agentfootprint 9.70.0 → 9.71.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/ai-instructions/setup.sh +0 -0
- package/bin/agentfootprint-index.mjs +0 -0
- package/bin/agentfootprint-lint-tools.mjs +0 -0
- package/dist/core/tools.js +71 -29
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/core/tools.d.ts +25 -0
- package/dist/esm/core/tools.js +68 -28
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/lib/mcp/index.d.ts +1 -0
- package/dist/esm/lib/mcp/index.js +3 -0
- package/dist/esm/lib/mcp/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpClient.d.ts +6 -0
- package/dist/esm/lib/mcp/mcpClient.js +14 -0
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.d.ts +8 -0
- package/dist/esm/lib/mcp/mcpServe.js +23 -5
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +26 -0
- package/dist/esm/lib/mcp/mockMcpClient.js +5 -0
- package/dist/esm/lib/mcp/mockMcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/toolExtras.d.ts +129 -0
- package/dist/esm/lib/mcp/toolExtras.js +198 -0
- package/dist/esm/lib/mcp/toolExtras.js.map +1 -0
- package/dist/esm/lib/mcp/types.d.ts +18 -5
- package/dist/esm/tool-providers/index.d.ts +2 -2
- package/dist/esm/tool-providers/index.js +5 -1
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/lib/mcp/index.js +5 -1
- package/dist/lib/mcp/index.js.map +1 -1
- package/dist/lib/mcp/mcpClient.js +14 -0
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +23 -5
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/lib/mcp/mockMcpClient.js +5 -0
- package/dist/lib/mcp/mockMcpClient.js.map +1 -1
- package/dist/lib/mcp/toolExtras.js +204 -0
- package/dist/lib/mcp/toolExtras.js.map +1 -0
- package/dist/tool-providers/index.js +5 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/types/core/tools.d.ts +25 -0
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/lib/mcp/index.d.ts +1 -0
- package/dist/types/lib/mcp/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpClient.d.ts +6 -0
- package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts +8 -0
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/mcp/mockMcpClient.d.ts +26 -0
- package/dist/types/lib/mcp/mockMcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/toolExtras.d.ts +130 -0
- package/dist/types/lib/mcp/toolExtras.d.ts.map +1 -0
- package/dist/types/lib/mcp/types.d.ts +18 -5
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +2 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -40,6 +40,32 @@ export interface MockMcpTool {
|
|
|
40
40
|
* registry verbatim — same as a real MCP server's `listTools()`.
|
|
41
41
|
*/
|
|
42
42
|
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
43
|
+
/**
|
|
44
|
+
* MCP's extensibility bag, exactly as a real server would send it (9.71.0).
|
|
45
|
+
*
|
|
46
|
+
* agentfootprint's tool DECLARATIONS — `argumentsFrom`, `resultKind`,
|
|
47
|
+
* `owner`, `resultClass`, `resultCeiling` — ride under the `agentfootprint`
|
|
48
|
+
* key here, and this mock reads them through the SAME defensive reader
|
|
49
|
+
* `mcpClient` uses. So a rail armed by a remotely-declared tool can be
|
|
50
|
+
* developed and tested before the real server exists, and so can the
|
|
51
|
+
* unhappy path: put a malformed declaration in and watch the field get
|
|
52
|
+
* dropped, the warning name the rule, and the tool register anyway.
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* mockMcpClient({
|
|
56
|
+
* name: 'fleet-mcp',
|
|
57
|
+
* tools: [{
|
|
58
|
+
* name: 'backup_status',
|
|
59
|
+
* inputSchema: { type: 'object', properties: { machine: { type: 'string' } } },
|
|
60
|
+
* _meta: { agentfootprint: { argumentsFrom: ['fleet_report'] } },
|
|
61
|
+
* }],
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Omitted → the registered `Tool` carries no declarations, exactly as
|
|
66
|
+
* before this existed.
|
|
67
|
+
*/
|
|
68
|
+
readonly _meta?: Readonly<Record<string, unknown>>;
|
|
43
69
|
/**
|
|
44
70
|
* Async handler that runs when the agent calls this tool. Receives
|
|
45
71
|
* the args the LLM produced; returns the string result the agent
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* — stable, documented, and the right level of abstraction for
|
|
29
29
|
* mock-first development.
|
|
30
30
|
*/
|
|
31
|
+
import { readToolExtras } from './toolExtras.js';
|
|
31
32
|
/**
|
|
32
33
|
* Build an in-memory `McpClient`. Useful when you want to develop
|
|
33
34
|
* against MCP semantics without spawning subprocesses, hitting the
|
|
@@ -77,6 +78,10 @@ function wrapMockTool(serverName, toolMap, mcp) {
|
|
|
77
78
|
// governs by server name has to be testable against the mock, or the swap
|
|
78
79
|
// from mock to real server changes what the policy sees.
|
|
79
80
|
source: serverName,
|
|
81
|
+
// …and the same declarations, through the same reader (9.71.0). A rail
|
|
82
|
+
// that arms on a remotely-declared `argumentsFrom` must arm here too, or
|
|
83
|
+
// the mock proves nothing about the server it stands in for.
|
|
84
|
+
...readToolExtras(mcp._meta, { server: serverName, tool: mcp.name }),
|
|
80
85
|
execute: async (args) => {
|
|
81
86
|
const argsObj = args !== null && typeof args === 'object' && !Array.isArray(args)
|
|
82
87
|
? args
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockMcpClient.js","sourceRoot":"","sources":["../../../../src/lib/mcp/mockMcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"mockMcpClient.js","sourceRoot":"","sources":["../../../../src/lib/mcp/mockMcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA0DjD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAsB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpF,IAAI,KAAK,GAA2B,IAAI,CAAC;IACzC,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,MAAM,UAAU,GAAG,CAAC,EAAU,EAAQ,EAAE;QACtC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,KAAK,EAAE,2DAA2D,CACxF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,GAAoB,EAAE,CACvC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,KAAK;YACT,UAAU,CAAC,OAAO,CAAC,CAAC;YACpB,IAAI,CAAC,KAAK;gBAAE,KAAK,GAAG,UAAU,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,CAAC,OAAO;YACX,UAAU,CAAC,SA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E,CAAC;gBACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC7D,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,IAAI,cAAc,UAAU,aAAa,GAAG,EAAE,CAAC,CAAC;YACxF,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolExtras — agentfootprint's own tool DECLARATIONS, carried over MCP.
|
|
3
|
+
*
|
|
4
|
+
* A `Tool` is two different things at once. Half of it is EXECUTION — the
|
|
5
|
+
* handler, the credential it needs, the human it wants to check in with. The
|
|
6
|
+
* other half is DECLARATION — flat, inert facts about the tool that no code
|
|
7
|
+
* runs and every consumer-side rail READS: where its arguments come from, what
|
|
8
|
+
* kind of artifact its result is, who owns it, what class of answer it gives,
|
|
9
|
+
* how big a result is too big.
|
|
10
|
+
*
|
|
11
|
+
* Over MCP only the execution half used to cross. A tool served by `mcpServe`
|
|
12
|
+
* arrived at a client as a name, a description and an input schema, so every
|
|
13
|
+
* rail that reads a declaration went quiet for it: the dangling-reference and
|
|
14
|
+
* unsupported-argument checks never armed, placement minted
|
|
15
|
+
* `tool-result/<name>` that no `wants` could spend, and the identity joins had
|
|
16
|
+
* no subject. An MCP server could be somebody's whole tool catalogue and still
|
|
17
|
+
* be a second-class citizen of every check this library ships.
|
|
18
|
+
*
|
|
19
|
+
* ── The carrier ─────────────────────────────────────────────────────────
|
|
20
|
+
* MCP's own extensibility bag: `Tool._meta`, under ONE namespaced key
|
|
21
|
+
* ({@link MCP_TOOL_EXTRAS_KEY}). `_meta` is declared on the spec's `Tool`
|
|
22
|
+
* object (`@modelcontextprotocol/sdk` types it as
|
|
23
|
+
* `z.record(z.string(), z.unknown()).optional()` on `ToolSchema`), so it
|
|
24
|
+
* survives the SDK's own `tools/list` validation in both directions and needs
|
|
25
|
+
* no new protocol, no side channel and no version negotiation. A server that
|
|
26
|
+
* has never heard of agentfootprint sends no bag; a client that has never
|
|
27
|
+
* heard of it ignores the key.
|
|
28
|
+
*
|
|
29
|
+
* ── What may travel, and the bar ────────────────────────────────────────
|
|
30
|
+
* **A declaration a consumer-side check or rail reads; nothing that governs
|
|
31
|
+
* execution.** The five fields below pass it. `needs` (credentials), `checkIn`
|
|
32
|
+
* (human consent) and the session hooks do NOT and never will: they govern how
|
|
33
|
+
* a tool RUNS, and the tool runs on the server. Sending them would tell a
|
|
34
|
+
* client to hold a gate that the only executor of the tool has already held,
|
|
35
|
+
* or — worse — that nobody is holding at all. `mcpServe` already refuses to
|
|
36
|
+
* serve a `checkIn` tool for exactly that reason; this list is the same law,
|
|
37
|
+
* stated on the way out.
|
|
38
|
+
*
|
|
39
|
+
* ── The asymmetry that matters ──────────────────────────────────────────
|
|
40
|
+
* SERVING validates nothing new: the tool was built by `defineTool`, which
|
|
41
|
+
* already refused every malformed declaration at definition time.
|
|
42
|
+
*
|
|
43
|
+
* INGEST validates everything and THROWS NOTHING. A bag comes from a server
|
|
44
|
+
* this process does not control, and one server's typo must not take down a
|
|
45
|
+
* bulk register of forty tools. So each field is judged by the SAME rule
|
|
46
|
+
* `defineTool` enforces (literally the same exported assert), and a field that
|
|
47
|
+
* fails is warned about once — naming the server, the tool, the field and the
|
|
48
|
+
* rule — and DROPPED. The tool still registers, without that one declaration.
|
|
49
|
+
* That is the honest outcome: the rail it would have armed stays unarmed, and
|
|
50
|
+
* the developer is told which rail and why.
|
|
51
|
+
*/
|
|
52
|
+
import { type Tool, type ToolOwner, type ToolResultCeiling } from '../../core/tools.js';
|
|
53
|
+
import type { ToolResultClass } from '../semantics/types.js';
|
|
54
|
+
/**
|
|
55
|
+
* The single `_meta` key every agentfootprint declaration travels under.
|
|
56
|
+
*
|
|
57
|
+
* Namespaced so it can never collide with another vendor's `_meta` entry, and
|
|
58
|
+
* a CONSTANT so there is exactly one spelling in the codebase — the
|
|
59
|
+
* `branchSegment.ts` precedent upstream: one owner of the grammar, and nobody
|
|
60
|
+
* else may write the string.
|
|
61
|
+
*/
|
|
62
|
+
export declare const MCP_TOOL_EXTRAS_KEY = "agentfootprint";
|
|
63
|
+
/**
|
|
64
|
+
* The declarations that cross an MCP boundary — the plain-data half of a
|
|
65
|
+
* `Tool`, in the shape the receiving side puts straight back onto a `Tool`.
|
|
66
|
+
*
|
|
67
|
+
* Every field is optional and ABSENT MEANS ABSENT: a tool that declares
|
|
68
|
+
* nothing sends no bag at all, and a tool that declares two sends two keys,
|
|
69
|
+
* never five with three empty placeholders. "Said nothing" and "said empty"
|
|
70
|
+
* are different statements everywhere else in this library, and they are
|
|
71
|
+
* different here.
|
|
72
|
+
*
|
|
73
|
+
* @see MCP_TOOL_EXTRAS_KEY for the `_meta` key it rides under.
|
|
74
|
+
*/
|
|
75
|
+
export interface McpToolExtras {
|
|
76
|
+
/** Where this tool's arguments come from — see {@link Tool.argumentsFrom}.
|
|
77
|
+
* Arms the dangling-reference and unsupported-argument checks. */
|
|
78
|
+
readonly argumentsFrom?: readonly string[];
|
|
79
|
+
/** The artifact kind a PLACED result is minted under — see
|
|
80
|
+
* {@link Tool.resultKind}. What makes a placed result spendable by `wants`. */
|
|
81
|
+
readonly resultKind?: string;
|
|
82
|
+
/** The identity edge integrity checks join on — see {@link Tool.owner}. */
|
|
83
|
+
readonly owner?: ToolOwner;
|
|
84
|
+
/** The declared class of this tool's results — see {@link Tool.resultClass}. */
|
|
85
|
+
readonly resultClass?: ToolResultClass;
|
|
86
|
+
/** The author's refusing ceiling on this tool's result — see
|
|
87
|
+
* {@link Tool.resultCeiling}. */
|
|
88
|
+
readonly resultCeiling?: ToolResultCeiling;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The declarations on `tool`, ready to be written into an MCP `_meta` bag —
|
|
92
|
+
* or `undefined` when the tool declares none, so `mcpServe` can leave `_meta`
|
|
93
|
+
* off the listing entirely rather than sending an empty object.
|
|
94
|
+
*
|
|
95
|
+
* Copied verbatim, never inferred or defaulted. This is the SERVE side, and
|
|
96
|
+
* the values were already vetted by `defineTool`.
|
|
97
|
+
*/
|
|
98
|
+
export declare function toolExtrasOf(tool: Tool): McpToolExtras | undefined;
|
|
99
|
+
/** Where a rejected declaration came from, for the warning that names it. */
|
|
100
|
+
export interface McpToolExtrasOrigin {
|
|
101
|
+
/** The client's logical name — `mcpClient({ name })`. */
|
|
102
|
+
readonly server: string;
|
|
103
|
+
/** The tool the bag was attached to. */
|
|
104
|
+
readonly tool: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Read an MCP `Tool._meta` bag into declarations a `Tool` can carry.
|
|
108
|
+
*
|
|
109
|
+
* **Never throws.** Everything here is somebody else's data:
|
|
110
|
+
*
|
|
111
|
+
* - no `_meta`, no `agentfootprint` key, or a non-object under it → `{}`,
|
|
112
|
+
* and the ingest is byte-identical to every release before this existed;
|
|
113
|
+
* - a field the receiving side does not know → ignored in silence (a NEWER
|
|
114
|
+
* server talking to an OLDER client is not an error, and warning about it
|
|
115
|
+
* would make every upgrade noisy at the wrong end);
|
|
116
|
+
* - a field this library DOES know but cannot honour → warned once and
|
|
117
|
+
* dropped, and the rest of the bag still lands.
|
|
118
|
+
*
|
|
119
|
+
* The rule each field is judged by is the exported assert `defineTool` itself
|
|
120
|
+
* calls, so a declaration that would have been refused at definition time is
|
|
121
|
+
* refused here too, with the same sentence.
|
|
122
|
+
*/
|
|
123
|
+
export declare function readToolExtras(meta: unknown, origin: McpToolExtrasOrigin): McpToolExtras;
|
|
124
|
+
/**
|
|
125
|
+
* Forget every warning issued so far.
|
|
126
|
+
* @internal test seam — the ledger is process-wide and warn-ONCE, so a test
|
|
127
|
+
* proving the warning fires must be able to start from silence.
|
|
128
|
+
*/
|
|
129
|
+
export declare function _resetToolExtrasWarnings(): void;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolExtras — agentfootprint's own tool DECLARATIONS, carried over MCP.
|
|
3
|
+
*
|
|
4
|
+
* A `Tool` is two different things at once. Half of it is EXECUTION — the
|
|
5
|
+
* handler, the credential it needs, the human it wants to check in with. The
|
|
6
|
+
* other half is DECLARATION — flat, inert facts about the tool that no code
|
|
7
|
+
* runs and every consumer-side rail READS: where its arguments come from, what
|
|
8
|
+
* kind of artifact its result is, who owns it, what class of answer it gives,
|
|
9
|
+
* how big a result is too big.
|
|
10
|
+
*
|
|
11
|
+
* Over MCP only the execution half used to cross. A tool served by `mcpServe`
|
|
12
|
+
* arrived at a client as a name, a description and an input schema, so every
|
|
13
|
+
* rail that reads a declaration went quiet for it: the dangling-reference and
|
|
14
|
+
* unsupported-argument checks never armed, placement minted
|
|
15
|
+
* `tool-result/<name>` that no `wants` could spend, and the identity joins had
|
|
16
|
+
* no subject. An MCP server could be somebody's whole tool catalogue and still
|
|
17
|
+
* be a second-class citizen of every check this library ships.
|
|
18
|
+
*
|
|
19
|
+
* ── The carrier ─────────────────────────────────────────────────────────
|
|
20
|
+
* MCP's own extensibility bag: `Tool._meta`, under ONE namespaced key
|
|
21
|
+
* ({@link MCP_TOOL_EXTRAS_KEY}). `_meta` is declared on the spec's `Tool`
|
|
22
|
+
* object (`@modelcontextprotocol/sdk` types it as
|
|
23
|
+
* `z.record(z.string(), z.unknown()).optional()` on `ToolSchema`), so it
|
|
24
|
+
* survives the SDK's own `tools/list` validation in both directions and needs
|
|
25
|
+
* no new protocol, no side channel and no version negotiation. A server that
|
|
26
|
+
* has never heard of agentfootprint sends no bag; a client that has never
|
|
27
|
+
* heard of it ignores the key.
|
|
28
|
+
*
|
|
29
|
+
* ── What may travel, and the bar ────────────────────────────────────────
|
|
30
|
+
* **A declaration a consumer-side check or rail reads; nothing that governs
|
|
31
|
+
* execution.** The five fields below pass it. `needs` (credentials), `checkIn`
|
|
32
|
+
* (human consent) and the session hooks do NOT and never will: they govern how
|
|
33
|
+
* a tool RUNS, and the tool runs on the server. Sending them would tell a
|
|
34
|
+
* client to hold a gate that the only executor of the tool has already held,
|
|
35
|
+
* or — worse — that nobody is holding at all. `mcpServe` already refuses to
|
|
36
|
+
* serve a `checkIn` tool for exactly that reason; this list is the same law,
|
|
37
|
+
* stated on the way out.
|
|
38
|
+
*
|
|
39
|
+
* ── The asymmetry that matters ──────────────────────────────────────────
|
|
40
|
+
* SERVING validates nothing new: the tool was built by `defineTool`, which
|
|
41
|
+
* already refused every malformed declaration at definition time.
|
|
42
|
+
*
|
|
43
|
+
* INGEST validates everything and THROWS NOTHING. A bag comes from a server
|
|
44
|
+
* this process does not control, and one server's typo must not take down a
|
|
45
|
+
* bulk register of forty tools. So each field is judged by the SAME rule
|
|
46
|
+
* `defineTool` enforces (literally the same exported assert), and a field that
|
|
47
|
+
* fails is warned about once — naming the server, the tool, the field and the
|
|
48
|
+
* rule — and DROPPED. The tool still registers, without that one declaration.
|
|
49
|
+
* That is the honest outcome: the rail it would have armed stays unarmed, and
|
|
50
|
+
* the developer is told which rail and why.
|
|
51
|
+
*/
|
|
52
|
+
import { assertArgumentsFrom, assertResultCeiling, assertResultClass, assertResultKind, assertToolOwner, } from '../../core/tools.js';
|
|
53
|
+
/**
|
|
54
|
+
* The single `_meta` key every agentfootprint declaration travels under.
|
|
55
|
+
*
|
|
56
|
+
* Namespaced so it can never collide with another vendor's `_meta` entry, and
|
|
57
|
+
* a CONSTANT so there is exactly one spelling in the codebase — the
|
|
58
|
+
* `branchSegment.ts` precedent upstream: one owner of the grammar, and nobody
|
|
59
|
+
* else may write the string.
|
|
60
|
+
*/
|
|
61
|
+
export const MCP_TOOL_EXTRAS_KEY = 'agentfootprint';
|
|
62
|
+
/**
|
|
63
|
+
* The declarations on `tool`, ready to be written into an MCP `_meta` bag —
|
|
64
|
+
* or `undefined` when the tool declares none, so `mcpServe` can leave `_meta`
|
|
65
|
+
* off the listing entirely rather than sending an empty object.
|
|
66
|
+
*
|
|
67
|
+
* Copied verbatim, never inferred or defaulted. This is the SERVE side, and
|
|
68
|
+
* the values were already vetted by `defineTool`.
|
|
69
|
+
*/
|
|
70
|
+
export function toolExtrasOf(tool) {
|
|
71
|
+
const extras = {
|
|
72
|
+
...(tool.argumentsFrom !== undefined && { argumentsFrom: tool.argumentsFrom }),
|
|
73
|
+
...(tool.resultKind !== undefined && { resultKind: tool.resultKind }),
|
|
74
|
+
...(tool.owner !== undefined && { owner: tool.owner }),
|
|
75
|
+
...(tool.resultClass !== undefined && { resultClass: tool.resultClass }),
|
|
76
|
+
...(tool.resultCeiling !== undefined && { resultCeiling: tool.resultCeiling }),
|
|
77
|
+
};
|
|
78
|
+
return Object.keys(extras).length > 0 ? extras : undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Read an MCP `Tool._meta` bag into declarations a `Tool` can carry.
|
|
82
|
+
*
|
|
83
|
+
* **Never throws.** Everything here is somebody else's data:
|
|
84
|
+
*
|
|
85
|
+
* - no `_meta`, no `agentfootprint` key, or a non-object under it → `{}`,
|
|
86
|
+
* and the ingest is byte-identical to every release before this existed;
|
|
87
|
+
* - a field the receiving side does not know → ignored in silence (a NEWER
|
|
88
|
+
* server talking to an OLDER client is not an error, and warning about it
|
|
89
|
+
* would make every upgrade noisy at the wrong end);
|
|
90
|
+
* - a field this library DOES know but cannot honour → warned once and
|
|
91
|
+
* dropped, and the rest of the bag still lands.
|
|
92
|
+
*
|
|
93
|
+
* The rule each field is judged by is the exported assert `defineTool` itself
|
|
94
|
+
* calls, so a declaration that would have been refused at definition time is
|
|
95
|
+
* refused here too, with the same sentence.
|
|
96
|
+
*/
|
|
97
|
+
export function readToolExtras(meta, origin) {
|
|
98
|
+
const bag = bagOf(meta);
|
|
99
|
+
if (bag === undefined)
|
|
100
|
+
return {};
|
|
101
|
+
const kept = (field, assert) => keepField(bag, field, origin, assert);
|
|
102
|
+
// One line per field, in the declaration order of `McpToolExtras` — a reader
|
|
103
|
+
// comparing the two lists should not have to sort. The casts inside each
|
|
104
|
+
// rule are the point of the exercise: the value is untyped until its own
|
|
105
|
+
// rule has agreed it is the shape the field claims.
|
|
106
|
+
const argumentsFrom = kept('argumentsFrom', (v) => assertArgumentsFrom(origin.tool, v));
|
|
107
|
+
const resultKind = kept('resultKind', (v) => assertResultKind(origin.tool, v));
|
|
108
|
+
const owner = kept('owner', (v) => assertToolOwner(origin.tool, v));
|
|
109
|
+
const resultClass = kept('resultClass', (v) => assertResultClass(origin.tool, v));
|
|
110
|
+
const resultCeiling = kept('resultCeiling', (v) => assertResultCeiling(origin.tool, v));
|
|
111
|
+
return {
|
|
112
|
+
...(argumentsFrom !== undefined && { argumentsFrom }),
|
|
113
|
+
...(resultKind !== undefined && { resultKind }),
|
|
114
|
+
...(owner !== undefined && { owner }),
|
|
115
|
+
...(resultClass !== undefined && { resultClass }),
|
|
116
|
+
...(resultCeiling !== undefined && { resultCeiling }),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// ─── The reading, field by field ───────────────────────────────────
|
|
120
|
+
/** The bag under our key, or `undefined` when there is nothing to read. */
|
|
121
|
+
function bagOf(meta) {
|
|
122
|
+
if (typeof meta !== 'object' || meta === null)
|
|
123
|
+
return undefined;
|
|
124
|
+
const bag = meta[MCP_TOOL_EXTRAS_KEY];
|
|
125
|
+
if (typeof bag !== 'object' || bag === null || Array.isArray(bag))
|
|
126
|
+
return undefined;
|
|
127
|
+
return bag;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Judge ONE field and answer with the value to keep, or `undefined` to drop.
|
|
131
|
+
*
|
|
132
|
+
* The rule is passed IN rather than looked up here, so this function owns the
|
|
133
|
+
* never-throw discipline and nothing else: every rule lives in `core/tools.ts`
|
|
134
|
+
* where `defineTool` reads it, and there is no second copy of any of them in
|
|
135
|
+
* this file.
|
|
136
|
+
*/
|
|
137
|
+
function keepField(bag, field, origin, assert) {
|
|
138
|
+
// `in` rather than a truthiness test: a server that sent the key holding a
|
|
139
|
+
// `null` said something wrong and should hear about it, while a server that
|
|
140
|
+
// never sent the key said nothing and should not.
|
|
141
|
+
if (!(field in bag))
|
|
142
|
+
return undefined;
|
|
143
|
+
const value = bag[field];
|
|
144
|
+
if (value === undefined)
|
|
145
|
+
return undefined;
|
|
146
|
+
try {
|
|
147
|
+
assert(value);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
warnOnce(origin, field, error instanceof Error ? error.message : String(error));
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
// ─── The warning ───────────────────────────────────────────────────
|
|
156
|
+
/**
|
|
157
|
+
* Warn-once ledger, keyed by server + tool + field.
|
|
158
|
+
*
|
|
159
|
+
* ONCE because `.refresh()` re-lists the whole catalogue and an agent that
|
|
160
|
+
* refreshes every minute would otherwise print the same complaint every
|
|
161
|
+
* minute. Bounded because the key contains a remote server's tool names, and
|
|
162
|
+
* an unbounded Set fed by a remote party is a memory leak with a hostname
|
|
163
|
+
* attached — past the cap the warning simply repeats, which is the harmless
|
|
164
|
+
* failure mode.
|
|
165
|
+
*/
|
|
166
|
+
const warned = new Set();
|
|
167
|
+
const MAX_WARNED = 500;
|
|
168
|
+
/**
|
|
169
|
+
* NOT gated on `isDevMode()`, unlike the tool-NAME warning next door.
|
|
170
|
+
*
|
|
171
|
+
* A dropped declaration is not a style note: it is a check that will not arm,
|
|
172
|
+
* a placed result that will not be spendable, an identity join with no
|
|
173
|
+
* subject — and the symptom is silence, which looks exactly like a rail that
|
|
174
|
+
* ran and agreed. The precedent is `toolArgsValidation`'s uncompilable
|
|
175
|
+
* `pattern`: an ingested declaration this library cannot honour is reported
|
|
176
|
+
* unconditionally, once, and then ignored.
|
|
177
|
+
*/
|
|
178
|
+
function warnOnce(origin, field, rule) {
|
|
179
|
+
const key = `${origin.server}${origin.tool}${field}`;
|
|
180
|
+
if (warned.has(key))
|
|
181
|
+
return;
|
|
182
|
+
if (warned.size < MAX_WARNED)
|
|
183
|
+
warned.add(key);
|
|
184
|
+
// eslint-disable-next-line no-console
|
|
185
|
+
console.warn(`[agentfootprint] MCP server '${origin.server}' declared \`${field}\` on tool ` +
|
|
186
|
+
`'${origin.tool}' in its _meta.${MCP_TOOL_EXTRAS_KEY} bag, and this library cannot ` +
|
|
187
|
+
`honour it — the field was DROPPED and the tool registered without it, so whatever ` +
|
|
188
|
+
`that declaration would have armed stays unarmed. The rule it broke: ${rule}`);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Forget every warning issued so far.
|
|
192
|
+
* @internal test seam — the ledger is process-wide and warn-ONCE, so a test
|
|
193
|
+
* proving the warning fires must be able to start from silence.
|
|
194
|
+
*/
|
|
195
|
+
export function _resetToolExtrasWarnings() {
|
|
196
|
+
warned.clear();
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=toolExtras.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolExtras.js","sourceRoot":"","sources":["../../../../src/lib/mcp/toolExtras.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAIhB,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AA8BpD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,MAAM,MAAM,GAAkB;QAC5B,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9E,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QACrE,GAAG,CAAC,IAAI,CAAC,KAA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|
254
254
|
connect(transport: unknown, options?: McpRequestOptions): Promise<void>;
|
|
255
255
|
listTools(params?: undefined, options?: McpRequestOptions): Promise<{
|
|
256
|
-
readonly tools: ReadonlyArray<
|
|
257
|
-
readonly name: string;
|
|
258
|
-
readonly description?: string;
|
|
259
|
-
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
260
|
-
}>;
|
|
256
|
+
readonly tools: ReadonlyArray<McpListedTool>;
|
|
261
257
|
}>;
|
|
262
258
|
callTool(params: {
|
|
263
259
|
readonly name: string;
|
|
@@ -267,6 +263,23 @@ export interface McpSdkClient {
|
|
|
267
263
|
resultSchema?: undefined, options?: McpRequestOptions): Promise<McpCallToolResult>;
|
|
268
264
|
close(): Promise<void>;
|
|
269
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* One entry of a `tools/list` answer, narrowed to what this client reads.
|
|
268
|
+
*
|
|
269
|
+
* `_meta` is the spec's own extensibility bag on a `Tool` object, and it is in
|
|
270
|
+
* this shim because agentfootprint's tool DECLARATIONS ride in it under one
|
|
271
|
+
* namespaced key (see `toolExtras.ts`). It is typed as a loose record on
|
|
272
|
+
* purpose: everything in it is written by a server this process does not
|
|
273
|
+
* control, so the shim promises only that it is an object, and
|
|
274
|
+
* `readToolExtras` does the judging.
|
|
275
|
+
*/
|
|
276
|
+
export interface McpListedTool {
|
|
277
|
+
readonly name: string;
|
|
278
|
+
readonly description?: string;
|
|
279
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
280
|
+
/** MCP's extensibility bag. Absent from most servers' tools. */
|
|
281
|
+
readonly _meta?: Readonly<Record<string, unknown>>;
|
|
282
|
+
}
|
|
270
283
|
/**
|
|
271
284
|
* What `tools/call` can answer with — **a union, because the protocol is one.**
|
|
272
285
|
*
|
|
@@ -51,7 +51,7 @@ export { staticTools } from './staticTools.js';
|
|
|
51
51
|
export { gatedTools } from './gatedTools.js';
|
|
52
52
|
export { skillScopedTools, skillScopedToolsTarget, SKILL_SCOPED_TOOLS_ID_PREFIX, } from './skillScopedTools.js';
|
|
53
53
|
export type { ToolProvider, ToolDispatchContext, ToolGatePredicate } from './types.js';
|
|
54
|
-
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError, } from '../lib/mcp/index.js';
|
|
54
|
+
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError, MCP_TOOL_EXTRAS_KEY, } from '../lib/mcp/index.js';
|
|
55
55
|
export { agentCoreGatewayTransport, agentCoreGatewayUrl, gatewaySearchTool, hasGatewaySearch, AGENTCORE_GATEWAY_SEARCH_TOOL, AGENTCORE_POLICY_SESSION_HEADER, AGENTCORE_SIGV4_SERVICE, } from '../adapters/mcp/agentcore.js';
|
|
56
56
|
export type { AgentCoreGatewayTransportOptions, AgentCoreGatewayUrlOptions, } from '../adapters/mcp/agentcore.js';
|
|
57
|
-
export type { GatewayTransportOptions, McpCallToolResult, McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, McpGatewayTransport, MockMcpClientOptions, MockMcpTool, McpServeOptions, McpServeHandle, McpServeTransport, McpStdioServeTransport, McpHttpServeTransport, McpSdkServer, } from '../lib/mcp/index.js';
|
|
57
|
+
export type { GatewayTransportOptions, McpCallToolResult, McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, McpGatewayTransport, MockMcpClientOptions, MockMcpTool, McpServeOptions, McpServeHandle, McpServeTransport, McpStdioServeTransport, McpHttpServeTransport, McpSdkServer, McpToolExtras, } from '../lib/mcp/index.js';
|
|
@@ -56,7 +56,11 @@ skillScopedToolsTarget, SKILL_SCOPED_TOOLS_ID_PREFIX, } from './skillScopedTools
|
|
|
56
56
|
// Re-export tool sources from the MCP module so consumers find them in
|
|
57
57
|
// one place. This subpath is the ONLY place `mcpClient` is public — the
|
|
58
58
|
// top-level barrel does not re-export it.
|
|
59
|
-
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError,
|
|
59
|
+
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError,
|
|
60
|
+
// The `_meta` key agentfootprint's tool declarations travel under, in both
|
|
61
|
+
// directions (9.71.0). Public so a server this library did not write can
|
|
62
|
+
// speak it, and so a client can read a bag it received.
|
|
63
|
+
MCP_TOOL_EXTRAS_KEY, } from '../lib/mcp/index.js';
|
|
60
64
|
// Reaching an AWS Bedrock AgentCore Gateway (9.66.0). A configuration of
|
|
61
65
|
// `gatewayTransport` plus the four facts that are AgentCore's alone — kept in
|
|
62
66
|
// the vendor's own file so the transport above stays able to say, truthfully,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,gBAAgB;AAChB,kFAAkF;AAClF,kFAAkF;AAClF,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAG/B,uEAAuE;AACvE,wEAAwE;AACxE,0CAA0C;AAC1C,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,iCAAiC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,gBAAgB;AAChB,kFAAkF;AAClF,kFAAkF;AAClF,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAG/B,uEAAuE;AACvE,wEAAwE;AACxE,0CAA0C;AAC1C,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,iCAAiC;AACjC,2EAA2E;AAC3E,yEAAyE;AACzE,wDAAwD;AACxD,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,yEAAyE;AACzE,8EAA8E;AAC9E,8EAA8E;AAC9E,yCAAyC;AACzC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,8BAA8B,CAAC"}
|
package/dist/lib/mcp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GatewayAuthorizationRequiredError = exports.gatewayTransport = exports.mockMcpClient = exports.mcpServe = exports.mcpClient = void 0;
|
|
3
|
+
exports.GatewayAuthorizationRequiredError = exports.gatewayTransport = exports.mockMcpClient = exports.MCP_TOOL_EXTRAS_KEY = exports.mcpServe = exports.mcpClient = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* MCP — Model Context Protocol, both directions. `mcpClient` connects to
|
|
6
6
|
* someone else's MCP server and registers its tools on your Agent;
|
|
@@ -11,6 +11,10 @@ var mcpClient_js_1 = require("./mcpClient.js");
|
|
|
11
11
|
Object.defineProperty(exports, "mcpClient", { enumerable: true, get: function () { return mcpClient_js_1.mcpClient; } });
|
|
12
12
|
var mcpServe_js_1 = require("./mcpServe.js");
|
|
13
13
|
Object.defineProperty(exports, "mcpServe", { enumerable: true, get: function () { return mcpServe_js_1.mcpServe; } });
|
|
14
|
+
// The declaration bag both directions speak (9.71.0) — one namespaced `_meta`
|
|
15
|
+
// key, and the shape a non-agentfootprint server writes to be understood.
|
|
16
|
+
var toolExtras_js_1 = require("./toolExtras.js");
|
|
17
|
+
Object.defineProperty(exports, "MCP_TOOL_EXTRAS_KEY", { enumerable: true, get: function () { return toolExtras_js_1.MCP_TOOL_EXTRAS_KEY; } });
|
|
14
18
|
var mockMcpClient_js_1 = require("./mockMcpClient.js");
|
|
15
19
|
Object.defineProperty(exports, "mockMcpClient", { enumerable: true, get: function () { return mockMcpClient_js_1.mockMcpClient; } });
|
|
16
20
|
var gatewayTransport_js_1 = require("./gatewayTransport.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,uDAAgG;AAAvF,iHAAA,aAAa,OAAA;AACtB,6DAI+B;AAH7B,uHAAA,gBAAgB,OAAA;AAChB,wIAAA,iCAAiC,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,8EAA8E;AAC9E,0EAA0E;AAC1E,iDAA0E;AAAjE,oHAAA,mBAAmB,OAAA;AAC5B,uDAAgG;AAAvF,iHAAA,aAAa,OAAA;AACtB,6DAI+B;AAH7B,uHAAA,gBAAgB,OAAA;AAChB,wIAAA,iCAAiC,OAAA"}
|
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
* Role: Layer-3 integration. Sits next to `defineTool` — same
|
|
24
24
|
* shape, different source. Once tools land on the agent,
|
|
25
25
|
* the rest of the library doesn't know they came from MCP.
|
|
26
|
+
* Since 9.71.0 that is true of DECLARATIONS too: a server's
|
|
27
|
+
* `_meta` bag becomes `argumentsFrom` / `resultKind` / `owner`
|
|
28
|
+
* / `resultClass` / `resultCeiling` on the registered `Tool`,
|
|
29
|
+
* so the integrity checks, the placement mint and the identity
|
|
30
|
+
* joins arm for a remote tool exactly as for a local one. The
|
|
31
|
+
* reading NEVER throws — see `toolExtras.ts`.
|
|
26
32
|
*
|
|
27
33
|
* Emits: N/A — wrapped tools emit the standard
|
|
28
34
|
* `agentfootprint.stream.tool_start` / `tool_end` events
|
|
@@ -36,6 +42,7 @@
|
|
|
36
42
|
*/
|
|
37
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
44
|
exports.mcpClient = void 0;
|
|
45
|
+
const toolExtras_js_1 = require("./toolExtras.js");
|
|
39
46
|
const gatewayTransport_js_1 = require("./gatewayTransport.js");
|
|
40
47
|
const throttleRetry_js_1 = require("./throttleRetry.js");
|
|
41
48
|
const lazyRequire_js_1 = require("../lazyRequire.js");
|
|
@@ -189,6 +196,13 @@ function wrapMcpTool(serverName, sdk, mcp, signal) {
|
|
|
189
196
|
// bare tool name cannot tell two servers' identically-named tools apart;
|
|
190
197
|
// this is the fact that lets it. See `Tool.source`.
|
|
191
198
|
source: serverName,
|
|
199
|
+
// The DECLARATIONS the server sent in MCP's `_meta` bag (9.71.0) — read
|
|
200
|
+
// defensively, per field, by the same rules `defineTool` enforces, and
|
|
201
|
+
// NEVER throwing: a malformed field is warned about once and dropped, and
|
|
202
|
+
// this tool still registers. That is what keeps one bad tool from killing
|
|
203
|
+
// a forty-tool bulk register. A server that sent no bag adds no keys here,
|
|
204
|
+
// so the Tool is byte-identical to one built before this existed.
|
|
205
|
+
...(0, toolExtras_js_1.readToolExtras)(mcp._meta, { server: serverName, tool: mcp.name }),
|
|
192
206
|
execute: async (args) => {
|
|
193
207
|
// The agent passes args as `unknown` per Tool contract. MCP
|
|
194
208
|
// expects a JSON object — non-object inputs become `{}` rather
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":";AAAA
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44,6 +44,14 @@
|
|
|
44
44
|
* - `needs` (declare-and-push credentials) needs a provider; without
|
|
45
45
|
* one the tool would run with `ctx.credential` undefined.
|
|
46
46
|
*
|
|
47
|
+
* ── Declarations travel; execution does not (9.71.0) ─────────────────
|
|
48
|
+
* A served tool's DECLARATIONS — `argumentsFrom`, `resultKind`, `owner`,
|
|
49
|
+
* `resultClass`, `resultCeiling` — are written into MCP's own `_meta` bag
|
|
50
|
+
* under one namespaced key, so an agentfootprint client arms the checks and
|
|
51
|
+
* rails that read them exactly as it would for a local `defineTool`. The
|
|
52
|
+
* execution-side fields never go: see `toolExtras.ts` for the bar and the
|
|
53
|
+
* reasoning. A tool declaring none of the five lists exactly as before.
|
|
54
|
+
*
|
|
47
55
|
* ── Schemas ──────────────────────────────────────────────────────────
|
|
48
56
|
* Tools already carry JSON Schema in `schema.inputSchema`, and MCP's
|
|
49
57
|
* `tools/list` wants JSON Schema, so the mapping is the identity
|
|
@@ -82,6 +90,7 @@ const types_js_1 = require("../../identity/types.js");
|
|
|
82
90
|
const capability_js_1 = require("../../artifacts/capability.js");
|
|
83
91
|
const wants_js_1 = require("../../artifacts/wants.js");
|
|
84
92
|
const lazyRequire_js_1 = require("../lazyRequire.js");
|
|
93
|
+
const toolExtras_js_1 = require("./toolExtras.js");
|
|
85
94
|
const runChain_js_1 = require("../../core/agent/middleware/runChain.js");
|
|
86
95
|
const DEFAULT_SERVER_NAME = 'agentfootprint';
|
|
87
96
|
const DEFAULT_SERVER_VERSION = '0.0.0';
|
|
@@ -101,11 +110,20 @@ async function mcpServe(tools, opts = {}) {
|
|
|
101
110
|
const version = opts.version ?? DEFAULT_SERVER_VERSION;
|
|
102
111
|
const byName = validateServableTools(tools, name, opts.credentials);
|
|
103
112
|
const credentials = opts.credentials ?? (0, types_js_1.unconfiguredCredentialProvider)();
|
|
104
|
-
const listing = tools.map((t) =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
const listing = tools.map((t) => {
|
|
114
|
+
// The declaration half of the tool, in MCP's own extensibility bag
|
|
115
|
+
// (9.71.0). Absent fields stay absent and a tool that declares NOTHING
|
|
116
|
+
// gets no `_meta` key at all, so a server whose tools carry no
|
|
117
|
+
// declarations lists exactly the bytes it always did. See toolExtras.ts
|
|
118
|
+
// for the inclusion bar and for why `needs` / `checkIn` never travel.
|
|
119
|
+
const extras = (0, toolExtras_js_1.toolExtrasOf)(t);
|
|
120
|
+
return {
|
|
121
|
+
name: t.schema.name,
|
|
122
|
+
...(t.schema.description !== undefined && { description: t.schema.description }),
|
|
123
|
+
inputSchema: t.schema.inputSchema ?? { type: 'object', properties: {} },
|
|
124
|
+
...(extras !== undefined && { _meta: { [toolExtras_js_1.MCP_TOOL_EXTRAS_KEY]: extras } }),
|
|
125
|
+
};
|
|
126
|
+
});
|
|
109
127
|
// Order matters: the server is resolved FIRST so that a missing SDK is
|
|
110
128
|
// reported by the message that tells you how to install it, rather than
|
|
111
129
|
// by the narrower one about a single submodule.
|