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.
Files changed (94) hide show
  1. package/dist/core/Agent.js +39 -5
  2. package/dist/core/Agent.js.map +1 -1
  3. package/dist/core/agent/AgentBuilder.js +59 -1
  4. package/dist/core/agent/AgentBuilder.js.map +1 -1
  5. package/dist/core/agent/buildAgentChart.js +6 -0
  6. package/dist/core/agent/buildAgentChart.js.map +1 -1
  7. package/dist/core/agent/buildDynamicAgentChart.js +14 -0
  8. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  9. package/dist/core/agent/stages/callLLM.js +10 -4
  10. package/dist/core/agent/stages/callLLM.js.map +1 -1
  11. package/dist/core/agent/stages/seed.js +16 -0
  12. package/dist/core/agent/stages/seed.js.map +1 -1
  13. package/dist/core/slots/buildSystemPromptSlot.js +2 -1
  14. package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
  15. package/dist/esm/core/Agent.d.ts +7 -3
  16. package/dist/esm/core/Agent.js +39 -5
  17. package/dist/esm/core/Agent.js.map +1 -1
  18. package/dist/esm/core/agent/AgentBuilder.d.ts +48 -1
  19. package/dist/esm/core/agent/AgentBuilder.js +59 -1
  20. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  21. package/dist/esm/core/agent/buildAgentChart.js +6 -0
  22. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  23. package/dist/esm/core/agent/buildDynamicAgentChart.js +14 -0
  24. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  25. package/dist/esm/core/agent/stages/callLLM.d.ts +9 -0
  26. package/dist/esm/core/agent/stages/callLLM.js +10 -4
  27. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  28. package/dist/esm/core/agent/stages/seed.d.ts +10 -1
  29. package/dist/esm/core/agent/stages/seed.js +16 -0
  30. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  31. package/dist/esm/core/agent/types.d.ts +44 -0
  32. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +19 -4
  33. package/dist/esm/core/slots/buildSystemPromptSlot.js +2 -1
  34. package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
  35. package/dist/esm/lib/injection-engine/index.d.ts +1 -0
  36. package/dist/esm/lib/injection-engine/index.js +4 -0
  37. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  38. package/dist/esm/lib/injection-engine/skillsFromDir.d.ts +80 -0
  39. package/dist/esm/lib/injection-engine/skillsFromDir.js +243 -0
  40. package/dist/esm/lib/injection-engine/skillsFromDir.js.map +1 -0
  41. package/dist/esm/lib/mcp/index.d.ts +6 -5
  42. package/dist/esm/lib/mcp/index.js +5 -4
  43. package/dist/esm/lib/mcp/index.js.map +1 -1
  44. package/dist/esm/lib/mcp/mcpClient.js +21 -9
  45. package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
  46. package/dist/esm/lib/mcp/mcpServe.d.ts +70 -0
  47. package/dist/esm/lib/mcp/mcpServe.js +374 -0
  48. package/dist/esm/lib/mcp/mcpServe.js.map +1 -0
  49. package/dist/esm/lib/mcp/types.d.ts +130 -17
  50. package/dist/esm/lib/mcp/types.js +10 -10
  51. package/dist/esm/tool-providers/index.d.ts +8 -2
  52. package/dist/esm/tool-providers/index.js +7 -1
  53. package/dist/esm/tool-providers/index.js.map +1 -1
  54. package/dist/lib/injection-engine/index.js +6 -1
  55. package/dist/lib/injection-engine/index.js.map +1 -1
  56. package/dist/lib/injection-engine/skillsFromDir.js +270 -0
  57. package/dist/lib/injection-engine/skillsFromDir.js.map +1 -0
  58. package/dist/lib/mcp/index.js +7 -5
  59. package/dist/lib/mcp/index.js.map +1 -1
  60. package/dist/lib/mcp/mcpClient.js +21 -9
  61. package/dist/lib/mcp/mcpClient.js.map +1 -1
  62. package/dist/lib/mcp/mcpServe.js +401 -0
  63. package/dist/lib/mcp/mcpServe.js.map +1 -0
  64. package/dist/lib/mcp/types.js +10 -10
  65. package/dist/tool-providers/index.js +8 -1
  66. package/dist/tool-providers/index.js.map +1 -1
  67. package/dist/types/core/Agent.d.ts +7 -3
  68. package/dist/types/core/Agent.d.ts.map +1 -1
  69. package/dist/types/core/agent/AgentBuilder.d.ts +48 -1
  70. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  71. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  72. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  73. package/dist/types/core/agent/stages/callLLM.d.ts +9 -0
  74. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  75. package/dist/types/core/agent/stages/seed.d.ts +10 -1
  76. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  77. package/dist/types/core/agent/types.d.ts +44 -0
  78. package/dist/types/core/agent/types.d.ts.map +1 -1
  79. package/dist/types/core/slots/buildSystemPromptSlot.d.ts +19 -4
  80. package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
  81. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  82. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  83. package/dist/types/lib/injection-engine/skillsFromDir.d.ts +81 -0
  84. package/dist/types/lib/injection-engine/skillsFromDir.d.ts.map +1 -0
  85. package/dist/types/lib/mcp/index.d.ts +6 -5
  86. package/dist/types/lib/mcp/index.d.ts.map +1 -1
  87. package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
  88. package/dist/types/lib/mcp/mcpServe.d.ts +71 -0
  89. package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -0
  90. package/dist/types/lib/mcp/types.d.ts +130 -17
  91. package/dist/types/lib/mcp/types.d.ts.map +1 -1
  92. package/dist/types/tool-providers/index.d.ts +8 -2
  93. package/dist/types/tool-providers/index.d.ts.map +1 -1
  94. package/package.json +2 -1
