@agent-deck/backend 1.2.10 → 1.3.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/.tsbuildinfo +1 -1
- package/dist/cli-runtime.d.ts +40 -0
- package/dist/cli-runtime.d.ts.map +1 -1
- package/dist/cli-runtime.js +67 -0
- package/dist/cli-runtime.js.map +1 -1
- package/dist/mcp-server.d.ts +3 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +22 -644
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp-tools/deck-card-ops.d.ts +21 -0
- package/dist/mcp-tools/deck-card-ops.d.ts.map +1 -0
- package/dist/mcp-tools/deck-card-ops.js +94 -0
- package/dist/mcp-tools/deck-card-ops.js.map +1 -0
- package/dist/mcp-tools/profile.d.ts +17 -0
- package/dist/mcp-tools/profile.d.ts.map +1 -0
- package/dist/mcp-tools/profile.js +25 -0
- package/dist/mcp-tools/profile.js.map +1 -0
- package/dist/mcp-tools/register.d.ts +49 -0
- package/dist/mcp-tools/register.d.ts.map +1 -0
- package/dist/mcp-tools/register.js +635 -0
- package/dist/mcp-tools/register.js.map +1 -0
- package/dist/mcp-tools/test-harness.d.ts +31 -0
- package/dist/mcp-tools/test-harness.d.ts.map +1 -0
- package/dist/mcp-tools/test-harness.js +108 -0
- package/dist/mcp-tools/test-harness.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AgentDeckMCPServer } from '../mcp-server';
|
|
2
|
+
import type { McpToolProfile } from './profile';
|
|
3
|
+
export declare const MCP_ACCEPT = "application/json, text/event-stream";
|
|
4
|
+
export declare function initializePayload(id?: number, clientName?: string): {
|
|
5
|
+
jsonrpc: string;
|
|
6
|
+
id: number;
|
|
7
|
+
method: string;
|
|
8
|
+
params: {
|
|
9
|
+
protocolVersion: string;
|
|
10
|
+
capabilities: {};
|
|
11
|
+
clientInfo: {
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function waitForMcpHealth(port: number): Promise<void>;
|
|
18
|
+
export declare function postInitialize(port: number, id?: number, clientName?: string): Promise<Response>;
|
|
19
|
+
export declare function listTools(port: number, sessionId: string, id: number): Promise<{
|
|
20
|
+
name: string;
|
|
21
|
+
inputSchema?: {
|
|
22
|
+
required?: string[];
|
|
23
|
+
};
|
|
24
|
+
}[]>;
|
|
25
|
+
export declare function callTool(port: number, sessionId: string, name: string, args: unknown, id: number): Promise<Record<string, unknown>>;
|
|
26
|
+
export declare function startMcpServer(backendUrl: string, profile?: McpToolProfile): Promise<{
|
|
27
|
+
port: number;
|
|
28
|
+
server: AgentDeckMCPServer;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function openSession(port: number, id?: number): Promise<string>;
|
|
31
|
+
//# sourceMappingURL=test-harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.d.ts","sourceRoot":"","sources":["../../src/mcp-tools/test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,eAAO,MAAM,UAAU,wCAAwC,CAAC;AAEhE,wBAAgB,iBAAiB,CAAC,EAAE,SAAI,EAAE,UAAU,SAAW;;;;;;;;;;;;EAW9D;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAalE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAI,EAAE,UAAU,SAAW,qBAS/E;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;UAgBtC,MAAM;kBAAgB;QAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;KAGjF;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,MAAM,oCA4BX;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,cAA2B,GACnC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAMvD;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOvE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCP_ACCEPT = void 0;
|
|
4
|
+
exports.initializePayload = initializePayload;
|
|
5
|
+
exports.waitForMcpHealth = waitForMcpHealth;
|
|
6
|
+
exports.postInitialize = postInitialize;
|
|
7
|
+
exports.listTools = listTools;
|
|
8
|
+
exports.callTool = callTool;
|
|
9
|
+
exports.startMcpServer = startMcpServer;
|
|
10
|
+
exports.openSession = openSession;
|
|
11
|
+
const mcp_server_1 = require("../mcp-server");
|
|
12
|
+
exports.MCP_ACCEPT = 'application/json, text/event-stream';
|
|
13
|
+
function initializePayload(id = 1, clientName = 'vitest') {
|
|
14
|
+
return {
|
|
15
|
+
jsonrpc: '2.0',
|
|
16
|
+
id,
|
|
17
|
+
method: 'initialize',
|
|
18
|
+
params: {
|
|
19
|
+
protocolVersion: '2024-11-05',
|
|
20
|
+
capabilities: {},
|
|
21
|
+
clientInfo: { name: clientName, version: '1.0.0' },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function waitForMcpHealth(port) {
|
|
26
|
+
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch(`http://127.0.0.1:${port}/health`);
|
|
29
|
+
if (response.ok) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// retry
|
|
35
|
+
}
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`MCP server on :${port} did not become healthy`);
|
|
39
|
+
}
|
|
40
|
+
async function postInitialize(port, id = 1, clientName = 'vitest') {
|
|
41
|
+
return fetch(`http://127.0.0.1:${port}/mcp`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
Accept: exports.MCP_ACCEPT,
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify(initializePayload(id, clientName)),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function listTools(port, sessionId, id) {
|
|
51
|
+
const response = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
Accept: exports.MCP_ACCEPT,
|
|
56
|
+
'mcp-session-id': sessionId,
|
|
57
|
+
},
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
jsonrpc: '2.0',
|
|
60
|
+
id,
|
|
61
|
+
method: 'tools/list',
|
|
62
|
+
params: {},
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
const body = (await response.json());
|
|
66
|
+
return body.result?.tools ?? [];
|
|
67
|
+
}
|
|
68
|
+
async function callTool(port, sessionId, name, args, id) {
|
|
69
|
+
const response = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: {
|
|
72
|
+
'Content-Type': 'application/json',
|
|
73
|
+
Accept: exports.MCP_ACCEPT,
|
|
74
|
+
'mcp-session-id': sessionId,
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
jsonrpc: '2.0',
|
|
78
|
+
id,
|
|
79
|
+
method: 'tools/call',
|
|
80
|
+
params: { name, arguments: args },
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
const body = (await response.json());
|
|
84
|
+
if (body.error) {
|
|
85
|
+
throw new Error(`MCP tools/call error: ${JSON.stringify(body.error)}`);
|
|
86
|
+
}
|
|
87
|
+
const text = body.result?.content?.[0]?.text;
|
|
88
|
+
if (typeof text !== 'string') {
|
|
89
|
+
throw new Error(`Unexpected tools/call result: ${JSON.stringify(body)}`);
|
|
90
|
+
}
|
|
91
|
+
return JSON.parse(text);
|
|
92
|
+
}
|
|
93
|
+
async function startMcpServer(backendUrl, profile = 'standard') {
|
|
94
|
+
const port = 36_000 + Math.floor(Math.random() * 3_000);
|
|
95
|
+
const server = new mcp_server_1.AgentDeckMCPServer(port, backendUrl, profile);
|
|
96
|
+
await server.start();
|
|
97
|
+
await waitForMcpHealth(port);
|
|
98
|
+
return { port, server };
|
|
99
|
+
}
|
|
100
|
+
async function openSession(port, id = 1) {
|
|
101
|
+
const init = await postInitialize(port, id);
|
|
102
|
+
const sessionId = init.headers.get('mcp-session-id');
|
|
103
|
+
if (!sessionId) {
|
|
104
|
+
throw new Error('Missing mcp-session-id');
|
|
105
|
+
}
|
|
106
|
+
return sessionId;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=test-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.js","sourceRoot":"","sources":["../../src/mcp-tools/test-harness.ts"],"names":[],"mappings":";;;AAKA,8CAWC;AAED,4CAaC;AAED,wCASC;AAED,8BAmBC;AAED,4BAiCC;AAED,wCASC;AAED,kCAOC;AAtHD,8CAAmD;AAGtC,QAAA,UAAU,GAAG,qCAAqC,CAAC;AAEhE,SAAgB,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,QAAQ;IAC7D,OAAO;QACL,OAAO,EA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AAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;AACrD,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,UAA0B,UAAU;IAEpC,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,+BAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAEM,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,EAAE,GAAG,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-deck/backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Agent Deck backend API, MCP server, and vault",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"prepublishOnly": "node ../../scripts/pre-publish-check.mjs && npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@agent-deck/shared": "^1.
|
|
40
|
+
"@agent-deck/shared": "^1.3.0",
|
|
41
41
|
"@fastify/cors": "^10.0.0",
|
|
42
42
|
"@fastify/static": "^8.0.0",
|
|
43
43
|
"@fastify/websocket": "^11.2.0",
|