@dudamel/mcp-memory 0.1.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/dist/http-client.d.ts +18 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +72 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +24 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio-server.d.ts +3 -0
- package/dist/stdio-server.d.ts.map +1 -0
- package/dist/stdio-server.js +15 -0
- package/dist/stdio-server.js.map +1 -0
- package/dist/tools/conversations.d.ts +5 -0
- package/dist/tools/conversations.d.ts.map +1 -0
- package/dist/tools/conversations.js +35 -0
- package/dist/tools/conversations.js.map +1 -0
- package/dist/tools/memories.d.ts +5 -0
- package/dist/tools/memories.d.ts.map +1 -0
- package/dist/tools/memories.js +150 -0
- package/dist/tools/memories.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +14 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +18 -0
- package/dist/util.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class DudamelApiError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly statusText: string;
|
|
4
|
+
readonly body: string;
|
|
5
|
+
constructor(status: number, statusText: string, body: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class DudamelApiClient {
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly headers;
|
|
10
|
+
constructor(baseUrl: string, apiKey: string, authScheme?: 'ApiKey' | 'Bearer');
|
|
11
|
+
get<T = unknown>(path: string, params?: Record<string, string>): Promise<T>;
|
|
12
|
+
post<T = unknown>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
13
|
+
put<T = unknown>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
14
|
+
delete<T = unknown>(path: string, params?: Record<string, string>): Promise<T>;
|
|
15
|
+
private buildUrl;
|
|
16
|
+
private request;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;aAEtB,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,IAAI,EAAE,MAAM;gBAFZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM;CAK/B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAQvE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAK3E,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ5F,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ3F,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKpF,OAAO,CAAC,QAAQ;YAYF,OAAO;CAiBtB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class DudamelApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
statusText;
|
|
4
|
+
body;
|
|
5
|
+
constructor(status, statusText, body) {
|
|
6
|
+
super(`Dudamel API error ${status} ${statusText}: ${body}`);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.statusText = statusText;
|
|
9
|
+
this.body = body;
|
|
10
|
+
this.name = 'DudamelApiError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class DudamelApiClient {
|
|
14
|
+
baseUrl;
|
|
15
|
+
headers;
|
|
16
|
+
constructor(baseUrl, apiKey, authScheme) {
|
|
17
|
+
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
18
|
+
this.headers = {
|
|
19
|
+
Authorization: `${authScheme ?? 'ApiKey'} ${apiKey}`,
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async get(path, params) {
|
|
24
|
+
const url = this.buildUrl(path, params);
|
|
25
|
+
return this.request(url, { method: 'GET' });
|
|
26
|
+
}
|
|
27
|
+
async post(path, body, params) {
|
|
28
|
+
const url = this.buildUrl(path, params);
|
|
29
|
+
return this.request(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async put(path, body, params) {
|
|
35
|
+
const url = this.buildUrl(path, params);
|
|
36
|
+
return this.request(url, {
|
|
37
|
+
method: 'PUT',
|
|
38
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async delete(path, params) {
|
|
42
|
+
const url = this.buildUrl(path, params);
|
|
43
|
+
return this.request(url, { method: 'DELETE' });
|
|
44
|
+
}
|
|
45
|
+
buildUrl(path, params) {
|
|
46
|
+
const url = new URL(path, this.baseUrl);
|
|
47
|
+
if (params) {
|
|
48
|
+
for (const [key, value] of Object.entries(params)) {
|
|
49
|
+
if (value !== undefined && value !== '') {
|
|
50
|
+
url.searchParams.set(key, value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return url.toString();
|
|
55
|
+
}
|
|
56
|
+
async request(url, init) {
|
|
57
|
+
const response = await fetch(url, {
|
|
58
|
+
...init,
|
|
59
|
+
headers: this.headers,
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
const body = await response.text();
|
|
63
|
+
throw new DudamelApiError(response.status, response.statusText, body);
|
|
64
|
+
}
|
|
65
|
+
const text = await response.text();
|
|
66
|
+
if (!text) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return JSON.parse(text);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAEtB;IACA;IACA;IAHlB,YACkB,MAAc,EACd,UAAkB,EAClB,IAAY;QAE5B,KAAK,CAAC,qBAAqB,MAAM,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC,CAAC;QAJ5C,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IACV,OAAO,C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CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,YAAY,CAAC;AAE/D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAyBrE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DudamelApiClient } from './http-client.js';
|
|
3
|
+
import { registerMemoryTools } from './tools/memories.js';
|
|
4
|
+
import { registerConversationTools } from './tools/conversations.js';
|
|
5
|
+
export function createMemoryServer(config) {
|
|
6
|
+
const server = new McpServer({ name: 'dudamel-memory', version: '0.1.0' }, {
|
|
7
|
+
capabilities: { tools: {} },
|
|
8
|
+
instructions: 'Dudamel Memory MCP — query and manage your memories and past conversations. ' +
|
|
9
|
+
'Always search before creating or updating a memory to avoid duplicates. ' +
|
|
10
|
+
'Write tools require a prior search in the same session.',
|
|
11
|
+
});
|
|
12
|
+
const client = new DudamelApiClient(config.apiUrl, config.apiKey, config.authScheme);
|
|
13
|
+
const ctx = {
|
|
14
|
+
userId: config.userId,
|
|
15
|
+
agentName: config.agentName,
|
|
16
|
+
seenIds: new Set(),
|
|
17
|
+
fetchedIds: new Set(),
|
|
18
|
+
hasListed: false,
|
|
19
|
+
};
|
|
20
|
+
registerMemoryTools(server, client, ctx);
|
|
21
|
+
registerConversationTools(server, client, ctx);
|
|
22
|
+
return server;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,MAAM,UAAU,kBAAkB,CAAC,MAAuB;IACxD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC5C;QACE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC3B,YAAY,EACV,8EAA8E;YAC9E,0EAA0E;YAC1E,yDAAyD;KAC5D,CACF,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACrF,MAAM,GAAG,GAAgB;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,UAAU,EAAE,IAAI,GAAG,EAAE;QACrB,SAAS,EAAE,KAAK;KACjB,CAAC;IAEF,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio-server.d.ts","sourceRoot":"","sources":["../src/stdio-server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { createMemoryServer } from './server.js';
|
|
4
|
+
const apiUrl = process.env['DUDAMEL_API_URL'] ?? 'http://orchestrator:3000';
|
|
5
|
+
const apiKey = process.env['DUDAMEL_API_KEY'];
|
|
6
|
+
const userId = process.env['DUDAMEL_USER_ID'] ?? '';
|
|
7
|
+
const agentName = process.env['DUDAMEL_AGENT_NAME'] ?? '';
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
process.stderr.write('Error: DUDAMEL_API_KEY environment variable is required.\n');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const server = createMemoryServer({ apiUrl, apiKey, userId, agentName });
|
|
13
|
+
const transport = new StdioServerTransport();
|
|
14
|
+
await server.connect(transport);
|
|
15
|
+
//# sourceMappingURL=stdio-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio-server.js","sourceRoot":"","sources":["../src/stdio-server.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,0BAA0B,CAAC;AAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;AACpD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;AAE1D,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AACzE,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { DudamelApiClient } from '../http-client.js';
|
|
3
|
+
import type { ToolContext } from '../types.js';
|
|
4
|
+
export declare function registerConversationTools(server: McpServer, client: DudamelApiClient, ctx: ToolContext): void;
|
|
5
|
+
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/tools/conversations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CA0CN"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { errorResult, jsonResult } from '../util.js';
|
|
3
|
+
export function registerConversationTools(server, client, ctx) {
|
|
4
|
+
server.registerTool('list-conversations', {
|
|
5
|
+
description: 'List past conversations for the current agent. Returns conversation metadata ' +
|
|
6
|
+
'including ids, timestamps, and summaries.',
|
|
7
|
+
annotations: { readOnlyHint: true },
|
|
8
|
+
}, async () => {
|
|
9
|
+
try {
|
|
10
|
+
const params = { agent: ctx.agentName };
|
|
11
|
+
const result = await client.get('/api/chat/conversations', params);
|
|
12
|
+
return jsonResult(result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return errorResult(err);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
server.registerTool('get-conversation-messages', {
|
|
19
|
+
description: 'Get the full message history for a specific conversation. Returns all messages ' +
|
|
20
|
+
'in chronological order.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
conversationId: z.string().describe('The conversation ID to retrieve messages for'),
|
|
23
|
+
},
|
|
24
|
+
annotations: { readOnlyHint: true },
|
|
25
|
+
}, async ({ conversationId }) => {
|
|
26
|
+
try {
|
|
27
|
+
const result = await client.get(`/api/chat/conversations/${conversationId}/messages`);
|
|
28
|
+
return jsonResult(result);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
return errorResult(err);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=conversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/tools/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,WAAW,EAAE,UAAU,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';
|
|
2
|
+
import type { DudamelApiClient } from '../http-client.js';
|
|
3
|
+
import type { ToolContext } from '../types.js';
|
|
4
|
+
export declare function registerMemoryTools(server: McpServer, client: DudamelApiClient, ctx: ToolContext): void;
|
|
5
|
+
//# sourceMappingURL=memories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/tools/memories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkB/C,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CAsKN"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { errorResult, jsonResult } from '../util.js';
|
|
3
|
+
// The 4 memory scopes (2×2). The server maps each to (agent_name, user_id) columns.
|
|
4
|
+
const SCOPE_DESCRIPTION = "Scope of the memory:\n" +
|
|
5
|
+
"- 'relational': what YOU (this agent) know about the CURRENT user.\n" +
|
|
6
|
+
"- 'profile': a fact about the CURRENT user, shared with all agents.\n" +
|
|
7
|
+
"- 'agent': org/general knowledge private to YOU (this agent), not about a user.\n" +
|
|
8
|
+
"- 'org': org-wide general knowledge, shared with all agents, not about a user.\n" +
|
|
9
|
+
"Ask: does this help me with ANYONE (org/agent) or only with THIS person (relational/profile)?";
|
|
10
|
+
export function registerMemoryTools(server, client, ctx) {
|
|
11
|
+
// ── Read: list (summaries) ─────────────────────────────────────────────────
|
|
12
|
+
server.registerTool('list-memories', {
|
|
13
|
+
description: 'List memories relevant to the current user (summaries only, NOT full content). ' +
|
|
14
|
+
'Returns the union of everything you know that applies here: your notes on this user, ' +
|
|
15
|
+
'their profile, and your/org general knowledge. Call this at the start of an interaction. ' +
|
|
16
|
+
'You MUST call this before creating a memory. Use get-memory to read a full entry.',
|
|
17
|
+
inputSchema: {
|
|
18
|
+
q: z.string().optional().describe('Keyword filter over summary + content (omit to list all)'),
|
|
19
|
+
scope: z.enum(['relational', 'profile', 'agent', 'org']).optional().describe('Filter to a single scope'),
|
|
20
|
+
},
|
|
21
|
+
annotations: { readOnlyHint: true },
|
|
22
|
+
}, async ({ q, scope }) => {
|
|
23
|
+
try {
|
|
24
|
+
const params = { agent: ctx.agentName };
|
|
25
|
+
if (q)
|
|
26
|
+
params['q'] = q;
|
|
27
|
+
if (scope)
|
|
28
|
+
params['scope'] = scope;
|
|
29
|
+
const rows = await client.get('/api/chat/memories', params);
|
|
30
|
+
if (Array.isArray(rows)) {
|
|
31
|
+
for (const r of rows)
|
|
32
|
+
if (r.id)
|
|
33
|
+
ctx.seenIds.add(r.id);
|
|
34
|
+
}
|
|
35
|
+
ctx.hasListed = true;
|
|
36
|
+
return jsonResult(rows);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return errorResult(err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// ── Read: get one (full content) ──────────────────────────────────────────
|
|
43
|
+
server.registerTool('get-memory', {
|
|
44
|
+
description: 'Get the full content of a single memory by id. You MUST call this before updating a ' +
|
|
45
|
+
'memory (so you edit its real content, not blindly). Ids come from list-memories.',
|
|
46
|
+
inputSchema: { id: z.string().describe('Memory id (from list-memories)') },
|
|
47
|
+
annotations: { readOnlyHint: true },
|
|
48
|
+
}, async ({ id }) => {
|
|
49
|
+
try {
|
|
50
|
+
const memory = await client.get(`/api/chat/memories/${id}`);
|
|
51
|
+
if (memory?.id) {
|
|
52
|
+
ctx.fetchedIds.add(memory.id);
|
|
53
|
+
ctx.seenIds.add(memory.id);
|
|
54
|
+
}
|
|
55
|
+
return jsonResult(memory);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return errorResult(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// ── Write: create ──────────────────────────────────────────────────────────
|
|
62
|
+
server.registerTool('create-memory', {
|
|
63
|
+
description: 'Create a NEW memory. Requires a prior list-memories call this session (to avoid ' +
|
|
64
|
+
'duplicates — if a similar memory exists, use update-memory instead). Content can be ' +
|
|
65
|
+
'multi-line markdown. A one-line summary is generated automatically; if the summary ' +
|
|
66
|
+
'service is unavailable the memory is NOT saved and you should retry later.',
|
|
67
|
+
inputSchema: {
|
|
68
|
+
scope: z.enum(['relational', 'profile', 'agent', 'org']).describe(SCOPE_DESCRIPTION),
|
|
69
|
+
content: z.string().describe('Full memory text (multi-line markdown allowed)'),
|
|
70
|
+
},
|
|
71
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
72
|
+
}, async ({ scope, content }) => {
|
|
73
|
+
if (!ctx.hasListed) {
|
|
74
|
+
return errorResult(new Error('Call list-memories first (to check for an existing memory to update instead of duplicating).'));
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const result = await client.post('/api/chat/memories', {
|
|
78
|
+
agentName: ctx.agentName,
|
|
79
|
+
scope,
|
|
80
|
+
content,
|
|
81
|
+
});
|
|
82
|
+
if (result?.id)
|
|
83
|
+
ctx.seenIds.add(result.id);
|
|
84
|
+
return jsonResult(result);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return errorResult(err);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
// ── Write: update ──────────────────────────────────────────────────────────
|
|
91
|
+
server.registerTool('update-memory', {
|
|
92
|
+
description: 'Update an existing memory\'s content (its summary is regenerated). You MUST call ' +
|
|
93
|
+
'get-memory on this id first, so you edit its real content. If the summary service is ' +
|
|
94
|
+
'unavailable the memory is NOT updated and you should retry later.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
id: z.string().describe('Memory id to update'),
|
|
97
|
+
content: z.string().describe('New full memory text (replaces the old content)'),
|
|
98
|
+
},
|
|
99
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
100
|
+
}, async ({ id, content }) => {
|
|
101
|
+
if (!ctx.fetchedIds.has(id)) {
|
|
102
|
+
return errorResult(new Error(`Call get-memory("${id}") first so you update its real content, not a guess.`));
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const result = await client.put(`/api/chat/memories/${id}`, { content });
|
|
106
|
+
return jsonResult(result);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
return errorResult(err);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// ── Write: delete ──────────────────────────────────────────────────────────
|
|
113
|
+
server.registerTool('delete-memory', {
|
|
114
|
+
description: 'Delete a memory by id. Requires the id to have been seen via list-memories or get-memory.',
|
|
115
|
+
inputSchema: { id: z.string().describe('Memory id to delete') },
|
|
116
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
117
|
+
}, async ({ id }) => {
|
|
118
|
+
if (!ctx.seenIds.has(id)) {
|
|
119
|
+
return errorResult(new Error(`Cannot delete ${id}: not seen in a prior list/get. Call list-memories first.`));
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
await client.delete(`/api/chat/memories/${id}`);
|
|
123
|
+
ctx.seenIds.delete(id);
|
|
124
|
+
ctx.fetchedIds.delete(id);
|
|
125
|
+
return jsonResult({ deleted: true, id });
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
return errorResult(err);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// ── Write: mark useful ─────────────────────────────────────────────────────
|
|
132
|
+
server.registerTool('mark-memory-useful', {
|
|
133
|
+
description: 'Mark a memory as useful now (bumps its recency ranking). Requires the id to have been ' +
|
|
134
|
+
'seen via list-memories or get-memory.',
|
|
135
|
+
inputSchema: { id: z.string().describe('Memory id to mark as useful') },
|
|
136
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
137
|
+
}, async ({ id }) => {
|
|
138
|
+
if (!ctx.seenIds.has(id)) {
|
|
139
|
+
return errorResult(new Error(`Cannot mark ${id}: not seen in a prior list/get. Call list-memories first.`));
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const result = await client.post(`/api/chat/memories/${id}/useful`, undefined);
|
|
143
|
+
return jsonResult(result);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
return errorResult(err);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=memories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memories.js","sourceRoot":"","sources":["../../src/tools/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,oFAAoF;AACpF,MAAM,iBAAiB,GACrB,wBAAwB;IACxB,sEAAsE;IACtE,uEAAuE;IACvE,mFAAmF;IACnF,kFAAkF;IAClF,+FAA+F,CAAC;AAQlG,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,MAAwB,EACxB,GAAgB;IAEhB,8EAA8E;IAC9E,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,WAAW,EACT,iFAAiF;YACjF,uFAAuF;YACvF,2FAA2F;YAC3F,mFAAmF;QACrF,WAAW,EAAE;YACX,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;YAC7F,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;SACzG;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;KACpC,EACD,KAAK,EAAE,EAAE,CAAC,EAAE,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S,EAAE,SAAS,CAAC,CAAC;YAC/E,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface McpMemoryConfig {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
authScheme?: 'ApiKey' | 'Bearer';
|
|
5
|
+
userId: string;
|
|
6
|
+
agentName: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolContext {
|
|
9
|
+
userId: string;
|
|
10
|
+
agentName: string;
|
|
11
|
+
/** Ids seen via list-memories or get-memory — gates delete / mark-useful. */
|
|
12
|
+
seenIds: Set<string>;
|
|
13
|
+
/** Ids whose full content was fetched via get-memory — gates update-memory. */
|
|
14
|
+
fetchedIds: Set<string>;
|
|
15
|
+
/** Whether list-memories/search ran this session — gates create-memory. */
|
|
16
|
+
hasListed: boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,+EAA+E;IAC/E,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function jsonResult(data: unknown): {
|
|
2
|
+
content: {
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare function errorResult(error: unknown): {
|
|
8
|
+
content: {
|
|
9
|
+
type: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
isError: boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO;;;;;EAIvC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO;;;;;;EAWzC"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DudamelApiError } from './http-client.js';
|
|
2
|
+
export function jsonResult(data) {
|
|
3
|
+
return {
|
|
4
|
+
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function errorResult(error) {
|
|
8
|
+
const message = error instanceof DudamelApiError
|
|
9
|
+
? `API error ${error.status}: ${error.body}`
|
|
10
|
+
: error instanceof Error
|
|
11
|
+
? error.message
|
|
12
|
+
: String(error);
|
|
13
|
+
return {
|
|
14
|
+
content: [{ type: 'text', text: message }],
|
|
15
|
+
isError: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,OAAO,GACX,KAAK,YAAY,eAAe;QAC9B,CAAC,CAAC,aAAa,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE;QAC5C,CAAC,CAAC,KAAK,YAAY,KAAK;YACtB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dudamel/mcp-memory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Dudamel Memory MCP — stdio client for an org's Dudamel memory (agent/user knowledge) over its REST API.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"dudamel-mcp-memory": "./dist/stdio-server.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/agents-squad/dudamel.git",
|
|
24
|
+
"directory": "packages/mcp/memory"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
31
|
+
"zod": "^3.24.4"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/express": "^5.0.6"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc",
|
|
38
|
+
"lint": "eslint src/",
|
|
39
|
+
"lint:fix": "eslint src/ --fix",
|
|
40
|
+
"test": "vitest run --passWithNoTests",
|
|
41
|
+
"clean": "rm -rf dist"
|
|
42
|
+
}
|
|
43
|
+
}
|