agentfootprint 7.12.0 → 7.13.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/core/Agent.js +39 -5
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +59 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +6 -0
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +14 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/callLLM.js +10 -4
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/seed.js +16 -0
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/slots/buildSystemPromptSlot.js +2 -1
- package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +7 -3
- package/dist/esm/core/Agent.js +39 -5
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +48 -1
- package/dist/esm/core/agent/AgentBuilder.js +59 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.js +6 -0
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +14 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/stages/callLLM.d.ts +9 -0
- package/dist/esm/core/agent/stages/callLLM.js +10 -4
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +10 -1
- package/dist/esm/core/agent/stages/seed.js +16 -0
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +44 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +19 -4
- package/dist/esm/core/slots/buildSystemPromptSlot.js +2 -1
- package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.d.ts +1 -0
- package/dist/esm/lib/injection-engine/index.js +4 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillsFromDir.d.ts +80 -0
- package/dist/esm/lib/injection-engine/skillsFromDir.js +243 -0
- package/dist/esm/lib/injection-engine/skillsFromDir.js.map +1 -0
- package/dist/esm/lib/mcp/index.d.ts +6 -5
- package/dist/esm/lib/mcp/index.js +5 -4
- package/dist/esm/lib/mcp/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpClient.js +21 -9
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.d.ts +70 -0
- package/dist/esm/lib/mcp/mcpServe.js +374 -0
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -0
- package/dist/esm/lib/mcp/types.d.ts +130 -17
- package/dist/esm/lib/mcp/types.js +10 -10
- package/dist/esm/tool-providers/index.d.ts +8 -2
- package/dist/esm/tool-providers/index.js +7 -1
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/lib/injection-engine/index.js +6 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillsFromDir.js +270 -0
- package/dist/lib/injection-engine/skillsFromDir.js.map +1 -0
- package/dist/lib/mcp/index.js +7 -5
- package/dist/lib/mcp/index.js.map +1 -1
- package/dist/lib/mcp/mcpClient.js +21 -9
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +401 -0
- package/dist/lib/mcp/mcpServe.js.map +1 -0
- package/dist/lib/mcp/types.js +10 -10
- package/dist/tool-providers/index.js +8 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/types/core/Agent.d.ts +7 -3
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +48 -1
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/callLLM.d.ts +9 -0
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +10 -1
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +44 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/slots/buildSystemPromptSlot.d.ts +19 -4
- package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillsFromDir.d.ts +81 -0
- package/dist/types/lib/injection-engine/skillsFromDir.d.ts.map +1 -0
- package/dist/types/lib/mcp/index.d.ts +6 -5
- package/dist/types/lib/mcp/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts +71 -0
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -0
- package/dist/types/lib/mcp/types.d.ts +130 -17
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +8 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillsFromDir.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/skillsFromDir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAE3E,2DAA2D;AAC3D,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B;;;;GAIG;AACH,MAAM,aAAa,GAAG,uBAAuB,CAAC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
+
* MCP — Model Context Protocol, both directions. `mcpClient` connects to
|
|
3
|
+
* someone else's MCP server and registers its tools on your Agent;
|
|
4
|
+
* `mcpServe` exposes your own tools AS an MCP server so any MCP client
|
|
5
|
+
* can call them.
|
|
6
6
|
*/
|
|
7
7
|
export { mcpClient } from './mcpClient.js';
|
|
8
|
+
export { mcpServe } from './mcpServe.js';
|
|
8
9
|
export { mockMcpClient, type MockMcpClientOptions, type MockMcpTool } from './mockMcpClient.js';
|
|
9
|
-
export type { McpClient, McpClientOptions, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, } from './types.js';
|
|
10
|
+
export type { McpClient, McpClientOptions, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, McpServeOptions, McpServeHandle, McpServeTransport, McpHttpServeTransport, McpStdioServeTransport, McpSdkServer, } from './types.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP — Model Context Protocol
|
|
3
|
-
* server
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* MCP — Model Context Protocol, both directions. `mcpClient` connects to
|
|
3
|
+
* someone else's MCP server and registers its tools on your Agent;
|
|
4
|
+
* `mcpServe` exposes your own tools AS an MCP server so any MCP client
|
|
5
|
+
* can call them.
|
|
6
6
|
*/
|
|
7
7
|
export { mcpClient } from './mcpClient.js';
|
|
8
|
+
export { mcpServe } from './mcpServe.js';
|
|
8
9
|
export { mockMcpClient } from './mockMcpClient.js';
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAA+C,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAA+C,MAAM,oBAAoB,CAAC"}
|
|
@@ -52,7 +52,7 @@ const DEFAULT_CLIENT_INFO = {
|
|
|
52
52
|
*/
|
|
53
53
|
export async function mcpClient(opts) {
|
|
54
54
|
const name = opts.name ?? 'mcp';
|
|
55
|
-
const sdk = opts._client ?? (await resolveClient(opts.transport, opts.clientInfo));
|
|
55
|
+
const sdk = opts._client ?? (await resolveClient(opts.transport, opts.clientInfo, opts.signal));
|
|
56
56
|
// Tool cache so consumers calling `.tools()` more than once don't
|
|
57
57
|
// hammer the server. `.refresh()` invalidates it.
|
|
58
58
|
let cache = null;
|
|
@@ -63,7 +63,11 @@ export async function mcpClient(opts) {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
const buildTools = async () => {
|
|
66
|
-
|
|
66
|
+
// `signal` rides in the SDK's THIRD argument (RequestOptions), not in
|
|
67
|
+
// the request params — see `wrapMcpTool`.
|
|
68
|
+
const listed = opts.signal
|
|
69
|
+
? await sdk.listTools(undefined, { signal: opts.signal })
|
|
70
|
+
: await sdk.listTools();
|
|
67
71
|
return listed.tools.map((t) => wrapMcpTool(name, sdk, t, opts.signal));
|
|
68
72
|
};
|
|
69
73
|
return {
|
|
@@ -89,7 +93,7 @@ export async function mcpClient(opts) {
|
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
// ─── SDK construction (lazy require) ───────────────────────────────
|
|
92
|
-
async function resolveClient(transport, clientInfo) {
|
|
96
|
+
async function resolveClient(transport, clientInfo, signal) {
|
|
93
97
|
let mod;
|
|
94
98
|
try {
|
|
95
99
|
mod = lazyRequire('@modelcontextprotocol/sdk/client/index.js');
|
|
@@ -103,7 +107,11 @@ async function resolveClient(transport, clientInfo) {
|
|
|
103
107
|
capabilities: {},
|
|
104
108
|
});
|
|
105
109
|
const transportImpl = await buildTransport(transport);
|
|
106
|
-
|
|
110
|
+
// Same rule as callTool: options ride beside the transport, never inside it.
|
|
111
|
+
if (signal)
|
|
112
|
+
await client.connect(transportImpl, { signal });
|
|
113
|
+
else
|
|
114
|
+
await client.connect(transportImpl);
|
|
107
115
|
return client;
|
|
108
116
|
}
|
|
109
117
|
async function buildTransport(t) {
|
|
@@ -151,11 +159,15 @@ function wrapMcpTool(serverName, sdk, mcp, signal) {
|
|
|
151
159
|
const argsObj = args !== null && typeof args === 'object' && !Array.isArray(args)
|
|
152
160
|
? args
|
|
153
161
|
: {};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
// The abort signal is NOT a request param — it belongs to the SDK's
|
|
163
|
+
// third argument (`RequestOptions`). Put it in the params object and
|
|
164
|
+
// it gets serialized onto the wire as an empty `{}` and the call is
|
|
165
|
+
// uncancellable: a silent no-op that only a real transport reveals.
|
|
166
|
+
// `resultSchema` (2nd arg) is left to the SDK's own default.
|
|
167
|
+
const params = { name: mcp.name, arguments: argsObj };
|
|
168
|
+
const result = signal
|
|
169
|
+
? await sdk.callTool(params, undefined, { signal })
|
|
170
|
+
: await sdk.callTool(params);
|
|
159
171
|
// MCP returns content blocks. We concatenate text blocks into
|
|
160
172
|
// a single string for the agent's tool-result event payload.
|
|
161
173
|
// Non-text blocks (images, resources) are summarized with their
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qEAAqE;AACrE,uEAAuE;AACvE,mEAAmE;AACnE,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,gBAAgB;IACtB,OAAO,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,CAAC,MAAM,CAAC,CAAC;YAC/B,8DAA8D;YAC9D,6DAA6D;YAC7D,gEAAgE;YAChE,iEAAiE;YACjE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;iBACxB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;iBAClE,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,CAAC,IAAI,cAAc,UAAU,yBAAyB,IAAI,EAAE,CAC7E,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpServe — expose your agentfootprint tools AS an MCP server.
|
|
3
|
+
*
|
|
4
|
+
* const handle = await mcpServe([lookupTool, refundTool], {
|
|
5
|
+
* name: 'support-desk',
|
|
6
|
+
* version: '1.0.0',
|
|
7
|
+
* });
|
|
8
|
+
*
|
|
9
|
+
* // …later
|
|
10
|
+
* await handle.close();
|
|
11
|
+
*
|
|
12
|
+
* `mcpClient` pulls someone else's tools in. This pushes yours out, so
|
|
13
|
+
* the tool you already wrote, tested and governed can be called by any
|
|
14
|
+
* MCP client — a desktop host, another team's agent, an IDE — without
|
|
15
|
+
* being rewritten against a second tool interface.
|
|
16
|
+
*
|
|
17
|
+
* Pattern: Adapter (GoF), pointed the other way. `mcpClient` translates
|
|
18
|
+
* MCP → `Tool`; this translates `Tool` → MCP. Same SDK, same
|
|
19
|
+
* lazy-require discipline, mirrored lifecycle (`close()`).
|
|
20
|
+
*
|
|
21
|
+
* ── The one promise worth stating plainly ────────────────────────────
|
|
22
|
+
* A served tool is THE SAME OBJECT you passed in. `mcpServe` holds your
|
|
23
|
+
* `Tool` by reference and calls `tool.execute(args, ctx)` — it never
|
|
24
|
+
* copies the schema and re-implements the body, never unwraps a
|
|
25
|
+
* decorator, never reaches past a wrapper to an inner tool. So whatever
|
|
26
|
+
* governance you composed around that tool — a permission check inside
|
|
27
|
+
* `execute`, a redaction step, an audit hook — is still the thing that
|
|
28
|
+
* runs when a remote client calls it. Serving is not a second door into
|
|
29
|
+
* your tool; it is the same door with a longer corridor.
|
|
30
|
+
*
|
|
31
|
+
* Two demands the library CANNOT keep over MCP are refused at
|
|
32
|
+
* construction rather than silently dropped:
|
|
33
|
+
* - `checkIn` (human consent before the tool runs) needs a pause
|
|
34
|
+
* channel that a request/response protocol does not have.
|
|
35
|
+
* - `needs` (declare-and-push credentials) needs a provider; without
|
|
36
|
+
* one the tool would run with `ctx.credential` undefined.
|
|
37
|
+
*
|
|
38
|
+
* ── Schemas ──────────────────────────────────────────────────────────
|
|
39
|
+
* Tools already carry JSON Schema in `schema.inputSchema`, and MCP's
|
|
40
|
+
* `tools/list` wants JSON Schema, so the mapping is the identity
|
|
41
|
+
* function. That is also why this builds on the SDK's low-level
|
|
42
|
+
* `Server` rather than its `McpServer` convenience wrapper — the latter
|
|
43
|
+
* takes zod schemas, which would mean converting a JSON Schema you
|
|
44
|
+
* already have into zod (a new dependency) to convert it straight back.
|
|
45
|
+
*/
|
|
46
|
+
import type { Tool } from '../../core/tools.js';
|
|
47
|
+
import type { McpServeHandle, McpServeOptions } from './types.js';
|
|
48
|
+
/**
|
|
49
|
+
* Serve `tools` over MCP. Resolves once the transport is connected (for
|
|
50
|
+
* `http`, once the socket is listening), so holding the handle means the
|
|
51
|
+
* server is live.
|
|
52
|
+
*
|
|
53
|
+
* @throws at construction when `tools` is empty, when two tools share a
|
|
54
|
+
* name, when a tool declares `checkIn`, or when a tool declares `needs`
|
|
55
|
+
* without `opts.credentials` — see the module header. Also throws when
|
|
56
|
+
* `@modelcontextprotocol/sdk` is not installed.
|
|
57
|
+
*/
|
|
58
|
+
export declare function mcpServe(tools: readonly Tool[], opts?: McpServeOptions): Promise<McpServeHandle>;
|
|
59
|
+
/**
|
|
60
|
+
* Sentinels handed to an injected `_server` in place of the SDK's zod
|
|
61
|
+
* schemas. Exported so a test can tell the two handlers apart.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare const LIST_TOOLS_SENTINEL: Readonly<{
|
|
65
|
+
method: "tools/list";
|
|
66
|
+
}>;
|
|
67
|
+
/** @internal @see LIST_TOOLS_SENTINEL */
|
|
68
|
+
export declare const CALL_TOOL_SENTINEL: Readonly<{
|
|
69
|
+
method: "tools/call";
|
|
70
|
+
}>;
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpServe — expose your agentfootprint tools AS an MCP server.
|
|
3
|
+
*
|
|
4
|
+
* const handle = await mcpServe([lookupTool, refundTool], {
|
|
5
|
+
* name: 'support-desk',
|
|
6
|
+
* version: '1.0.0',
|
|
7
|
+
* });
|
|
8
|
+
*
|
|
9
|
+
* // …later
|
|
10
|
+
* await handle.close();
|
|
11
|
+
*
|
|
12
|
+
* `mcpClient` pulls someone else's tools in. This pushes yours out, so
|
|
13
|
+
* the tool you already wrote, tested and governed can be called by any
|
|
14
|
+
* MCP client — a desktop host, another team's agent, an IDE — without
|
|
15
|
+
* being rewritten against a second tool interface.
|
|
16
|
+
*
|
|
17
|
+
* Pattern: Adapter (GoF), pointed the other way. `mcpClient` translates
|
|
18
|
+
* MCP → `Tool`; this translates `Tool` → MCP. Same SDK, same
|
|
19
|
+
* lazy-require discipline, mirrored lifecycle (`close()`).
|
|
20
|
+
*
|
|
21
|
+
* ── The one promise worth stating plainly ────────────────────────────
|
|
22
|
+
* A served tool is THE SAME OBJECT you passed in. `mcpServe` holds your
|
|
23
|
+
* `Tool` by reference and calls `tool.execute(args, ctx)` — it never
|
|
24
|
+
* copies the schema and re-implements the body, never unwraps a
|
|
25
|
+
* decorator, never reaches past a wrapper to an inner tool. So whatever
|
|
26
|
+
* governance you composed around that tool — a permission check inside
|
|
27
|
+
* `execute`, a redaction step, an audit hook — is still the thing that
|
|
28
|
+
* runs when a remote client calls it. Serving is not a second door into
|
|
29
|
+
* your tool; it is the same door with a longer corridor.
|
|
30
|
+
*
|
|
31
|
+
* Two demands the library CANNOT keep over MCP are refused at
|
|
32
|
+
* construction rather than silently dropped:
|
|
33
|
+
* - `checkIn` (human consent before the tool runs) needs a pause
|
|
34
|
+
* channel that a request/response protocol does not have.
|
|
35
|
+
* - `needs` (declare-and-push credentials) needs a provider; without
|
|
36
|
+
* one the tool would run with `ctx.credential` undefined.
|
|
37
|
+
*
|
|
38
|
+
* ── Schemas ──────────────────────────────────────────────────────────
|
|
39
|
+
* Tools already carry JSON Schema in `schema.inputSchema`, and MCP's
|
|
40
|
+
* `tools/list` wants JSON Schema, so the mapping is the identity
|
|
41
|
+
* function. That is also why this builds on the SDK's low-level
|
|
42
|
+
* `Server` rather than its `McpServer` convenience wrapper — the latter
|
|
43
|
+
* takes zod schemas, which would mean converting a JSON Schema you
|
|
44
|
+
* already have into zod (a new dependency) to convert it straight back.
|
|
45
|
+
*/
|
|
46
|
+
import { unconfiguredCredentialProvider } from '../../identity/types.js';
|
|
47
|
+
import { lazyRequire } from '../lazyRequire.js';
|
|
48
|
+
const DEFAULT_SERVER_NAME = 'agentfootprint';
|
|
49
|
+
const DEFAULT_SERVER_VERSION = '0.0.0';
|
|
50
|
+
const DEFAULT_HTTP_PATH = '/mcp';
|
|
51
|
+
/**
|
|
52
|
+
* Serve `tools` over MCP. Resolves once the transport is connected (for
|
|
53
|
+
* `http`, once the socket is listening), so holding the handle means the
|
|
54
|
+
* server is live.
|
|
55
|
+
*
|
|
56
|
+
* @throws at construction when `tools` is empty, when two tools share a
|
|
57
|
+
* name, when a tool declares `checkIn`, or when a tool declares `needs`
|
|
58
|
+
* without `opts.credentials` — see the module header. Also throws when
|
|
59
|
+
* `@modelcontextprotocol/sdk` is not installed.
|
|
60
|
+
*/
|
|
61
|
+
export async function mcpServe(tools, opts = {}) {
|
|
62
|
+
const name = opts.name ?? DEFAULT_SERVER_NAME;
|
|
63
|
+
const version = opts.version ?? DEFAULT_SERVER_VERSION;
|
|
64
|
+
const byName = validateServableTools(tools, name, opts.credentials);
|
|
65
|
+
const credentials = opts.credentials ?? unconfiguredCredentialProvider();
|
|
66
|
+
const listing = tools.map((t) => ({
|
|
67
|
+
name: t.schema.name,
|
|
68
|
+
...(t.schema.description !== undefined && { description: t.schema.description }),
|
|
69
|
+
inputSchema: t.schema.inputSchema ?? { type: 'object', properties: {} },
|
|
70
|
+
}));
|
|
71
|
+
// Order matters: the server is resolved FIRST so that a missing SDK is
|
|
72
|
+
// reported by the message that tells you how to install it, rather than
|
|
73
|
+
// by the narrower one about a single submodule.
|
|
74
|
+
const rootServer = opts._server ?? (await resolveServer(name, version));
|
|
75
|
+
const { listSchema, callSchema } = await resolveRequestSchemas(opts._server !== undefined);
|
|
76
|
+
let callCounter = 0;
|
|
77
|
+
const handleCall = async (request, extra) => {
|
|
78
|
+
// Everything below this line is inside one try/catch on purpose. A
|
|
79
|
+
// client we do not control chose this request; a bad choice is a tool
|
|
80
|
+
// error reported back over the protocol, never an exception that
|
|
81
|
+
// escapes the SDK's dispatch loop and takes the server down with it.
|
|
82
|
+
try {
|
|
83
|
+
const toolName = request?.params?.name;
|
|
84
|
+
const tool = typeof toolName === 'string' ? byName.get(toolName) : undefined;
|
|
85
|
+
if (!tool) {
|
|
86
|
+
return toolError(`Unknown tool '${String(toolName)}'. Served tools: ${listing
|
|
87
|
+
.map((t) => t.name)
|
|
88
|
+
.join(', ')}.`);
|
|
89
|
+
}
|
|
90
|
+
const ctx = await buildExecutionContext(tool, `mcp-${name}-${++callCounter}`, {
|
|
91
|
+
credentials,
|
|
92
|
+
hasCredentials: opts.credentials !== undefined,
|
|
93
|
+
...(extra?.signal && { signal: extra.signal }),
|
|
94
|
+
});
|
|
95
|
+
if ('blocked' in ctx)
|
|
96
|
+
return toolError(ctx.blocked);
|
|
97
|
+
// Args are forwarded EXACTLY as the client sent them. Validating
|
|
98
|
+
// them here would mean a second, weaker copy of the tool's own
|
|
99
|
+
// contract — and a tool that already rejects bad input is the one
|
|
100
|
+
// place that rejection belongs.
|
|
101
|
+
const result = await tool.execute(request?.params?.arguments, ctx.context);
|
|
102
|
+
return { content: [{ type: 'text', text: stringifyResult(result) }] };
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return toolError(error instanceof Error ? error.message : String(error));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Put our two handlers on one SDK server. Factored out of the body
|
|
110
|
+
* because the streamable-HTTP path cannot reuse a single server: the
|
|
111
|
+
* SDK's stateless transport refuses a second request ("Stateless
|
|
112
|
+
* transport cannot be reused across requests"), so that path builds a
|
|
113
|
+
* fresh server + transport per request and needs to install the same
|
|
114
|
+
* two handlers on each one. `listing` and `byName` are captured, so
|
|
115
|
+
* every server instance serves the same tools — the same objects.
|
|
116
|
+
*/
|
|
117
|
+
const install = (server) => {
|
|
118
|
+
server.setRequestHandler(listSchema, () => ({ tools: listing }));
|
|
119
|
+
server.setRequestHandler(callSchema, handleCall);
|
|
120
|
+
return server;
|
|
121
|
+
};
|
|
122
|
+
const sdk = install(rootServer);
|
|
123
|
+
const connection = await connectTransport(sdk, opts.transport ?? { transport: 'stdio' }, opts, async () => install(await resolveServer(name, version)));
|
|
124
|
+
let closed = false;
|
|
125
|
+
return {
|
|
126
|
+
name,
|
|
127
|
+
toolNames: listing.map((t) => t.name),
|
|
128
|
+
async close() {
|
|
129
|
+
if (closed)
|
|
130
|
+
return;
|
|
131
|
+
closed = true;
|
|
132
|
+
await connection.close();
|
|
133
|
+
await sdk.close();
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// ─── Construction-time refusals ────────────────────────────────────
|
|
138
|
+
/**
|
|
139
|
+
* Build the dispatch map and refuse, by name, every tool this transport
|
|
140
|
+
* cannot honour. All of these are author mistakes, and all of them are
|
|
141
|
+
* invisible at run time if we let them through — a duplicate name means
|
|
142
|
+
* one tool silently shadows another; a dropped `checkIn` means a
|
|
143
|
+
* consent gate that quietly stopped gating.
|
|
144
|
+
*/
|
|
145
|
+
function validateServableTools(tools, serverName, credentials) {
|
|
146
|
+
if (tools.length === 0) {
|
|
147
|
+
throw new Error(`mcpServe('${serverName}'): no tools to serve. Pass at least one Tool — a server ` +
|
|
148
|
+
`advertising an empty tool list is indistinguishable from a broken one.`);
|
|
149
|
+
}
|
|
150
|
+
const byName = new Map();
|
|
151
|
+
for (const tool of tools) {
|
|
152
|
+
const name = tool.schema.name;
|
|
153
|
+
if (byName.has(name)) {
|
|
154
|
+
throw new Error(`mcpServe('${serverName}'): duplicate tool name '${name}'. MCP clients dispatch by ` +
|
|
155
|
+
`name, so one of the two could never be reached.`);
|
|
156
|
+
}
|
|
157
|
+
if (tool.checkIn !== undefined) {
|
|
158
|
+
throw new Error(`mcpServe('${serverName}'): tool '${name}' declares checkIn, which asks a human to ` +
|
|
159
|
+
`approve the call before it runs. MCP is request/response — there is no pause to ` +
|
|
160
|
+
`carry that ask — so serving it would drop the consent gate silently. Serve a ` +
|
|
161
|
+
`variant without checkIn, or keep this tool inside an agent that can pause.`);
|
|
162
|
+
}
|
|
163
|
+
if (tool.needs !== undefined && credentials === undefined) {
|
|
164
|
+
throw new Error(`mcpServe('${serverName}'): tool '${name}' declares needs.credential ` +
|
|
165
|
+
`'${tool.needs.credential}' but no credential provider was passed. Pass ` +
|
|
166
|
+
`mcpServe(tools, { credentials }) so the credential is resolved before execute, ` +
|
|
167
|
+
`the same way the Agent resolves it.`);
|
|
168
|
+
}
|
|
169
|
+
byName.set(name, tool);
|
|
170
|
+
}
|
|
171
|
+
return byName;
|
|
172
|
+
}
|
|
173
|
+
// ─── Per-call execution context ────────────────────────────────────
|
|
174
|
+
/**
|
|
175
|
+
* Assemble the `ToolExecutionContext` for one served call, resolving a
|
|
176
|
+
* declared credential first. Returns `{ blocked }` instead of throwing
|
|
177
|
+
* when the credential is unavailable, so the client is told WHY in a
|
|
178
|
+
* tool-error result rather than seeing a generic failure.
|
|
179
|
+
*/
|
|
180
|
+
async function buildExecutionContext(tool, toolCallId, wiring) {
|
|
181
|
+
const { credentials, hasCredentials, signal } = wiring;
|
|
182
|
+
let credential;
|
|
183
|
+
const need = tool.needs;
|
|
184
|
+
if (need) {
|
|
185
|
+
const resolved = await credentials.getCredential({
|
|
186
|
+
service: need.credential,
|
|
187
|
+
...(need.scopes && { scopes: need.scopes }),
|
|
188
|
+
...(need.mode && { mode: need.mode }),
|
|
189
|
+
});
|
|
190
|
+
// Fail-closed, mirroring the Agent's tool-call stage: a tool that
|
|
191
|
+
// asked for a credential never runs without one.
|
|
192
|
+
if (resolved.status !== 'issued') {
|
|
193
|
+
return {
|
|
194
|
+
blocked: `authorization required for '${need.credential}': ${resolved.authorizationUrl}`,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
credential = resolved.credential;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
context: {
|
|
201
|
+
toolCallId,
|
|
202
|
+
// There is no ReAct loop out here — a served call is a single
|
|
203
|
+
// request, so the iteration a tool might branch on is zero.
|
|
204
|
+
iteration: 0,
|
|
205
|
+
credentials,
|
|
206
|
+
hasCredentials,
|
|
207
|
+
...(signal && { signal }),
|
|
208
|
+
...(credential && { credential }),
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// ─── Result mapping ────────────────────────────────────────────────
|
|
213
|
+
/** MCP carries text blocks; a Tool returns anything JSON-serializable. */
|
|
214
|
+
function stringifyResult(result) {
|
|
215
|
+
if (typeof result === 'string')
|
|
216
|
+
return result;
|
|
217
|
+
if (result === undefined)
|
|
218
|
+
return '';
|
|
219
|
+
try {
|
|
220
|
+
return JSON.stringify(result) ?? String(result);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// Circular or otherwise unserializable — say so rather than throwing
|
|
224
|
+
// from the happy path.
|
|
225
|
+
return String(result);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** A tool-level error: reported IN the result, per the MCP spec, not thrown. */
|
|
229
|
+
function toolError(message) {
|
|
230
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
231
|
+
}
|
|
232
|
+
// ─── SDK construction (lazy require) ───────────────────────────────
|
|
233
|
+
async function resolveServer(name, version) {
|
|
234
|
+
let mod;
|
|
235
|
+
try {
|
|
236
|
+
mod = lazyRequire('@modelcontextprotocol/sdk/server/index.js');
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
throw new Error('mcpServe requires @modelcontextprotocol/sdk.\n' +
|
|
240
|
+
' Install: npm install @modelcontextprotocol/sdk\n' +
|
|
241
|
+
' Or pass `_server` for test injection.');
|
|
242
|
+
}
|
|
243
|
+
return new mod.Server({ name, version }, { capabilities: { tools: {} } });
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The request schemas the SDK dispatches on. With an injected `_server`
|
|
247
|
+
* there is no SDK to read them from, so tests get stable sentinel
|
|
248
|
+
* objects — the injected server decides what to do with them.
|
|
249
|
+
*/
|
|
250
|
+
async function resolveRequestSchemas(injected) {
|
|
251
|
+
if (injected) {
|
|
252
|
+
return { listSchema: LIST_TOOLS_SENTINEL, callSchema: CALL_TOOL_SENTINEL };
|
|
253
|
+
}
|
|
254
|
+
let types;
|
|
255
|
+
try {
|
|
256
|
+
types = lazyRequire('@modelcontextprotocol/sdk/types.js');
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
throw new Error('mcpServe requires @modelcontextprotocol/sdk/types.js — check that ' +
|
|
260
|
+
'@modelcontextprotocol/sdk is installed at the latest version.');
|
|
261
|
+
}
|
|
262
|
+
return { listSchema: types.ListToolsRequestSchema, callSchema: types.CallToolRequestSchema };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Sentinels handed to an injected `_server` in place of the SDK's zod
|
|
266
|
+
* schemas. Exported so a test can tell the two handlers apart.
|
|
267
|
+
* @internal
|
|
268
|
+
*/
|
|
269
|
+
export const LIST_TOOLS_SENTINEL = Object.freeze({ method: 'tools/list' });
|
|
270
|
+
/** @internal @see LIST_TOOLS_SENTINEL */
|
|
271
|
+
export const CALL_TOOL_SENTINEL = Object.freeze({ method: 'tools/call' });
|
|
272
|
+
/**
|
|
273
|
+
* For stdio and for an injected test server there is nothing extra to
|
|
274
|
+
* unwind: the SDK's own `server.close()` closes the transport it is
|
|
275
|
+
* connected to. Only the HTTP path owns a socket of its own.
|
|
276
|
+
*/
|
|
277
|
+
const NOTHING_TO_UNWIND = { close: () => Promise.resolve() };
|
|
278
|
+
async function connectTransport(sdk, transport, opts, newServer) {
|
|
279
|
+
// An injected server is a test double: there is no real transport to
|
|
280
|
+
// build, and building one would spawn a listener or seize stdio.
|
|
281
|
+
if (opts._server) {
|
|
282
|
+
await sdk.connect(undefined);
|
|
283
|
+
return NOTHING_TO_UNWIND;
|
|
284
|
+
}
|
|
285
|
+
if (transport.transport === 'stdio') {
|
|
286
|
+
let stdioMod;
|
|
287
|
+
try {
|
|
288
|
+
stdioMod = lazyRequire('@modelcontextprotocol/sdk/server/stdio.js');
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
throw new Error('mcpServe(stdio) requires @modelcontextprotocol/sdk/server/stdio.js — ' +
|
|
292
|
+
'check that @modelcontextprotocol/sdk is installed at the latest version.');
|
|
293
|
+
}
|
|
294
|
+
await sdk.connect(new stdioMod.StdioServerTransport());
|
|
295
|
+
return NOTHING_TO_UNWIND;
|
|
296
|
+
}
|
|
297
|
+
// HTTP deliberately does not use `sdk`: it mints a server per request
|
|
298
|
+
// (see connectHttp). The root server stays unconnected, which makes the
|
|
299
|
+
// handle's `sdk.close()` a harmless no-op on this path.
|
|
300
|
+
return connectHttp(transport, newServer);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Streamable HTTP. The SDK's transport handles the protocol but does not
|
|
304
|
+
* own a socket — it expects to be driven from a request handler — so the
|
|
305
|
+
* listener is ours, built on node:http (built in; no new dependency).
|
|
306
|
+
*
|
|
307
|
+
* Stateless (`sessionIdGenerator: undefined`): no session table to keep,
|
|
308
|
+
* nothing to expire, and several replicas can serve the same tools.
|
|
309
|
+
*
|
|
310
|
+
* Statelessness is not just a config flag here — it decides the shape of
|
|
311
|
+
* this function. The SDK's stateless transport is single-use by design
|
|
312
|
+
* (reusing one would let two clients collide on JSON-RPC message ids), so
|
|
313
|
+
* it throws on its second request. Each request therefore gets its own
|
|
314
|
+
* transport, and — because one SDK server can only be attached to one
|
|
315
|
+
* transport — its own server. Both are thrown away when the response
|
|
316
|
+
* closes. The tools they serve are the same objects either way.
|
|
317
|
+
*/
|
|
318
|
+
async function connectHttp(transport, newServer) {
|
|
319
|
+
let httpMod;
|
|
320
|
+
try {
|
|
321
|
+
httpMod = lazyRequire('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
throw new Error('mcpServe(http) requires @modelcontextprotocol/sdk/server/streamableHttp.js — ' +
|
|
325
|
+
'check that @modelcontextprotocol/sdk is installed at the latest version.');
|
|
326
|
+
}
|
|
327
|
+
const { createServer } = await import('node:http');
|
|
328
|
+
const serveOne = async (req, res) => {
|
|
329
|
+
const server = await newServer();
|
|
330
|
+
const mcpTransport = new httpMod.StreamableHTTPServerTransport({
|
|
331
|
+
sessionIdGenerator: undefined,
|
|
332
|
+
});
|
|
333
|
+
// The pair lives exactly as long as the response does.
|
|
334
|
+
res.on('close', () => {
|
|
335
|
+
void mcpTransport.close();
|
|
336
|
+
void server.close();
|
|
337
|
+
});
|
|
338
|
+
await server.connect(mcpTransport);
|
|
339
|
+
await mcpTransport.handleRequest(req, res);
|
|
340
|
+
};
|
|
341
|
+
const path = transport.path ?? DEFAULT_HTTP_PATH;
|
|
342
|
+
const listener = createServer((req, res) => {
|
|
343
|
+
// Route on the path only; the transport itself decides which HTTP
|
|
344
|
+
// methods it accepts on the MCP endpoint.
|
|
345
|
+
const url = req.url ?? '';
|
|
346
|
+
if (url.split('?')[0] !== path) {
|
|
347
|
+
res.statusCode = 404;
|
|
348
|
+
res.end();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
// One failed request must not take the listener down. The client is
|
|
352
|
+
// told (500 is a protocol-level error it surfaces); the next request
|
|
353
|
+
// is served normally.
|
|
354
|
+
void serveOne(req, res).catch(() => {
|
|
355
|
+
if (!res.headersSent) {
|
|
356
|
+
res.statusCode = 500;
|
|
357
|
+
res.end();
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
await new Promise((resolve, reject) => {
|
|
362
|
+
listener.once('error', reject);
|
|
363
|
+
if (transport.host !== undefined)
|
|
364
|
+
listener.listen(transport.port, transport.host, resolve);
|
|
365
|
+
else
|
|
366
|
+
listener.listen(transport.port, resolve);
|
|
367
|
+
});
|
|
368
|
+
return {
|
|
369
|
+
close: () => new Promise((resolve, reject) => {
|
|
370
|
+
listener.close((err) => (err ? reject(err) : resolve()));
|
|
371
|
+
}),
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=mcpServe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServe.js","sourceRoot":"","sources":["../../../../src/lib/mcp/mcpServe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAQH,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AASzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAC7C,MAAM,sBAAsB,GAAG,OAAO,CAAC;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