Stores and retrieves conversation history and code entity metadata across VS Code windows, enabling persistent context sharing and cross-repository code analysis.
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 messagesget_related_context- Find discussions mentioning same classes/filessearch_conversations- Full-text search across all workspacesget_workspace_summary- Overview of all tracked repositories
Resources (Automatic Context)
context://recent- Last 50 messages across all workspacescontext://workspace/{path}- History for specific repository
Installation
Install dependencies:
Build the server:
Configure in VS Code:
Add to your Copilot settings (~/Library/Application Support/Code/User/globalStorage/github.copilot-chat/mcpServers.json on macOS):
Restart VS Code
Usage
Automatic Context Sharing
When you open any VS Code window, Copilot can access:
Recent conversations from all windows via
context://recentresourceWorkspace-specific history via
context://workspace/{path}resource
Manual Context Queries
Ask Copilot to use the tools:
Example Workflow
Window A (ETL-core repo):
Window B (Consumer repo):
Architecture
Database Schema
messages table:
id: Primary keyworkspace_path: Repository pathrole: "user" or "assistant"content: Message texttimestamp: When saved
code_entities table:
message_id: Links to messageentity_type: "class", "file", or "method"entity_name: Name of the entity
workspace_metadata table:
workspace_path: Primary keymessage_count: Total messageslast_active: Last update timestamp
How It Works
Entity Extraction: Automatically detects Java classes, files, and methods in conversations
Smart Storage: Saves messages with extracted entities for later matching
Context Matching: When querying, finds messages mentioning same entities
Cross-Window Sync: All VS Code windows access same SQLite database
Development
Database Location
The SQLite database is stored at:
You can inspect it with any SQLite browser or CLI:
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.jsonis correctVerify
dist/index.jsexists after buildingCheck 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