@@ -1,11 +1,14 @@
1
1
  /**
2
- * MCP — Model Context Protocol client integration.
2
+ * MCP — Model Context Protocol, in both directions.
3
3
  *
4
4
  * MCP (https://modelcontextprotocol.io) is an open standard for
5
- * connecting LLMs to external tools and data sources. agentfootprint's
6
- * MCP adapter is **client-only** — it consumes MCP servers and exposes
7
- * their tools as agentfootprint `Tool[]` so consumers can plug them
8
- * straight into `agent.tool(...)`.
5
+ * connecting LLMs to external tools and data sources. This module
6
+ * bridges it both ways:
7
+ *
8
+ * - `mcpClient(opts)` — consume an MCP server; its tools become
9
+ * agentfootprint `Tool[]` you can hand to `agent.tools(...)`.
10
+ * - `mcpServe(tools, opts)` — the other direction: expose your own
11
+ * `Tool[]` AS an MCP server, so any MCP client can call them.
9
12
  *
10
13
  * Pattern: Adapter (GoF) — translates MCP wire format ↔ agentfootprint
11
14
  * `Tool` interface. The MCP SDK does the protocol work; we
@@ -14,11 +17,8 @@
14
17
  * inline alternative for non-MCP tools).
15
18
  * Emits: N/A directly — wrapped tools emit the standard
16
19
  * `agentfootprint.stream.tool_start` / `tool_end` events
17
- * when the agent calls them.
18
- *
19
- * Server-side support (exposing an agent or LLMCall as an MCP tool)
20
- * is a separate concern not yet shipped. This module covers the
21
- * 80% case: pulling an existing MCP server's tools INTO an agent.
20
+ * when the agent calls them. `mcpServe` runs OUTSIDE any
21
+ * agent run, so it emits nothing at all.
22
22
  */
23
23
  import type { Tool } from '../../core/tools.js';
24
24
  /**
@@ -32,7 +32,13 @@ export interface McpStdioTransport {
32
32
  readonly command: string;
33
33
  /** CLI args passed to the executable. */
34
34
  readonly args?: readonly string[];
35
- /** Optional env vars set on the subprocess. */
35
+ /**
36
+ * Environment for the subprocess. Passed to the SDK as-is, and the SDK
37
+ * treats it as the WHOLE environment: set this and the child no longer
38
+ * inherits the safe default set (`PATH`, `HOME`, …). Omit it unless you
39
+ * mean to replace the environment; to merely add a variable, include the
40
+ * ones the child still needs.
41
+ */
36
42
  readonly env?: Readonly<Record<string, string>>;
37
43
  /** Working directory for the subprocess. */
38
44
  readonly cwd?: string;
@@ -107,22 +113,29 @@ export interface McpClient {
107
113
  * a lazy peer-dep)
108
114
  *
109
115
  * The real SDK exports a richer surface; we narrow to what's needed.
