Context MCP Server

Persistent context management for AI agents using Upstash Vector DB

README.md

Context MCP

A Model Context Protocol (MCP) server that provides persistent context management for AI agents like Cursor, Claude Code, and Claude Desktop. Uses Upstash Vector DB for storage and Google AI for embeddings.

Features

  • Add Context: Store text with metadata, automatically embedded and indexed
  • Query Context: Semantic search to find relevant stored information
  • Batch Operations: Efficiently add or delete multiple contexts
  • Metadata Filtering: Filter queries by metadata attributes
  • Statistics: Monitor your vector database usage

Prerequisites

  1. Upstash Vector DB account - Sign up at Upstash

    • Create a new Vector Index with dimension 768 (for Google's text-embedding-004)
    • Get your REST URL and Token
  2. Google AI API Key - Get from Google AI Studio

Installation

# Clone the repository
git clone <your-repo-url>
cd context-mcp

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Create a .env file based on .env.example:

cp .env.example .env

Fill in your credentials:

UPSTASH_VECTOR_REST_URL=your_upstash_vector_url
UPSTASH_VECTOR_REST_TOKEN=your_upstash_vector_token
GOOGLE_AI_API_KEY=your_google_ai_api_key

Usage with AI Agents

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "context": {
      "command": "node",
      "args": ["path/to/context-mcp/dist/index.js"],
      "env": {
        "UPSTASH_VECTOR_REST_URL": "your_url",
        "UPSTASH_VECTOR_REST_TOKEN": "your_token",
        "GOOGLE_AI_API_KEY": "your_key"
      }
    }
  }
}

Cursor

Add to your Cursor MCP settings:

{
  "mcpServers": {
    "context": {
      "command": "node",
      "args": ["path/to/context-mcp/dist/index.js"],
      "env": {
        "UPSTASH_VECTOR_REST_URL": "your_url",
        "UPSTASH_VECTOR_REST_TOKEN": "your_token",
        "GOOGLE_AI_API_KEY": "your_key"
      }
    }
  }
}

Claude Code (Windsurf)

Add to your MCP configuration file.

Available Tools

`add_context`

Store a single piece of context.

Parameters:

  • id (required): Unique identifier
  • content (required): Text content to store
  • metadata (optional): Key-value pairs for filtering

`add_contexts_batch`

Store multiple contexts efficiently.

Parameters:

  • contexts (required): Array of {id, content, metadata} objects

`query_context`

Search for relevant contexts.

Parameters:

  • query (required): Natural language search query
  • topK (optional): Number of results (1-20, default: 5)
  • filter (optional): Upstash filter expression

`delete_context`

Delete a single context by ID.

Parameters:

  • id (required): ID of context to delete

`delete_contexts_batch`

Delete multiple contexts.

Parameters:

  • ids (required): Array of IDs to delete

`get_stats`

Get database statistics (vector count, dimensions).

Example Usage

Once connected, you can ask your AI agent to:

"Add this project documentation to my context with id 'project-readme'"

"Search my context for information about authentication"

"Store these meeting notes with category 'meetings' and date '2024-01-15'"

"What relevant context do I have about the payment system?"

Upstash Filter Syntax

When querying, you can filter by metadata:

# Exact match
category = 'meetings'

# Numeric comparison  
priority > 5

# Multiple conditions
category = 'docs' AND priority >= 3

Development

# Run in development mode
npm run dev

# Build for production
npm run build

# Start production server
npm start

License

MIT

Tools 6

add_contextStore a single piece of context.
add_contexts_batchStore multiple contexts efficiently.
query_contextSearch for relevant contexts.
delete_contextDelete a single context by ID.
delete_contexts_batchDelete multiple contexts.
get_statsGet database statistics (vector count, dimensions).

Environment Variables

UPSTASH_VECTOR_REST_URLrequiredThe REST URL for your Upstash Vector Index
UPSTASH_VECTOR_REST_TOKENrequiredThe REST token for your Upstash Vector Index
GOOGLE_AI_API_KEYrequiredAPI key for Google AI embeddings

Try it

Add this project documentation to my context with id 'project-readme'
Search my context for information about authentication
Store these meeting notes with category 'meetings' and date '2024-01-15'
What relevant context do I have about the payment system?

Frequently Asked Questions

What are the key features of Context MCP?

Persistent storage of text context with metadata. Semantic search capabilities using Google AI embeddings. Batch operations for efficient data management. Metadata-based filtering for precise retrieval. Database statistics monitoring.

What can I use Context MCP for?

Storing project documentation for quick retrieval by AI agents. Managing meeting notes with searchable metadata. Indexing technical specifications for cross-referencing during coding tasks. Maintaining a persistent knowledge base for long-term AI assistant memory.

How do I install Context MCP?

Install Context MCP by running: git clone <your-repo-url> && cd context-mcp && npm install && npm run build

What MCP clients work with Context MCP?

Context MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Context MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare