agentfootprint 2.1.0 → 2.2.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 (40) hide show
  1. package/AGENTS.md +28 -0
  2. package/CLAUDE.md +28 -0
  3. package/README.md +2 -1
  4. package/ai-instructions/claude-code/SKILL.md +32 -0
  5. package/ai-instructions/clinerules +22 -0
  6. package/ai-instructions/copilot-instructions.md +22 -0
  7. package/ai-instructions/cursor/agentfootprint.md +22 -0
  8. package/ai-instructions/kiro/agentfootprint.md +22 -0
  9. package/ai-instructions/windsurfrules +22 -0
  10. package/dist/core/Agent.js +11 -0
  11. package/dist/core/Agent.js.map +1 -1
  12. package/dist/esm/core/Agent.js +11 -0
  13. package/dist/esm/core/Agent.js.map +1 -1
  14. package/dist/esm/index.js +5 -0
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/lib/mcp/index.js +8 -0
  17. package/dist/esm/lib/mcp/index.js.map +1 -0
  18. package/dist/esm/lib/mcp/mcpClient.js +171 -0
  19. package/dist/esm/lib/mcp/mcpClient.js.map +1 -0
  20. package/dist/esm/lib/mcp/types.js +24 -0
  21. package/dist/esm/lib/mcp/types.js.map +1 -0
  22. package/dist/index.js +7 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/mcp/index.js +12 -0
  25. package/dist/lib/mcp/index.js.map +1 -0
  26. package/dist/lib/mcp/mcpClient.js +175 -0
  27. package/dist/lib/mcp/mcpClient.js.map +1 -0
  28. package/dist/lib/mcp/types.js +25 -0
  29. package/dist/lib/mcp/types.js.map +1 -0
  30. package/dist/types/core/Agent.d.ts +7 -0
  31. package/dist/types/core/Agent.d.ts.map +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/types/lib/mcp/index.d.ts +9 -0
  35. package/dist/types/lib/mcp/index.d.ts.map +1 -0
  36. package/dist/types/lib/mcp/mcpClient.d.ts +64 -0
  37. package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -0
  38. package/dist/types/lib/mcp/types.d.ts +132 -0
  39. package/dist/types/lib/mcp/types.d.ts.map +1 -0
  40. package/package.json +1 -1
