@cogenta/mcp 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.
@@ -0,0 +1,17 @@
1
+ import type { ChildProcessLike, McpClient } from './types.js';
2
+ export interface McpStdioClientOptions {
3
+ readonly command: string;
4
+ readonly args?: readonly string[];
5
+ /** Injectable for tests — defaults to `node:child_process.spawn`, piping stdio. */
6
+ readonly spawnFn?: (command: string, args: readonly string[]) => ChildProcessLike;
7
+ }
8
+ /**
9
+ * The same JSON-RPC-per-line protocol `serveMcpOverStdio` (task 17) speaks,
10
+ * from the other end: spawns a third-party MCP server as a child process and
11
+ * talks to it over its stdio. "Le client MCP permet aux agents de consommer
12
+ * des serveurs tiers" — this is that consumption; `wrapMcpTool` is what
13
+ * turns what it discovers into something the runtime can actually grant to
14
+ * an agent, with permissions declared exactly like an internal tool.
15
+ */
16
+ export declare function createMcpStdioClient(options: McpStdioClientOptions): McpClient;
17
+ //# sourceMappingURL=stdio-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio-client.d.ts","sourceRoot":"","sources":["../../src/client/stdio-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EAIV,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,gBAAgB,CAAA;CAClF;AAOD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS,CA+D9E"}
@@ -0,0 +1,77 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createInterface } from 'node:readline';
3
+ import { CogentaError } from '@cogenta/core';
4
+ function defaultSpawn(command, args) {
5
+ const child = spawn(command, [...args], { stdio: ['pipe', 'pipe', 'inherit'] });
6
+ return { stdin: child.stdin, stdout: child.stdout, kill: () => child.kill() };
7
+ }
8
+ /**
9
+ * The same JSON-RPC-per-line protocol `serveMcpOverStdio` (task 17) speaks,
10
+ * from the other end: spawns a third-party MCP server as a child process and
11
+ * talks to it over its stdio. "Le client MCP permet aux agents de consommer
12
+ * des serveurs tiers" — this is that consumption; `wrapMcpTool` is what
13
+ * turns what it discovers into something the runtime can actually grant to
14
+ * an agent, with permissions declared exactly like an internal tool.
15
+ */
16
+ export function createMcpStdioClient(options) {
17
+ const spawnFn = options.spawnFn ?? defaultSpawn;
18
+ const child = spawnFn(options.command, options.args ?? []);
19
+ const rl = createInterface({ input: child.stdout });
20
+ const pending = new Map();
21
+ let nextId = 1;
22
+ rl.on('line', (line) => {
23
+ const trimmed = line.trim();
24
+ if (trimmed === '')
25
+ return;
26
+ let response;
27
+ try {
28
+ response = JSON.parse(trimmed);
29
+ }
30
+ catch {
31
+ return;
32
+ }
33
+ if (typeof response.id !== 'number')
34
+ return;
35
+ const resolve = pending.get(response.id);
36
+ if (resolve === undefined)
37
+ return;
38
+ pending.delete(response.id);
39
+ resolve(response);
40
+ });
41
+ function send(method, params) {
42
+ const id = nextId++;
43
+ return new Promise((resolve, reject) => {
44
+ pending.set(id, (response) => {
45
+ if ('error' in response) {
46
+ reject(new CogentaError({
47
+ code: 'MCP_CLIENT_REMOTE_ERROR',
48
+ message: response.error.message,
49
+ hint: 'The remote MCP server reported a protocol-level error, not a tool failure.',
50
+ details: { code: response.error.code, data: response.error.data },
51
+ }));
52
+ return;
53
+ }
54
+ resolve(response.result);
55
+ });
56
+ child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, ...(params === undefined ? {} : { params }) })}\n`);
57
+ });
58
+ }
59
+ return {
60
+ async initialize() {
61
+ const result = (await send('initialize'));
62
+ return result.serverInfo;
63
+ },
64
+ async listTools() {
65
+ const result = (await send('tools/list'));
66
+ return result.tools;
67
+ },
68
+ async callTool(name, args) {
69
+ return (await send('tools/call', { name, arguments: args }));
70
+ },
71
+ close() {
72
+ rl.close();
73
+ child.kill();
74
+ },
75
+ };
76
+ }
77
+ //# sourceMappingURL=stdio-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio-client.js","sourceRoot":"","sources":["../../src/client/stdio-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAiB5C,SAAS,YAAY,CAAC,OAAe,EAAE,IAAuB;IAC5D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;IAC/E,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAA;AAC/E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAA;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;IAC1D,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA+C,CAAA;IACtE,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,EAAE,CAAC,EA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C,CAAA;YAC1B,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,KAAK,CAAC,KAAK,CACf,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,CACnG,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,KAAK,CAAC,UAAU;YACd,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAkC,CAAA;YAC1E,OAAO,MAAM,CAAC,UAAU,CAAA;QAC1B,CAAC;QACD,KAAK,CAAC,SAAS;YACb,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAsC,CAAA;YAC9E,OAAO,MAAM,CAAC,KAAK,CAAA;QACrB,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI;YACvB,OAAO,CAAC,MAAM,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAsB,CAAA;QACnF,CAAC;QACD,KAAK;YACH,EAAE,CAAC,KAAK,EAAE,CAAA;YACV,KAAK,CAAC,IAAI,EAAE,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Readable, Writable } from 'node:stream';
2
+ export interface McpToolSpec {
3
+ readonly name: string;
4
+ readonly description: string;
5
+ readonly inputSchema: Readonly<Record<string, unknown>>;
6
+ }
7
+ export interface McpContentBlock {
8
+ readonly type: string;
9
+ readonly text: string;
10
+ }
11
+ export interface McpToolCallResult {
12
+ readonly content: readonly McpContentBlock[];
13
+ readonly isError: boolean;
14
+ }
15
+ export interface McpServerInfo {
16
+ readonly name: string;
17
+ readonly version: string;
18
+ }
19
+ export interface McpClient {
20
+ initialize(): Promise<McpServerInfo>;
21
+ listTools(): Promise<readonly McpToolSpec[]>;
22
+ callTool(name: string, args: Readonly<Record<string, unknown>>): Promise<McpToolCallResult>;
23
+ close(): void;
24
+ }
25
+ /** The minimal shape a spawned MCP server process needs — real `child_process.spawn()` already satisfies this; tests inject a fake. */
26
+ export interface ChildProcessLike {
27
+ readonly stdin: Writable;
28
+ readonly stdout: Readable;
29
+ kill(): void;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACxD;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,CAAA;IACpC,SAAS,IAAI,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAAA;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC3F,KAAK,IAAI,IAAI,CAAA;CACd;AAED,uIAAuI;AACvI,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;IACzB,IAAI,IAAI,IAAI,CAAA;CACb"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { type ToolCost, type ToolDefinition } from '@cogenta/agents';
2
+ import type { z } from 'zod';
3
+ import type { McpClient } from './types.js';
4
+ export interface WrapMcpToolOptions<Input, Output> {
5
+ readonly client: McpClient;
6
+ /** The tool's name on the remote server — may differ from `name` below. */
7
+ readonly remoteName: string;
8
+ readonly name: string;
9
+ readonly version: string;
10
+ readonly description: string;
11
+ readonly input: z.ZodType<Input>;
12
+ readonly output: z.ZodType<Output>;
13
+ /**
14
+ * Not read from the remote server's own `tools/list` — a third-party
15
+ * server has no way to declare, and no reason to be trusted to declare,
16
+ * what a local agent may do with it. "Le client MCP permet aux agents de
17
+ * consommer des serveurs tiers, avec les mêmes permissions déclarées que
18
+ * les outils internes": these five fields are the integrator's own
19
+ * declaration, checked by the same runtime (registry, manifest, audit,
20
+ * autonomy) as every other `defineTool` built in-repo.
21
+ */
22
+ readonly permissions: readonly string[];
23
+ readonly sideEffects: boolean;
24
+ readonly reversible: boolean;
25
+ readonly cost: ToolCost;
26
+ }
27
+ /**
28
+ * Turns one tool discovered on a remote MCP server into an ordinary
29
+ * `ToolDefinition` — from here on, the runtime cannot tell it apart from a
30
+ * tool implemented in this repository. `execute` calls the remote tool and
31
+ * maps its MCP result back to the declared Zod `output`; a remote failure
32
+ * (`isError: true`) becomes a thrown error, same as a local tool's.
33
+ */
34
+ export declare function wrapMcpTool<Input, Output>(options: WrapMcpToolOptions<Input, Output>): ToolDefinition<Input, Output>;
35
+ //# sourceMappingURL=wrap-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-tool.d.ts","sourceRoot":"","sources":["../../src/client/wrap-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,WAAW,kBAAkB,CAAC,KAAK,EAAE,MAAM;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EACvC,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CA+B/B"}
@@ -0,0 +1,40 @@
1
+ import { defineTool } from '@cogenta/agents';
2
+ import { CogentaError } from '@cogenta/core';
3
+ /**
4
+ * Turns one tool discovered on a remote MCP server into an ordinary
5
+ * `ToolDefinition` — from here on, the runtime cannot tell it apart from a
6
+ * tool implemented in this repository. `execute` calls the remote tool and
7
+ * maps its MCP result back to the declared Zod `output`; a remote failure
8
+ * (`isError: true`) becomes a thrown error, same as a local tool's.
9
+ */
10
+ export function wrapMcpTool(options) {
11
+ return defineTool({
12
+ name: options.name,
13
+ version: options.version,
14
+ description: options.description,
15
+ input: options.input,
16
+ output: options.output,
17
+ permissions: options.permissions,
18
+ sideEffects: options.sideEffects,
19
+ reversible: options.reversible,
20
+ cost: options.cost,
21
+ async execute(input) {
22
+ const result = await options.client.callTool(options.remoteName, input);
23
+ const text = result.content.map((block) => block.text).join('\n');
24
+ if (result.isError) {
25
+ throw new CogentaError({
26
+ code: 'MCP_CLIENT_TOOL_FAILED',
27
+ message: text === '' ? `"${options.remoteName}" failed on the remote MCP server.` : text,
28
+ hint: 'This is the remote tool reporting its own failure, not a protocol error.',
29
+ });
30
+ }
31
+ try {
32
+ return JSON.parse(text);
33
+ }
34
+ catch {
35
+ return text;
36
+ }
37
+ },
38
+ });
39
+ }
40
+ //# sourceMappingURL=wrap-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-tool.js","sourceRoot":"","sources":["../../src/client/wrap-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AA4B5C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,OAA0C;IAE1C,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAC1C,OAAO,CAAC,UAAU,EAClB,KAA0C,CAC3C,CAAA;YACD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjE,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,IAAI,YAAY,CAAC;oBACrB,IAAI,EAAE,wBAAwB;oBAC9B,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,UAAU,oCAAoC,CAAC,CAAC,CAAC,IAAI;oBACxF,IAAI,EAAE,0EAA0E;iBACjF,CAAC,CAAA;YACJ,CAAC;YACD,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAW,CAAA;YACnC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAyB,CAAA;YAClC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type { McpStdioClientOptions } from './client/stdio-client.js';
2
+ export { createMcpStdioClient } from './client/stdio-client.js';
3
+ export type { ChildProcessLike, McpClient, McpContentBlock, McpServerInfo, McpToolCallResult, McpToolSpec, } from './client/types.js';
4
+ export type { WrapMcpToolOptions } from './client/wrap-tool.js';
5
+ export { wrapMcpTool } from './client/wrap-tool.js';
6
+ export type { JsonRpcError, JsonRpcErrorPayload, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccess, } from './jsonrpc.js';
7
+ export { JsonRpcErrorCode, jsonRpcError, jsonRpcSuccess } from './jsonrpc.js';
8
+ export type { McpServer, McpServerOptions } from './server.js';
9
+ export { createMcpServer } from './server.js';
10
+ export type { StdioTransport, StdioTransportOptions } from './stdio-transport.js';
11
+ export { serveMcpOverStdio } from './stdio-transport.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7E,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { createMcpStdioClient } from './client/stdio-client.js';
2
+ export { wrapMcpTool } from './client/wrap-tool.js';
3
+ export { JsonRpcErrorCode, jsonRpcError, jsonRpcSuccess } from './jsonrpc.js';
4
+ export { createMcpServer } from './server.js';
5
+ export { serveMcpOverStdio } from './stdio-transport.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAU/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAQnD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * MCP is JSON-RPC 2.0 — this is that envelope, and only that envelope. R9:
3
+ * the official `@modelcontextprotocol/sdk` was audited and rejected for
4
+ * this — it pulls express, hono, ajv, jose and cross-spawn (100+ transitive
5
+ * packages, 4.3MB) to expose three methods (`initialize`, `tools/list`,
6
+ * `tools/call`); this package hand-rolls exactly that subset instead.
7
+ */
8
+ export interface JsonRpcRequest {
9
+ readonly jsonrpc: '2.0';
10
+ readonly id: string | number | null;
11
+ readonly method: string;
12
+ readonly params?: Readonly<Record<string, unknown>>;
13
+ }
14
+ export interface JsonRpcSuccess {
15
+ readonly jsonrpc: '2.0';
16
+ readonly id: string | number | null;
17
+ readonly result: unknown;
18
+ }
19
+ export interface JsonRpcErrorPayload {
20
+ readonly code: number;
21
+ readonly message: string;
22
+ readonly data?: unknown;
23
+ }
24
+ export interface JsonRpcError {
25
+ readonly jsonrpc: '2.0';
26
+ readonly id: string | number | null;
27
+ readonly error: JsonRpcErrorPayload;
28
+ }
29
+ export type JsonRpcResponse = JsonRpcSuccess | JsonRpcError;
30
+ /** The JSON-RPC 2.0 reserved codes this server actually raises. */
31
+ export declare const JsonRpcErrorCode: {
32
+ readonly PARSE_ERROR: -32700;
33
+ readonly INVALID_PARAMS: -32602;
34
+ readonly METHOD_NOT_FOUND: -32601;
35
+ };
36
+ export declare function jsonRpcSuccess(id: string | number | null, result: unknown): JsonRpcSuccess;
37
+ export declare function jsonRpcError(id: string | number | null, code: number, message: string, data?: unknown): JsonRpcError;
38
+ //# sourceMappingURL=jsonrpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAA;CACpC;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,CAAA;AAE3D,mEAAmE;AACnE,eAAO,MAAM,gBAAgB;aAC3B,WAAW,EAAE,CAAC,KAAK;aACnB,cAAc,EAAE,CAAC,KAAK;aACtB,gBAAgB,EAAE,CAAC,KAAK;CAChB,CAAA;AAEV,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,cAAc,CAE1F;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,OAAO,GACb,YAAY,CAEd"}
@@ -0,0 +1,13 @@
1
+ /** The JSON-RPC 2.0 reserved codes this server actually raises. */
2
+ export const JsonRpcErrorCode = {
3
+ PARSE_ERROR: -32700,
4
+ INVALID_PARAMS: -32602,
5
+ METHOD_NOT_FOUND: -32601,
6
+ };
7
+ export function jsonRpcSuccess(id, result) {
8
+ return { jsonrpc: '2.0', id, result };
9
+ }
10
+ export function jsonRpcError(id, code, message, data) {
11
+ return { jsonrpc: '2.0', id, error: { code, message, ...(data === undefined ? {} : { data }) } };
12
+ }
13
+ //# sourceMappingURL=jsonrpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAkCA,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,CAAC,KAAK;IACnB,cAAc,EAAE,CAAC,KAAK;IACtB,gBAAgB,EAAE,CAAC,KAAK;CAChB,CAAA;AAEV,MAAM,UAAU,cAAc,CAAC,EAA0B,EAAE,MAAe;IACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,EAA0B,EAC1B,IAAY,EACZ,OAAe,EACf,IAAc;IAEd,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAA;AAClG,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ExecutableTool } from '@cogenta/agents';
2
+ import { type JsonRpcRequest, type JsonRpcResponse } from './jsonrpc.js';
3
+ export interface McpServerOptions {
4
+ readonly name: string;
5
+ readonly version: string;
6
+ /**
7
+ * The already-built manifest for this MCP server's caller — permissions,
8
+ * autonomy and audit are decided by whoever built this list (task 4's
9
+ * `buildManifest`, plus whichever decorators from tasks 6/9/10 that caller
10
+ * wraps it in), never by this module. "Le registre d'outils est le
11
+ * serveur MCP : aucun travail supplémentaire, seulement une exposition."
12
+ */
13
+ readonly tools: readonly ExecutableTool[];
14
+ }
15
+ export interface McpServer {
16
+ /** Handles exactly one JSON-RPC request; the caller owns transport (stdio, HTTP, or a direct call in a test). */
17
+ handle(request: JsonRpcRequest): Promise<JsonRpcResponse>;
18
+ }
19
+ export declare function createMcpServer(options: McpServerOptions): McpServer;
20
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,eAAe,EAGrB,MAAM,cAAc,CAAA;AAIrB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAA;CAC1C;AAED,MAAM,WAAW,SAAS;IACxB,iHAAiH;IACjH,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1D;AAMD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAoEpE"}
package/dist/server.js ADDED
@@ -0,0 +1,57 @@
1
+ import { JsonRpcErrorCode, jsonRpcError, jsonRpcSuccess, } from './jsonrpc.js';
2
+ const PROTOCOL_VERSION = '2025-06-18';
3
+ function toolResultContent(text, isError) {
4
+ return { content: [{ type: 'text', text }], isError };
5
+ }
6
+ export function createMcpServer(options) {
7
+ const toolIndex = new Map(options.tools.map((tool) => [tool.spec.name, tool]));
8
+ return {
9
+ async handle(request) {
10
+ if (request.method === 'initialize') {
11
+ return jsonRpcSuccess(request.id, {
12
+ protocolVersion: PROTOCOL_VERSION,
13
+ serverInfo: { name: options.name, version: options.version },
14
+ capabilities: { tools: {} },
15
+ });
16
+ }
17
+ if (request.method === 'tools/list') {
18
+ return jsonRpcSuccess(request.id, {
19
+ tools: options.tools.map((tool) => ({
20
+ name: tool.spec.name,
21
+ description: tool.spec.description,
22
+ inputSchema: tool.spec.inputSchema,
23
+ })),
24
+ });
25
+ }
26
+ if (request.method === 'tools/call') {
27
+ const name = request.params?.name;
28
+ if (typeof name !== 'string') {
29
+ return jsonRpcError(request.id, JsonRpcErrorCode.INVALID_PARAMS, 'params.name must be a string.');
30
+ }
31
+ const tool = toolIndex.get(name);
32
+ if (tool === undefined) {
33
+ return jsonRpcError(request.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `No tool named "${name}" on this server.`);
34
+ }
35
+ const rawArguments = request.params?.arguments;
36
+ const toolArguments = rawArguments !== null && typeof rawArguments === 'object'
37
+ ? rawArguments
38
+ : {};
39
+ // A tool failure is MCP protocol data (isError: true in a successful
40
+ // result), never a JSON-RPC error — the call itself succeeded, the
41
+ // tool it invoked did not.
42
+ try {
43
+ const controller = new AbortController();
44
+ const output = await tool.execute(toolArguments, { signal: controller.signal });
45
+ const text = typeof output === 'string' ? output : JSON.stringify(output ?? null);
46
+ return jsonRpcSuccess(request.id, toolResultContent(text, false));
47
+ }
48
+ catch (error) {
49
+ const message = error instanceof Error ? error.message : String(error);
50
+ return jsonRpcSuccess(request.id, toolResultContent(message, true));
51
+ }
52
+ }
53
+ return jsonRpcError(request.id, JsonRpcErrorCode.METHOD_NOT_FOUND, `Unknown method "${request.method}".`);
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAGhB,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAA;AAErB,MAAM,gBAAgB,GAAG,YAAY,CAAA;AAoBrC,SAAS,iBAAiB,CAAC,IAAY,EAAE,OAAgB;IACvD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAyB;IACvD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IAE9E,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,OAAuB;YAClC,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBACpC,OAAO,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE;oBAChC,eAAe,EAAE,gBAAgB;oBACjC,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;oBAC5D,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;iBAC5B,CAAC,CAAA;YACJ,CAAC;YAED,IAAI,OAAO,CAAC,MAAM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AAC,aAAa,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA;oBAC/E,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,CAAA;oBACjF,OAAO,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;gBACnE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;oBACtE,OAAO,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;YAED,OAAO,YAAY,CACjB,OAAO,CAAC,EAAE,EACV,gBAAgB,CAAC,gBAAgB,EACjC,mBAAmB,OAAO,CAAC,MAAM,IAAI,CACtC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Readable, Writable } from 'node:stream';
2
+ import type { McpServer } from './server.js';
3
+ export interface StdioTransportOptions {
4
+ readonly server: McpServer;
5
+ /** Injectable for tests — defaults to the real process streams. */
6
+ readonly input?: Readable;
7
+ readonly output?: Writable;
8
+ }
9
+ export interface StdioTransport {
10
+ close(): void;
11
+ }
12
+ /**
13
+ * One JSON-RPC request per line in, one response per line out — MCP's
14
+ * simplest transport, and the only one this task needs: a locally-spawned
15
+ * server talking to its parent process over its own stdin/stdout, no HTTP
16
+ * server or network port involved.
17
+ */
18
+ export declare function serveMcpOverStdio(options: StdioTransportOptions): StdioTransport;
19
+ //# sourceMappingURL=stdio-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio-transport.d.ts","sourceRoot":"","sources":["../src/stdio-transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAyBhF"}
@@ -0,0 +1,32 @@
1
+ import { createInterface } from 'node:readline';
2
+ import { JsonRpcErrorCode, jsonRpcError } from './jsonrpc.js';
3
+ /**
4
+ * One JSON-RPC request per line in, one response per line out — MCP's
5
+ * simplest transport, and the only one this task needs: a locally-spawned
6
+ * server talking to its parent process over its own stdin/stdout, no HTTP
7
+ * server or network port involved.
8
+ */
9
+ export function serveMcpOverStdio(options) {
10
+ const input = options.input ?? process.stdin;
11
+ const output = options.output ?? process.stdout;
12
+ const rl = createInterface({ input });
13
+ rl.on('line', (line) => {
14
+ const trimmed = line.trim();
15
+ if (trimmed === '')
16
+ return;
17
+ void (async () => {
18
+ let request;
19
+ try {
20
+ request = JSON.parse(trimmed);
21
+ }
22
+ catch {
23
+ output.write(`${JSON.stringify(jsonRpcError(null, JsonRpcErrorCode.PARSE_ERROR, 'Invalid JSON.'))}\n`);
24
+ return;
25
+ }
26
+ const response = await options.server.handle(request);
27
+ output.write(`${JSON.stringify(response)}\n`);
28
+ })();
29
+ });
30
+ return { close: () => rl.close() };
31
+ }
32
+ //# sourceMappingURL=stdio-transport.js.map
@@ -0,0 +1 @@
1
+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C,EAAE,CAAC,KAAK,EAAE,EAAE,CAAA;AACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@cogenta/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP (Model Context Protocol) server and client — the tool registry, exposed.",
5
+ "license": "MPL-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "engines": {
18
+ "node": ">=22.11.0"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "provenance": true
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/cogenta-cms/cogenta.git",
27
+ "directory": "packages/mcp"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json",
31
+ "typecheck": "tsc -p tsconfig.typecheck.json",
32
+ "test": "vitest run --passWithNoTests"
33
+ },
34
+ "dependencies": {
35
+ "@cogenta/agents": "workspace:*",
36
+ "@cogenta/core": "workspace:*",
37
+ "zod": "catalog:"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "catalog:",
41
+ "vitest": "catalog:"
42
+ }
43
+ }