@nish_ntr/chat-memory-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +205 -0
- package/bin/start.js +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +411 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Chat Memory MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that enables AI agents in VS Code to search and retrieve content from past Copilot Chat sessions across all workspaces.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Search Chat History**: Search through all past VS Code Copilot Chat sessions using natural language queries
|
|
8
|
+
- **AI-Generated Summaries**: Uses LLM sampling to generate concise summaries of chat sessions
|
|
9
|
+
- **Clean Prompt Chains**: Full transcripts are sent to the LLM for summarization but removed from the response
|
|
10
|
+
- **Cross-Workspace**: Access chat history from all workspaces, not just the current one
|
|
11
|
+
- **Platform Support**: Works on macOS, Windows, and Linux
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- **MCP Client with Sampling Support**: The MCP client (Cline, Roo Code, etc.) must support the `sampling` capability to enable AI-generated summaries
|
|
16
|
+
- **Node.js**: Version 18.0.0 or higher
|
|
17
|
+
|
|
18
|
+
## Tools Provided
|
|
19
|
+
|
|
20
|
+
### 1. `search_vs_code_chats`
|
|
21
|
+
|
|
22
|
+
Search through past VS Code Copilot Chat sessions.
|
|
23
|
+
|
|
24
|
+
**Input:**
|
|
25
|
+
- `query` (string): Search query to find in chat titles and messages
|
|
26
|
+
|
|
27
|
+
**Output:**
|
|
28
|
+
- Array of matching sessions with metadata (sessionId, title, workspaceName, lastModified)
|
|
29
|
+
|
|
30
|
+
### 2. `get_vs_code_chat_content`
|
|
31
|
+
|
|
32
|
+
Retrieve an AI-generated summary of a specific chat session.
|
|
33
|
+
|
|
34
|
+
**Input:**
|
|
35
|
+
- `sessionId` (string): Absolute file path to the chat session JSON file (obtained from search results)
|
|
36
|
+
|
|
37
|
+
**Output:**
|
|
38
|
+
- AI-generated concise summary of the conversation (3-5 sentences)
|
|
39
|
+
- Chat title and message count
|
|
40
|
+
- Note: The full transcript is sent to the LLM for summarization but is NOT included in the response, keeping the prompt chain clean
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cd /home/compro/nishant-compro/chat-memory
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
### For Cline
|
|
53
|
+
|
|
54
|
+
Add to your Cline MCP settings file (usually `~/.cline/mcp_settings.json` or in VS Code settings):
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"chat-memory": {
|
|
60
|
+
"command": "node",
|
|
61
|
+
"args": ["/home/compro/nishant-compro/chat-memory/dist/index.js"],
|
|
62
|
+
"env": {}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or in VS Code settings (`settings.json`):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"cline.mcpServers": {
|
|
73
|
+
"chat-memory": {
|
|
74
|
+
"command": "node",
|
|
75
|
+
"args": ["/home/compro/nishant-compro/chat-memory/dist/index.js"],
|
|
76
|
+
"env": {}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### For Roo Code
|
|
83
|
+
|
|
84
|
+
Add to `.roo/mcp.json` in your workspace or in VS Code settings:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"mcpServers": {
|
|
89
|
+
"chat-memory": {
|
|
90
|
+
"command": "node",
|
|
91
|
+
"args": ["/home/compro/nishant-compro/chat-memory/dist/index.js"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or in VS Code settings (`settings.json`):
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"roo-cline.mcpServers": {
|
|
102
|
+
"chat-memory": {
|
|
103
|
+
"command": "node",
|
|
104
|
+
"args": ["/home/compro/nishant-compro/chat-memory/dist/index.js"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### For VS Code Copilot MCP
|
|
111
|
+
|
|
112
|
+
Add to VS Code `settings.json`:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"github.copilot.chat.mcp.servers": {
|
|
117
|
+
"chat-memory": {
|
|
118
|
+
"command": "node",
|
|
119
|
+
"args": ["/home/compro/nishant-compro/chat-memory/dist/index.js"]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Usage Examples
|
|
126
|
+
|
|
127
|
+
Once configured, agents can use these tools automatically. Here are example requests:
|
|
128
|
+
|
|
129
|
+
### Searching Chat History
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
"Search my past chats for discussions about React hooks"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The agent will use `search_vs_code_chats` with query "React hooks" and return matching sessions.
|
|
136
|
+
|
|
137
|
+
### Retrieving Chat Summaries
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
"Give me a summary of that chat about authentication"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The agent will:
|
|
144
|
+
1. Search for chats about "authentication"
|
|
145
|
+
2. Use `get_vs_code_chat_content` with the sessionId to retrieve a concise summary
|
|
146
|
+
|
|
147
|
+
## Data Location
|
|
148
|
+
|
|
149
|
+
The server reads VS Code chat sessions from:
|
|
150
|
+
|
|
151
|
+
- **macOS**: `~/Library/Application Support/Code/User/workspaceStorage/*/chatSessions/*.json`
|
|
152
|
+
- **Windows**: `%APPDATA%\Code\User\workspaceStorage\*/chatSessions\*.json`
|
|
153
|
+
- **Linux**: `~/.config/Code/User/workspaceStorage/*/chatSessions/*.json`
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Install dependencies
|
|
159
|
+
npm install
|
|
160
|
+
|
|
161
|
+
# Run in development mode (with hot reload)
|
|
162
|
+
npm run dev
|
|
163
|
+
|
|
164
|
+
# Build for production
|
|
165
|
+
npm run build
|
|
166
|
+
|
|
167
|
+
# Run built version
|
|
168
|
+
npm start
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Troubleshooting
|
|
172
|
+
|
|
173
|
+
### Server not appearing in agent tools
|
|
174
|
+
|
|
175
|
+
1. Ensure you've run `npm run build` after installation
|
|
176
|
+
2. Check that the path in your configuration matches the actual installation location
|
|
177
|
+
3. Restart VS Code after adding the configuration
|
|
178
|
+
4. Check the agent's MCP connection logs for errors
|
|
179
|
+
|
|
180
|
+
### "Sampling not supported" error
|
|
181
|
+
|
|
182
|
+
If you get an error about sampling not being supported:
|
|
183
|
+
1. Ensure your MCP client (Cline, Roo Code, etc.) supports the `sampling` capability
|
|
184
|
+
2. Update to the latest version of your MCP client
|
|
185
|
+
3. Check the client's documentation for sampling support
|
|
186
|
+
|
|
187
|
+
### No chat sessions found
|
|
188
|
+
|
|
189
|
+
1. Verify that you have past Copilot Chat conversations in VS Code
|
|
190
|
+
2. Check that the workspace storage path exists on your system
|
|
191
|
+
3. Ensure the server has read permissions for the workspace storage directory
|
|
192
|
+
|
|
193
|
+
### Permission errors
|
|
194
|
+
|
|
195
|
+
On macOS/Linux, ensure the workspace storage directory is readable:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Check permissions
|
|
199
|
+
ls -la ~/.config/Code/User/workspaceStorage # Linux
|
|
200
|
+
ls -la ~/Library/Application\ Support/Code/User/workspaceStorage # macOS
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT
|
package/bin/start.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmdA,wBAAsB,WAAW,kBAKhC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import * as z from 'zod';
|
|
4
|
+
import { readdir, readFile, stat } from 'fs/promises';
|
|
5
|
+
import { join, basename } from 'path';
|
|
6
|
+
import { homedir, platform } from 'os';
|
|
7
|
+
import Fuse from 'fuse.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Utility Functions
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Get the VS Code workspace storage path based on the current OS
|
|
13
|
+
*/
|
|
14
|
+
function getWorkspaceStoragePath() {
|
|
15
|
+
const home = homedir();
|
|
16
|
+
const os = platform();
|
|
17
|
+
switch (os) {
|
|
18
|
+
case 'darwin': // macOS
|
|
19
|
+
return join(home, 'Library/Application Support/Code/User/workspaceStorage');
|
|
20
|
+
case 'win32': // Windows
|
|
21
|
+
return join(process.env.APPDATA || join(home, 'AppData/Roaming'), 'Code/User/workspaceStorage');
|
|
22
|
+
case 'linux': // Linux
|
|
23
|
+
return join(home, '.config/Code/User/workspaceStorage');
|
|
24
|
+
default:
|
|
25
|
+
return join(home, '.config/Code/User/workspaceStorage'); // Default to Linux path
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse workspace.json to extract human-readable workspace name
|
|
30
|
+
*/
|
|
31
|
+
async function getWorkspaceName(workspaceHashFolder) {
|
|
32
|
+
try {
|
|
33
|
+
const workspaceJsonPath = join(workspaceHashFolder, 'workspace.json');
|
|
34
|
+
const content = await readFile(workspaceJsonPath, 'utf-8');
|
|
35
|
+
const data = JSON.parse(content);
|
|
36
|
+
// Try to extract folder path or workspace name
|
|
37
|
+
if (data.folder) {
|
|
38
|
+
// folder is typically a URI like "file:///path/to/workspace"
|
|
39
|
+
const folderUri = data.folder;
|
|
40
|
+
const folderPath = folderUri.replace(/^file:\/\//, '');
|
|
41
|
+
return basename(folderPath) || basename(workspaceHashFolder);
|
|
42
|
+
}
|
|
43
|
+
if (data.workspace) {
|
|
44
|
+
const workspaceUri = data.workspace;
|
|
45
|
+
const workspacePath = workspaceUri.replace(/^file:\/\//, '');
|
|
46
|
+
return basename(workspacePath) || basename(workspaceHashFolder);
|
|
47
|
+
}
|
|
48
|
+
// Fallback to hash folder name
|
|
49
|
+
return basename(workspaceHashFolder);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
// If we can't read workspace.json, use the hash folder name
|
|
53
|
+
return basename(workspaceHashFolder);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Find all chat session JSON files in the workspace storage directory
|
|
58
|
+
*/
|
|
59
|
+
async function findChatSessionFiles() {
|
|
60
|
+
const results = [];
|
|
61
|
+
const storagePath = getWorkspaceStoragePath();
|
|
62
|
+
try {
|
|
63
|
+
const workspaceFolders = await readdir(storagePath);
|
|
64
|
+
for (const folder of workspaceFolders) {
|
|
65
|
+
const workspaceFolder = join(storagePath, folder);
|
|
66
|
+
try {
|
|
67
|
+
const chatSessionsDir = join(workspaceFolder, 'chatSessions');
|
|
68
|
+
const stats = await stat(chatSessionsDir);
|
|
69
|
+
if (stats.isDirectory()) {
|
|
70
|
+
const files = await readdir(chatSessionsDir);
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
if (file.endsWith('.json')) {
|
|
73
|
+
results.push({
|
|
74
|
+
filePath: join(chatSessionsDir, file),
|
|
75
|
+
workspaceFolder: workspaceFolder,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// Skip folders without chatSessions directory or with permission errors
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// If workspace storage path doesn't exist, return empty array
|
|
89
|
+
console.error('Error accessing workspace storage:', error);
|
|
90
|
+
}
|
|
91
|
+
return results;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extract messages from VS Code chat session JSON (handles multiple schemas)
|
|
95
|
+
*/
|
|
96
|
+
function extractMessages(jsonData) {
|
|
97
|
+
const messages = [];
|
|
98
|
+
try {
|
|
99
|
+
// Try different JSON schema variants
|
|
100
|
+
// Schema 1: { requests: [...] }
|
|
101
|
+
if (jsonData.requests && Array.isArray(jsonData.requests)) {
|
|
102
|
+
for (const request of jsonData.requests) {
|
|
103
|
+
if (request.message) {
|
|
104
|
+
let userContent = '';
|
|
105
|
+
if (typeof request.message === 'string') {
|
|
106
|
+
userContent = request.message;
|
|
107
|
+
}
|
|
108
|
+
else if (request.message.text) {
|
|
109
|
+
userContent = request.message.text;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
userContent = JSON.stringify(request.message);
|
|
113
|
+
}
|
|
114
|
+
messages.push({
|
|
115
|
+
role: 'user',
|
|
116
|
+
content: userContent,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (request.response) {
|
|
120
|
+
let assistantContent = '';
|
|
121
|
+
if (Array.isArray(request.response)) {
|
|
122
|
+
assistantContent = request.response.map((r) => r.value || r.text || (typeof r === 'string' ? r : JSON.stringify(r))).join('\n');
|
|
123
|
+
}
|
|
124
|
+
else if (typeof request.response === 'string') {
|
|
125
|
+
assistantContent = request.response;
|
|
126
|
+
}
|
|
127
|
+
else if (request.response.text) {
|
|
128
|
+
assistantContent = request.response.text;
|
|
129
|
+
}
|
|
130
|
+
else if (request.response.value) {
|
|
131
|
+
assistantContent = request.response.value;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
assistantContent = JSON.stringify(request.response);
|
|
135
|
+
}
|
|
136
|
+
messages.push({
|
|
137
|
+
role: 'assistant',
|
|
138
|
+
content: assistantContent,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Schema 2: { turns: [...] }
|
|
144
|
+
if (jsonData.turns && Array.isArray(jsonData.turns)) {
|
|
145
|
+
for (const turn of jsonData.turns) {
|
|
146
|
+
if (turn.request || turn.prompt) {
|
|
147
|
+
const userMessage = turn.request || turn.prompt;
|
|
148
|
+
messages.push({
|
|
149
|
+
role: 'user',
|
|
150
|
+
content: typeof userMessage === 'string' ? userMessage : JSON.stringify(userMessage),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (turn.response || turn.completion) {
|
|
154
|
+
const assistantMessage = turn.response || turn.completion;
|
|
155
|
+
messages.push({
|
|
156
|
+
role: 'assistant',
|
|
157
|
+
content: typeof assistantMessage === 'string' ? assistantMessage : JSON.stringify(assistantMessage),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Schema 3: { messages: [...] }
|
|
163
|
+
if (jsonData.messages && Array.isArray(jsonData.messages)) {
|
|
164
|
+
for (const msg of jsonData.messages) {
|
|
165
|
+
if (msg.role === 'user' || msg.role === 'assistant') {
|
|
166
|
+
messages.push({
|
|
167
|
+
role: msg.role,
|
|
168
|
+
content: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Schema 4: { entries: [...] } (some versions use entries)
|
|
174
|
+
if (jsonData.entries && Array.isArray(jsonData.entries)) {
|
|
175
|
+
for (const entry of jsonData.entries) {
|
|
176
|
+
if (entry.type === 'user' || entry.author === 'user') {
|
|
177
|
+
messages.push({
|
|
178
|
+
role: 'user',
|
|
179
|
+
content: typeof entry.text === 'string' ? entry.text : JSON.stringify(entry),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (entry.type === 'assistant' || entry.author === 'assistant') {
|
|
183
|
+
messages.push({
|
|
184
|
+
role: 'assistant',
|
|
185
|
+
content: typeof entry.text === 'string' ? entry.text : JSON.stringify(entry),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error('Error extracting messages:', error);
|
|
193
|
+
}
|
|
194
|
+
return messages;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the title of a chat session from JSON data
|
|
198
|
+
*/
|
|
199
|
+
function getChatTitle(jsonData) {
|
|
200
|
+
let title = jsonData.title || jsonData.name || jsonData.label;
|
|
201
|
+
// Handle complex title objects/JSON strings often found in newer VS Code versions
|
|
202
|
+
if (title && typeof title === 'string' && title.trim().startsWith('{')) {
|
|
203
|
+
try {
|
|
204
|
+
const parsed = JSON.parse(title);
|
|
205
|
+
if (parsed.parts && Array.isArray(parsed.parts)) {
|
|
206
|
+
title = parsed.parts
|
|
207
|
+
.map((p) => (typeof p === 'string' ? p : p.value || p.text || ''))
|
|
208
|
+
.join('')
|
|
209
|
+
.trim();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
// If parsing fails, use the original title string
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (title && typeof title === 'string' && title.trim().length > 0) {
|
|
217
|
+
return title;
|
|
218
|
+
}
|
|
219
|
+
// Try to extract from first message if no title found
|
|
220
|
+
const messages = extractMessages(jsonData);
|
|
221
|
+
if (messages.length > 0 && messages[0].role === 'user') {
|
|
222
|
+
const firstMessage = messages[0].content;
|
|
223
|
+
return firstMessage.substring(0, 100).replace(/\n/g, ' ') + (firstMessage.length > 100 ? '...' : '');
|
|
224
|
+
}
|
|
225
|
+
return 'Untitled Chat';
|
|
226
|
+
}
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// MCP Server Setup
|
|
229
|
+
// ============================================================================
|
|
230
|
+
const server = new McpServer({
|
|
231
|
+
name: 'chat-memory',
|
|
232
|
+
version: '1.0.0',
|
|
233
|
+
});
|
|
234
|
+
// ============================================================================
|
|
235
|
+
// Tool 1: search_vs_code_chats
|
|
236
|
+
// ============================================================================
|
|
237
|
+
server.registerTool('search_vs_code_chats', {
|
|
238
|
+
title: 'Search VS Code Chat History',
|
|
239
|
+
description: 'Search through past VS Code Copilot Chat sessions across all workspaces',
|
|
240
|
+
inputSchema: {
|
|
241
|
+
query: z.string().describe('Search query to find in chat titles and messages'),
|
|
242
|
+
},
|
|
243
|
+
}, async ({ query }, extra) => {
|
|
244
|
+
const chatFiles = await findChatSessionFiles();
|
|
245
|
+
const allSessions = [];
|
|
246
|
+
// Get current session ID from MCP transport context
|
|
247
|
+
const currentSessionId = extra?.sessionId;
|
|
248
|
+
for (const { filePath, workspaceFolder } of chatFiles) {
|
|
249
|
+
try {
|
|
250
|
+
const content = await readFile(filePath, 'utf-8');
|
|
251
|
+
const jsonData = JSON.parse(content);
|
|
252
|
+
// DEFINITIVE EXCLUSION: Compare VS Code chat session ID with MCP session ID
|
|
253
|
+
if (currentSessionId && jsonData.sessionId === currentSessionId) {
|
|
254
|
+
continue; // Skip current session
|
|
255
|
+
}
|
|
256
|
+
// Extract title and messages
|
|
257
|
+
const title = getChatTitle(jsonData);
|
|
258
|
+
const messages = extractMessages(jsonData);
|
|
259
|
+
const fileStats = await stat(filePath);
|
|
260
|
+
const workspaceName = await getWorkspaceName(workspaceFolder);
|
|
261
|
+
// Limit indexed message content to first 10k chars for performance
|
|
262
|
+
const messageText = messages.map(m => m.content).join(' ').substring(0, 10000);
|
|
263
|
+
allSessions.push({
|
|
264
|
+
sessionId: filePath,
|
|
265
|
+
title,
|
|
266
|
+
messageText,
|
|
267
|
+
workspaceName,
|
|
268
|
+
workspacePath: workspaceFolder,
|
|
269
|
+
lastModified: fileStats.mtime.toISOString(),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
// Skip files that can't be parsed
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Meaningful comparison using Fuse.js (fuzzy search)
|
|
278
|
+
const fuse = new Fuse(allSessions, {
|
|
279
|
+
keys: [
|
|
280
|
+
{ name: 'title', weight: 0.7 },
|
|
281
|
+
{ name: 'messageText', weight: 0.3 }
|
|
282
|
+
],
|
|
283
|
+
threshold: 0.4, // 0.0 = perfect match, 1.0 = match anything
|
|
284
|
+
ignoreLocation: true,
|
|
285
|
+
includeScore: true,
|
|
286
|
+
distance: 100, // Search radius
|
|
287
|
+
minMatchCharLength: 2,
|
|
288
|
+
useExtendedSearch: true // Allows for operators like | (OR) and ! (NOT)
|
|
289
|
+
});
|
|
290
|
+
const searchResults = fuse.search(query);
|
|
291
|
+
// Convert Fuse results back to ChatSessionResult
|
|
292
|
+
const results = searchResults.slice(0, 2).map(result => ({
|
|
293
|
+
sessionId: result.item.sessionId,
|
|
294
|
+
title: result.item.title,
|
|
295
|
+
workspaceName: result.item.workspaceName,
|
|
296
|
+
workspacePath: result.item.workspacePath,
|
|
297
|
+
lastModified: result.item.lastModified
|
|
298
|
+
}));
|
|
299
|
+
// If no results from fuzzy search, fall back to literal substring check (wider net)
|
|
300
|
+
if (results.length === 0) {
|
|
301
|
+
const queryLower = query.toLowerCase();
|
|
302
|
+
const literalResults = allSessions
|
|
303
|
+
.filter(s => s.title.toLowerCase().includes(queryLower) || s.messageText.toLowerCase().includes(queryLower))
|
|
304
|
+
.slice(0, 2)
|
|
305
|
+
.map(s => ({
|
|
306
|
+
sessionId: s.sessionId,
|
|
307
|
+
title: s.title,
|
|
308
|
+
workspaceName: s.workspaceName,
|
|
309
|
+
workspacePath: s.workspacePath,
|
|
310
|
+
lastModified: s.lastModified
|
|
311
|
+
}));
|
|
312
|
+
results.push(...literalResults);
|
|
313
|
+
}
|
|
314
|
+
const output = { sessions: results };
|
|
315
|
+
return {
|
|
316
|
+
content: [
|
|
317
|
+
{
|
|
318
|
+
type: 'text',
|
|
319
|
+
text: JSON.stringify(output, null, 2),
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
};
|
|
323
|
+
});
|
|
324
|
+
// ============================================================================
|
|
325
|
+
// Tool 2: get_vs_code_chat_content
|
|
326
|
+
// ============================================================================
|
|
327
|
+
server.registerTool('get_vs_code_chat_content', {
|
|
328
|
+
title: 'Get VS Code Chat Summary',
|
|
329
|
+
description: 'Retrieve an AI-generated summary of a specific chat session (not full transcript to avoid polluting prompt chain)',
|
|
330
|
+
inputSchema: {
|
|
331
|
+
sessionId: z.string().describe('Absolute file path to the chat session JSON file'),
|
|
332
|
+
},
|
|
333
|
+
}, async ({ sessionId }) => {
|
|
334
|
+
try {
|
|
335
|
+
const content = await readFile(sessionId, 'utf-8');
|
|
336
|
+
const jsonData = JSON.parse(content);
|
|
337
|
+
const title = getChatTitle(jsonData);
|
|
338
|
+
const messages = extractMessages(jsonData);
|
|
339
|
+
// Format full transcript for LLM summarization
|
|
340
|
+
const transcriptLines = [];
|
|
341
|
+
const MAX_TRANSCRIPT_LENGTH = 15000; // Character limit to avoid context window issues
|
|
342
|
+
for (const msg of messages) {
|
|
343
|
+
const speaker = msg.role === 'user' ? 'USER' : 'ASSISTANT';
|
|
344
|
+
transcriptLines.push(`[${speaker}]: ${msg.content}`);
|
|
345
|
+
}
|
|
346
|
+
let fullTranscript = transcriptLines.join('\n\n');
|
|
347
|
+
if (fullTranscript.length > MAX_TRANSCRIPT_LENGTH) {
|
|
348
|
+
fullTranscript = fullTranscript.substring(0, MAX_TRANSCRIPT_LENGTH) + '\n\n... (transcript truncated for brevity) ...';
|
|
349
|
+
}
|
|
350
|
+
// Request LLM to generate summary using MCP sampling
|
|
351
|
+
// This sends the full transcript to the LLM, which then gets removed from the prompt chain
|
|
352
|
+
const response = await server.server.createMessage({
|
|
353
|
+
messages: [
|
|
354
|
+
{
|
|
355
|
+
role: 'user',
|
|
356
|
+
content: {
|
|
357
|
+
type: 'text',
|
|
358
|
+
text: `Please provide a concise summary of the following VS Code Copilot chat conversation. Focus on:\n1. The main topics discussed\n2. Key problems or questions raised\n3. Important solutions or approaches suggested\n4. Any action items or decisions\n\nKeep the summary to 5-8 sentences maximum.\n\nChat Title: ${title}\n\nConversation:\n${fullTranscript}`,
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
maxTokens: 500,
|
|
363
|
+
});
|
|
364
|
+
// Extract summary from LLM response
|
|
365
|
+
const aiSummary = response.content.type === 'text'
|
|
366
|
+
? response.content.text
|
|
367
|
+
: JSON.stringify(response.content);
|
|
368
|
+
// Note: The full transcript was sent to the LLM for summarization
|
|
369
|
+
// but is NOT included in the output, keeping the prompt chain clean
|
|
370
|
+
const output = {
|
|
371
|
+
summary: aiSummary,
|
|
372
|
+
title,
|
|
373
|
+
messageCount: messages.length,
|
|
374
|
+
};
|
|
375
|
+
return {
|
|
376
|
+
content: [
|
|
377
|
+
{
|
|
378
|
+
type: 'text',
|
|
379
|
+
text: JSON.stringify(output, null, 2),
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
386
|
+
return {
|
|
387
|
+
content: [
|
|
388
|
+
{
|
|
389
|
+
type: 'text',
|
|
390
|
+
text: `Error: ${errorMessage}`,
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
// ============================================================================
|
|
397
|
+
// Server Initialization
|
|
398
|
+
// ============================================================================
|
|
399
|
+
export async function startServer() {
|
|
400
|
+
const transport = new StdioServerTransport();
|
|
401
|
+
await server.connect(transport);
|
|
402
|
+
console.error('Chat Memory MCP Server running on stdio');
|
|
403
|
+
}
|
|
404
|
+
const isMain = process.argv[1]?.endsWith('index.ts') || process.argv[1]?.endsWith('index.js');
|
|
405
|
+
if (isMain) {
|
|
406
|
+
startServer().catch((error) => {
|
|
407
|
+
console.error('Fatal error:', error);
|
|
408
|
+
process.exit(1);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAmB3B,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,uBAAuB;IAC9B,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IAEtB,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,QAAQ,EAAE,QAAQ;YACrB,OAAO,IAAI,CAAC,IAAI,EAAE,wDAAwD,CAAC,CAAC;QAC9E,KAAK,OAAO,EAAE,UAAU;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG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
|
2
|
+
"name": "@nish_ntr/chat-memory-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server to search and retrieve VS Code Copilot Chat history",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"chat-memory-mcp": "./bin/start.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"bin"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "tsx src/index.ts",
|
|
21
|
+
"prepare": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"mcp",
|
|
25
|
+
"model-context-protocol",
|
|
26
|
+
"vscode",
|
|
27
|
+
"copilot",
|
|
28
|
+
"chat-memory"
|
|
29
|
+
],
|
|
30
|
+
"author": "nishntr",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
34
|
+
"fuse.js": "^7.1.0",
|
|
35
|
+
"zod": "^3.24.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.10.5",
|
|
39
|
+
"tsx": "^4.19.2",
|
|
40
|
+
"typescript": "^5.7.2"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|