@@ -0,0 +1,132 @@
1
+ /**
2
+ * MCP — Model Context Protocol client integration.
3
+ *
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(...)`.
9
+ *
10
+ * Pattern: Adapter (GoF) — translates MCP wire format ↔ agentfootprint
11
+ * `Tool` interface. The MCP SDK does the protocol work; we
12
+ * just bridge.
13
+ * Role: Layer-3 tool integration. Pairs with `defineTool` (the
14
+ * inline alternative for non-MCP tools).
15
+ * Emits: N/A directly — wrapped tools emit the standard
16
+ * `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.
22
+ */
23
+ import type { Tool } from '../../core/tools.js';
24
+ /**
25
+ * `stdio` transport — spawns a local subprocess and speaks MCP over
26
+ * its stdin/stdout. Best for development, single-user scenarios, and
27
+ * testing against locally-installed MCP servers.
28
+ */
29
+ export interface McpStdioTransport {
30
+ readonly transport: 'stdio';
31
+ /** Executable to spawn (e.g., `'npx'`, `'node'`, `'python'`). */
32
+ readonly command: string;
33
+ /** CLI args passed to the executable. */
34
+ readonly args?: readonly string[];
35
+ /** Optional env vars set on the subprocess. */
36
+ readonly env?: Readonly<Record<string, string>>;
37
+ /** Working directory for the subprocess. */
38
+ readonly cwd?: string;
39
+ }
40
+ /**
41
+ * `http` transport — speaks MCP over Streamable HTTP. Best for remote
42
+ * servers, web environments, and multi-user scenarios.
43
+ */
44
+ export interface McpHttpTransport {
45
+ readonly transport: 'http';
46
+ /** MCP server endpoint URL. */
47
+ readonly url: string;
48
+ /** Optional auth headers (e.g., `Authorization: Bearer ...`). */
49
+ readonly headers?: Readonly<Record<string, string>>;
50
+ }
51
+ export type McpTransport = McpStdioTransport | McpHttpTransport;
52
+ export interface McpClientOptions {
53
+ /**
54
+ * Logical name for observability + tool-call routing. Surfaces in
55
+ * Lens chips and event payloads. Defaults to `'mcp'`. Recommend
56
+ * setting per-server (`'slack-mcp'`, `'github-mcp'`) when you
57
+ * connect to multiple servers.
58
+ */
59
+ readonly name?: string;
60
+ /** Transport configuration — stdio or http. */
61
+ readonly transport: McpTransport;
62
+ /**
63
+ * Optional client identity sent on connect. Default:
64
+ * `{ name: 'agentfootprint', version: <package version> }`.
65
+ */
66
+ readonly clientInfo?: {
67
+ readonly name: string;
68
+ readonly version: string;
69
+ };
70
+ /** Abort the connection / list / call paths. Honored by the SDK. */
71
+ readonly signal?: AbortSignal;
72
+ /**
73
+ * @internal Pre-built SDK client for tests. Skips SDK import +
74
+ * transport construction. Same convention as `AnthropicProvider._client`.
75
+ */
76
+ readonly _client?: McpSdkClient;
77
+ }
78
+ /**
79
+ * What `mcpClient(opts)` returns. Connect once; call `.tools()` to
80
+ * snapshot the tool list, `.refresh()` to re-list after the server's
81
+ * tools change, `.close()` when done.
82
+ */
83
+ export interface McpClient {
84
+ /** Logical name from options (or default `'mcp'`). */
85
+ readonly name: string;
86
+ /**
87
+ * List the server's tools as agentfootprint `Tool[]`. First call
88
+ * after `mcpClient(...)` is the snapshot used to register on the
89
+ * agent; subsequent calls re-fetch (cheap, in-memory cached by the
90
+ * SDK between fetches).
91
+ */
92
+ tools(): Promise<readonly Tool[]>;
93
+ /**
94
+ * Force a refresh from the server. Use when you suspect the server
95
+ * has dynamically added/removed tools mid-session (e.g., after the
96
+ * server processes a config update).
97
+ */
98
+ refresh(): Promise<readonly Tool[]>;
99
+ /** Close the underlying transport. After `close()` the client is unusable. */
100
+ close(): Promise<void>;
101
+ }
102
+ /**
103
+ * Minimal structural type capturing the parts of the MCP SDK client
104
+ * we touch. Defined locally so we can:
105
+ * 1. Inject a mock for tests (`McpClientOptions._client`)
106
+ * 2. Avoid a hard import on `@modelcontextprotocol/sdk` (which is
107
+ * a lazy peer-dep)
108
+ *
109
+ * The real SDK exports a richer surface; we narrow to what's needed.
110
+ */
111
+ export interface McpSdkClient {
112
+ connect(transport: unknown): Promise<void>;
113
+ listTools(): Promise<{
114
+ readonly tools: ReadonlyArray<{
115
+ readonly name: string;
116
+ readonly description?: string;
117
+ readonly inputSchema: Readonly<Record<string, unknown>>;
118
+ }>;
119
+ }>;
120
+ callTool(args: {
121
+ readonly name: string;
122
+ readonly arguments?: Readonly<Record<string, unknown>>;
123
+ }): Promise<{
124
+ readonly content: ReadonlyArray<{
125
+ readonly type: string;
126
+ readonly text?: string;
127
+ }>;
128
+ readonly isError?: boolean;
129
+ }>;
130
+ close(): Promise<void>;
131
+ }
132
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,MAAM,WAAW,gBAAgB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C5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAC9B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;SACzD,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACxD,GAAG,OAAO,CAAC;QACV,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;YAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KAC5B,CAAC,CAAC;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",