116
+ *
117
+ * Argument POSITION matters here and is easy to get wrong: the SDK keeps
118
+ * per-request options (`signal`, `timeout`) in a SEPARATE trailing
119
+ * argument, never inside the JSON-RPC params. A `signal` smuggled into
120
+ * the params object is serialized onto the wire as `{}` and silently
121
+ * fails to cancel anything, so these signatures mirror the SDK's own
122
+ * shape rather than a flattened convenience version of it.
110
123
  */
111
124
  export interface McpSdkClient {
112
- connect(transport: unknown): Promise<void>;
113
- listTools(): Promise<{
125
+ connect(transport: unknown, options?: McpRequestOptions): Promise<void>;
126
+ listTools(params?: undefined, options?: McpRequestOptions): Promise<{
114
127
  readonly tools: ReadonlyArray<{
115
128
  readonly name: string;
116
129
  readonly description?: string;
117
130
  readonly inputSchema: Readonly<Record<string, unknown>>;
118
131
  }>;
119
132
  }>;
120
- callTool(args: {
133
+ callTool(params: {
121
134
  readonly name: string;
122
135
  readonly arguments?: Readonly<Record<string, unknown>>;
123
- /** Forwarded from `McpClientOptions.signal` so consumers can cancel hung tool calls. */
124
- readonly signal?: AbortSignal;
125
- }): Promise<{
136
+ },
137
+ /** The SDK's result schema. We always want its default, so we pass `undefined`. */
138
+ resultSchema?: undefined, options?: McpRequestOptions): Promise<{
126
139
  readonly content: ReadonlyArray<{
127
140
  readonly type: string;
128
141
  readonly text?: string;
@@ -131,4 +144,104 @@ export interface McpSdkClient {
131
144
  }>;
132
145
  close(): Promise<void>;
133
146
  }
147
+ /**
148
+ * The SDK's trailing per-request options argument, narrowed to the one
149
+ * field we forward from {@link McpClientOptions.signal}.
150
+ */
151
+ export interface McpRequestOptions {
152
+ readonly signal?: AbortSignal;
153
+ }
154
+ /**
155
+ * `stdio` transport — the server speaks MCP over its own stdin/stdout.
156
+ * This is how a desktop MCP host launches a server: it spawns your
157
+ * process and talks down the pipe. The default.
158
+ *
159
+ * One consequence worth stating out loud: stdout belongs to the
160
+ * protocol. Anything else your process prints there corrupts the
161
+ * stream, so log to stderr.
162
+ */
163
+ export interface McpStdioServeTransport {
164
+ readonly transport: 'stdio';
165
+ }
166
+ /**
167
+ * `http` transport — the server listens on a port and speaks MCP over
168
+ * Streamable HTTP. Stateless (no session ids): every request is
169
+ * self-contained, which is what makes it safe to run several replicas
170
+ * behind a load balancer.
171
+ */
172
+ export interface McpHttpServeTransport {
173
+ readonly transport: 'http';
174
+ /** TCP port to listen on. */
175
+ readonly port: number;
176
+ /** Interface to bind. Defaults to Node's own default (all interfaces). */
177
+ readonly host?: string;
178
+ /** URL path the MCP endpoint answers on. Default `'/mcp'`. */
179
+ readonly path?: string;
180
+ }
181
+ export type McpServeTransport = McpStdioServeTransport | McpHttpServeTransport;
182
+ export interface McpServeOptions {
183
+ /**
184
+ * Server name reported to clients on connect. Surfaces in the
185
+ * client's server list. Default `'agentfootprint'`.
186
+ */
187
+ readonly name?: string;
188
+ /** Server version reported to clients. Default `'0.0.0'`. */
189
+ readonly version?: string;
190
+ /** Transport configuration. Default `{ transport: 'stdio' }`. */
191
+ readonly transport?: McpServeTransport;
192
+ /**
193
+ * Credential provider for served tools that declare `needs`. The
194
+ * credential is resolved BEFORE `execute` and injected as
195
+ * `ctx.credential`, exactly as the Agent's tool-call stage does it.
196
+ *
197
+ * Serving a `needs`-declaring tool without this is refused at
198
+ * construction: the tool would run with `ctx.credential` undefined
199
+ * and fail somewhere further in, or worse, not fail at all.
200
+ */
201
+ readonly credentials?: import('../../identity/types.js').CredentialProvider;
202
+ /**
203
+ * @internal Pre-built SDK server for tests. Skips SDK import +
204
+ * transport construction. Mirrors `McpClientOptions._client`.
205
+ */
206
+ readonly _server?: McpSdkServer;
207
+ }
208
+ /**
209
+ * What `mcpServe(...)` returns. The server is already listening by the
210
+ * time you hold this; `close()` is the only thing left to do.
211
+ */
212
+ export interface McpServeHandle {
213
+ /** Server name from options (or the default). */
214
+ readonly name: string;
215
+ /** Names of the tools being served, in the order clients will list them. */
216
+ readonly toolNames: readonly string[];
217
+ /**
218
+ * Stop serving: closes the transport (and, for `http`, the listening
219
+ * socket) and then the MCP server. Idempotent — calling it twice is
220
+ * not an error, so a shutdown hook and an explicit close can coexist.
221
+ */
222
+ close(): Promise<void>;
223
+ }
224
+ /**
225
+ * Minimal structural type for the parts of the MCP SDK's low-level
226
+ * `Server` we touch. Defined locally for the same two reasons as
227
+ * {@link McpSdkClient}: test injection via `McpServeOptions._server`,
228
+ * and no hard import on the lazy peer-dep.
229
+ */
230
+ export interface McpSdkServer {
231
+ setRequestHandler(schema: unknown, handler: (request: McpCallToolRequest, extra: {
232
+ readonly signal?: AbortSignal;
233
+ }) => unknown): void;
234
+ connect(transport: unknown): Promise<void>;
235
+ close(): Promise<void>;
236
+ }
237
+ /**
238
+ * The shape `tools/call` requests arrive in. `tools/list` requests carry
239
+ * no params we read, so one request type covers both handlers.
240
+ */
241
+ export interface McpCallToolRequest {
242
+ readonly params?: {
243
+ readonly name?: string;
244
+ readonly arguments?: unknown;
245
+ };
246
+ }
134
247
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAIhD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,4CAA4C;IAC5C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAA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AC;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH"}
@@ -13,6 +13,12 @@
13
13
  * - `mcpClient(opts)` — connect to an MCP server (real)
14
14
  * - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests
15
15
  *
16
+ * 3. Tool sink — the other direction
17
+ * - `mcpServe(tools, opts)` — expose your own `Tool[]` AS an MCP
18
+ * server, so any MCP client can call them. The served tool is the
19
+ * SAME object you pass in, so whatever governance you composed
20
+ * around it still runs.
21
+ *
16
22
  * Compose freely. The dispatch layer is decorator-shaped (mirroring
17
23
  * `withRetry` / `withFallback` over LLMProvider). Tool sources produce
18
24
  * `Tool[]` that flow into a `staticTools(arr)` provider, which can
@@ -37,6 +43,6 @@ export { staticTools } from './staticTools.js';
37
43
  export { gatedTools } from './gatedTools.js';
38
44
  export { skillScopedTools } from './skillScopedTools.js';
39
45
  export type { ToolProvider, ToolDispatchContext, ToolGatePredicate } from './types.js';
40
- export { mcpClient, mockMcpClient } from '../lib/mcp/index.js';
41
- export type { McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, MockMcpClientOptions, MockMcpTool, } from '../lib/mcp/index.js';
46
+ export { mcpClient, mcpServe, mockMcpClient } from '../lib/mcp/index.js';
47
+ export type { McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, MockMcpClientOptions, MockMcpTool, McpServeOptions, McpServeHandle, McpServeTransport, McpStdioServeTransport, McpHttpServeTransport, McpSdkServer, } from '../lib/mcp/index.js';
42
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKvF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKvF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,GACb,MAAM,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "7.12.0",
3
+ "version": "7.13.0",
4
4
  "description": "The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",
@@ -461,6 +461,7 @@
461
461
  },
462
462
  "devDependencies": {
463
463
  "@arethetypeswrong/cli": "^0.18.1",
464
+ "@modelcontextprotocol/sdk": "^1.30.0",
464
465
  "@types/node": "^25.5.2",
465
466
  "@typescript-eslint/eslint-plugin": "^5.61.0",
466
467
  "@typescript-eslint/parser": "^5.61.0",