Context Persistence MCP Server

Context Persistence MCP Server

Enables cross-window context sharing in VS Code by persisting Copilot conversations to SQLite, allowing code discussions from one repository to be accessible in other VS Code windows through smart entity matching and search.

Category
Visit Server

README

Context Persistence MCP Server

A Model Context Protocol (MCP) server that enables cross-window context sharing in VS Code. This solves the problem of losing conversation context when working across multiple VS Code windows with different repositories.

Problem Statement

When working with multiple repositories in separate VS Code windows:

  • Conversations with Copilot in Window A are not available in Window B
  • Analyzing code dependencies across repos requires repeating context
  • No shared memory of previous discussions when switching windows

Example: You analyze SparkJobX.java usage in Repo B, then switch to Repo A to modify the implementation - but Copilot doesn't know about your analysis from Window B.

Solution

This MCP server provides:

  • Persistent Storage: All conversations saved to SQLite
  • Cross-Window Access: Context available across all VS Code windows
  • Smart Matching: Automatically links related discussions by code entities (classes, files, methods)
  • Hybrid Approach: Both automatic resources and explicit tools for querying context

Features

Tools (Explicit Queries)

  • save_conversation - Store conversation messages
  • get_related_context - Find discussions mentioning same classes/files
  • search_conversations - Full-text search across all workspaces
  • get_workspace_summary - Overview of all tracked repositories

Resources (Automatic Context)

  • context://recent - Last 50 messages across all workspaces
  • context://workspace/{path} - History for specific repository

Installation

  1. Install dependencies:
npm install
  1. Build the server:
npm run build
  1. Configure in VS Code:

Add to your Copilot settings (~/Library/Application Support/Code/User/globalStorage/github.copilot-chat/mcpServers.json on macOS):

{
  "mcpServers": {
    "context-persistence": {
      "command": "node",
      "args": [
        "/Users/j0k0h1v/Documents/AI/McpServerPoc/dist/index.js"
      ]
    }
  }
}
  1. Restart VS Code

Usage

Automatic Context Sharing

When you open any VS Code window, Copilot can access:

  • Recent conversations from all windows via context://recent resource
  • Workspace-specific history via context://workspace/{path} resource

Manual Context Queries

Ask Copilot to use the tools:

"Check if we discussed SparkJobX in other repositories"
→ Copilot will call get_related_context with entities: ["SparkJobX"]

"Search our previous conversations about performance optimization"
→ Copilot will call search_conversations with query: "performance optimization"

"What repositories have we analyzed?"
→ Copilot will call get_workspace_summary

Example Workflow

Window A (ETL-core repo):

You: "Analyze SparkJobX.java performance"
Copilot: [analyzes code] "The job processes 1M records..."
[Context automatically saved]

Window B (Consumer repo):

You: "Why is SparkJobX slow when imported here?"
Copilot: [checks context://recent resource]
         "Based on our previous analysis in ETL-core, SparkJobX processes 1M records..."

Architecture

┌─────────────────────────────────┐
│  VS Code Window A (Repo A)      │
│  ├─ Copilot Chat                │
│  └─ MCP Client                  │
└─────────────┬───────────────────┘
              │
              ├─── Tools ──────┐
              │                 │
              ├─── Resources ──┤
              │                 │
        ┌─────▼─────────────────▼───┐
        │  MCP Server                │
        │  ├─ Save conversations     │
        │  ├─ Extract entities       │
        │  └─ Match context          │
        └─────┬──────────────────────┘
              │
        ┌─────▼──────────────────────┐
        │  SQLite Database           │
        │  ~/.context-persistence-mcp│
        │  ├─ messages               │
        │  ├─ code_entities          │
        │  └─ workspace_metadata     │
        └─────┬──────────────────────┘
              │
┌─────────────┴───────────────────┐
│  VS Code Window B (Repo B)      │
│  ├─ Copilot Chat                │
│  └─ MCP Client                  │
└─────────────────────────────────┘

Database Schema

messages table:

  • id: Primary key
  • workspace_path: Repository path
  • role: "user" or "assistant"
  • content: Message text
  • timestamp: When saved

code_entities table:

  • message_id: Links to message
  • entity_type: "class", "file", or "method"
  • entity_name: Name of the entity

workspace_metadata table:

  • workspace_path: Primary key
  • message_count: Total messages
  • last_active: Last update timestamp

How It Works

  1. Entity Extraction: Automatically detects Java classes, files, and methods in conversations
  2. Smart Storage: Saves messages with extracted entities for later matching
  3. Context Matching: When querying, finds messages mentioning same entities
  4. Cross-Window Sync: All VS Code windows access same SQLite database

Development

# Watch mode for development
npm run dev

# Build for production
npm run build

# Run directly
npm start

Database Location

The SQLite database is stored at:

~/.context-persistence-mcp/context.db

You can inspect it with any SQLite browser or CLI:

sqlite3 ~/.context-persistence-mcp/context.db

Limitations & Future Enhancements

Current (MVP):

  • Simple keyword matching for entities
  • Single-user local storage
  • Manual tool invocation by Copilot

Planned:

  • Semantic similarity using embeddings
  • Automatic dependency detection from pom.xml/build.gradle
  • Repository relationship mapping
  • Multi-user support with authentication
  • Automatic context injection based on relevance
  • Time-based context pruning

Troubleshooting

Server not starting?

  • Check the path in mcpServers.json is correct
  • Verify dist/index.js exists after building
  • Check VS Code output panel for MCP logs

No context appearing?

  • Ensure conversations are being saved (ask Copilot to save explicitly first)
  • Check database: sqlite3 ~/.context-persistence-mcp/context.db "SELECT COUNT(*) FROM messages;"
  • Restart VS Code after configuration changes

Related context not found?

  • Entity extraction is pattern-based - use clear class/file names
  • Try explicit search: "search for [keyword] in our conversations"

Contributing

This is a POC. Feedback and improvements welcome!

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured