@agentionai/agents 0.6.0 → 0.7.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.
@@ -6,24 +6,43 @@ export type AgentVendor = "openai" | "anthropic" | "mistral" | "gemini";
6
6
  * Common configuration shared by all agents
7
7
  */
8
8
  export interface CommonAgentConfig {
9
+ /** Unique identifier for the agent instance */
9
10
  id: string;
11
+ /** Human-readable name for the agent */
10
12
  name: string;
13
+ /** Description of the agent's purpose and capabilities */
11
14
  description: string;
15
+ /** API key for authenticating with the LLM provider */
12
16
  apiKey: string;
17
+ /** Enable debug logging for troubleshooting (default: false) */
13
18
  debug?: boolean;
19
+ /** Maximum number of messages to retain in conversation history */
14
20
  maxHistoryLength?: number;
21
+ /** Model identifier (e.g., "claude-3-5-sonnet-20241022", "gpt-4") */
15
22
  model?: string;
23
+ /** Array of tools the agent can use during execution */
16
24
  tools?: Tool<unknown>[];
25
+ /** Array of sub-agents this agent can delegate tasks to */
17
26
  agents?: BaseAgent[];
27
+ /** Maximum number of tokens to generate in the response */
18
28
  maxTokens?: number;
29
+ /** Sampling temperature (0.0-1.0). Higher values increase randomness */
19
30
  temperature?: number;
31
+ /** Nucleus sampling threshold (0.0-1.0). Considers tokens with top cumulative probability */
20
32
  topP?: number;
33
+ /** Top-K sampling. Only considers the K most likely tokens (Anthropic, Gemini) */
21
34
  topK?: number;
35
+ /** Sequences that will stop generation when encountered */
22
36
  stopSequences?: string[];
37
+ /** Request timeout in milliseconds */
23
38
  timeout?: number;
39
+ /** Maximum number of retry attempts on API failures */
24
40
  maxRetries?: number;
41
+ /** Random seed for deterministic outputs (when supported by vendor) */
25
42
  seed?: number;
43
+ /** Penalty for using tokens that already appear in the text (-2.0 to 2.0) */
26
44
  presencePenalty?: number;
45
+ /** Penalty based on token frequency in the text (-2.0 to 2.0) */
27
46
  frequencyPenalty?: number;
28
47
  }
29
48
  /**
package/dist/core.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./history/History";
7
7
  export * from "./history/types";
8
8
  export * from "./graph/AgentGraph";
9
9
  export * from "./tools/Tool";
10
+ export * from "./mcp";
10
11
  export * from "./viz";
11
12
  export * from "./vectorstore";
12
13
  export * from "./chunkers";
package/dist/core.js CHANGED
@@ -29,6 +29,8 @@ __exportStar(require("./history/types"), exports);
29
29
  __exportStar(require("./graph/AgentGraph"), exports);
30
30
  // Tools
31
31
  __exportStar(require("./tools/Tool"), exports);
32
+ // MCP (Model Context Protocol)
33
+ __exportStar(require("./mcp"), exports);
32
34
  // Visualization
33
35
  __exportStar(require("./viz"), exports);
34
36
  // Vector Store
@@ -103,6 +103,7 @@ class VoyageAIEmbeddings extends Embeddings_1.Embeddings {
103
103
  return [];
104
104
  }
105
105
  // Dynamic import to keep voyageai optional at module load time
106
+ // @ts-ignore - voyageai is an optional peer dependency
106
107
  const { VoyageAIClient } = await Promise.resolve().then(() => __importStar(require("voyageai")));
107
108
  const client = new VoyageAIClient({
108
109
  apiKey: this.apiKey,
@@ -62,6 +62,9 @@ class History extends events_1.default {
62
62
  ...entry,
63
63
  __metadata,
64
64
  });
65
+ if (this.options.maxLength && this._entries.length > this.options.maxLength) {
66
+ this._entries = this._entries.slice(this._entries.length - this.options.maxLength);
67
+ }
65
68
  this.emit("entry", entry);
66
69
  }
67
70
  /**
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./history/types";
9
9
  export { anthropicTransformer, openAiTransformer, mistralTransformer, geminiTransformer, } from "./history/transformers";
10
10
  export * from "./graph/AgentGraph";
11
11
  export * from "./tools/Tool";
12
+ export * from "./mcp";
12
13
  export * from "./viz";
13
14
  export * from "./vectorstore";
14
15
  export * from "./embeddings";
package/dist/index.js CHANGED
@@ -45,6 +45,8 @@ Object.defineProperty(exports, "geminiTransformer", { enumerable: true, get: fun
45
45
  __exportStar(require("./graph/AgentGraph"), exports);
46
46
  // Tools
47
47
  __exportStar(require("./tools/Tool"), exports);
48
+ // MCP (Model Context Protocol)
49
+ __exportStar(require("./mcp"), exports);
48
50
  // Visualization
49
51
  __exportStar(require("./viz"), exports);
50
52
  // Vector Store
@@ -0,0 +1,106 @@
1
+ import { Tool } from "../tools/Tool";
2
+ import { MCPStdioConfig, MCPHttpConfig, MCPClientOptions } from "./types";
3
+ /**
4
+ * MCPClient connects to an MCP (Model Context Protocol) server and converts its
5
+ * tools into agention-lib {@link Tool} instances that can be passed to any agent.
6
+ *
7
+ * Supports two transport types:
8
+ * - **stdio** — spawns a local process and communicates over stdin/stdout
9
+ * - **http** — connects to a remote MCP server over Streamable HTTP
10
+ *
11
+ * @requires @modelcontextprotocol/sdk - Install as a peer dependency:
12
+ * ```
13
+ * npm install @modelcontextprotocol/sdk
14
+ * ```
15
+ *
16
+ * @example Stdio (local process)
17
+ * ```typescript
18
+ * import { MCPClient } from "@agentionai/agents";
19
+ * import { ClaudeAgent } from "@agentionai/agents/claude";
20
+ *
21
+ * const mcp = MCPClient.fromStdio({
22
+ * command: "npx",
23
+ * args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
24
+ * });
25
+ *
26
+ * await mcp.connect();
27
+ * const agent = new ClaudeAgent({
28
+ * id: "file-agent",
29
+ * name: "File Agent",
30
+ * description: "An agent that can work with files",
31
+ * apiKey: process.env.ANTHROPIC_API_KEY!,
32
+ * tools: mcp.getTools(),
33
+ * });
34
+ *
35
+ * const result = await agent.execute("List the files in /tmp");
36
+ * await mcp.disconnect();
37
+ * ```
38
+ *
39
+ * @example HTTP with static API key
40
+ * ```typescript
41
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
42
+ * headers: { Authorization: "Bearer my-api-key" },
43
+ * });
44
+ *
45
+ * await mcp.connect();
46
+ * agent.addTools(mcp.getTools());
47
+ * ```
48
+ *
49
+ * @example HTTP with OAuth
50
+ * ```typescript
51
+ * import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
52
+ *
53
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
54
+ * authProvider: myOAuthProvider, // implements OAuthClientProvider
55
+ * });
56
+ * ```
57
+ */
58
+ export declare class MCPClient {
59
+ private readonly transportConfig;
60
+ private readonly options;
61
+ private sdkClient;
62
+ private sdkTransport;
63
+ private _tools;
64
+ private connected;
65
+ private constructor();
66
+ /**
67
+ * Create an MCPClient that connects to a local MCP server process via stdio.
68
+ *
69
+ * @param config - Command and arguments to spawn the MCP server process
70
+ * @param options - Optional client identification options
71
+ */
72
+ static fromStdio(config: MCPStdioConfig, options?: MCPClientOptions): MCPClient;
73
+ /**
74
+ * Create an MCPClient that connects to a remote MCP server via HTTP.
75
+ *
76
+ * @param url - Full URL to the MCP endpoint
77
+ * @param options - Optional client options including auth headers or OAuth provider
78
+ */
79
+ static fromUrl(url: string, options?: MCPClientOptions & Pick<MCPHttpConfig, "headers" | "authProvider">): MCPClient;
80
+ /**
81
+ * Connect to the MCP server and discover all available tools.
82
+ *
83
+ * This method is idempotent — calling it when already connected is a no-op.
84
+ * Must be called before {@link getTools}.
85
+ *
86
+ * @throws If the MCP server cannot be reached or the SDK is not installed
87
+ */
88
+ connect(): Promise<void>;
89
+ /**
90
+ * Return all tools discovered from the MCP server as agention-lib Tool instances.
91
+ *
92
+ * Returns an empty array if {@link connect} has not been called yet.
93
+ * The returned tools can be passed directly to any agent via the `tools` config
94
+ * option or {@link BaseAgent.addTools}.
95
+ */
96
+ getTools(): Tool<unknown>[];
97
+ /**
98
+ * Disconnect from the MCP server and release all resources.
99
+ *
100
+ * This method is idempotent — calling it when not connected is a no-op.
101
+ * After disconnecting, {@link getTools} returns an empty array.
102
+ */
103
+ disconnect(): Promise<void>;
104
+ private wrapMcpTool;
105
+ }
106
+ //# sourceMappingURL=MCPClient.d.ts.map
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.MCPClient = void 0;
37
+ const Tool_1 = require("../tools/Tool");
38
+ /**
39
+ * MCPClient connects to an MCP (Model Context Protocol) server and converts its
40
+ * tools into agention-lib {@link Tool} instances that can be passed to any agent.
41
+ *
42
+ * Supports two transport types:
43
+ * - **stdio** — spawns a local process and communicates over stdin/stdout
44
+ * - **http** — connects to a remote MCP server over Streamable HTTP
45
+ *
46
+ * @requires @modelcontextprotocol/sdk - Install as a peer dependency:
47
+ * ```
48
+ * npm install @modelcontextprotocol/sdk
49
+ * ```
50
+ *
51
+ * @example Stdio (local process)
52
+ * ```typescript
53
+ * import { MCPClient } from "@agentionai/agents";
54
+ * import { ClaudeAgent } from "@agentionai/agents/claude";
55
+ *
56
+ * const mcp = MCPClient.fromStdio({
57
+ * command: "npx",
58
+ * args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
59
+ * });
60
+ *
61
+ * await mcp.connect();
62
+ * const agent = new ClaudeAgent({
63
+ * id: "file-agent",
64
+ * name: "File Agent",
65
+ * description: "An agent that can work with files",
66
+ * apiKey: process.env.ANTHROPIC_API_KEY!,
67
+ * tools: mcp.getTools(),
68
+ * });
69
+ *
70
+ * const result = await agent.execute("List the files in /tmp");
71
+ * await mcp.disconnect();
72
+ * ```
73
+ *
74
+ * @example HTTP with static API key
75
+ * ```typescript
76
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
77
+ * headers: { Authorization: "Bearer my-api-key" },
78
+ * });
79
+ *
80
+ * await mcp.connect();
81
+ * agent.addTools(mcp.getTools());
82
+ * ```
83
+ *
84
+ * @example HTTP with OAuth
85
+ * ```typescript
86
+ * import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
87
+ *
88
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
89
+ * authProvider: myOAuthProvider, // implements OAuthClientProvider
90
+ * });
91
+ * ```
92
+ */
93
+ class MCPClient {
94
+ constructor(transportConfig, options = {}) {
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
+ this.sdkClient = null;
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
+ this.sdkTransport = null;
99
+ this._tools = [];
100
+ this.connected = false;
101
+ this.transportConfig = transportConfig;
102
+ this.options = {
103
+ clientName: options.clientName ?? "agention-mcp-client",
104
+ clientVersion: options.clientVersion ?? "1.0.0",
105
+ };
106
+ }
107
+ /**
108
+ * Create an MCPClient that connects to a local MCP server process via stdio.
109
+ *
110
+ * @param config - Command and arguments to spawn the MCP server process
111
+ * @param options - Optional client identification options
112
+ */
113
+ static fromStdio(config, options) {
114
+ return new MCPClient({ type: "stdio", config }, options);
115
+ }
116
+ /**
117
+ * Create an MCPClient that connects to a remote MCP server via HTTP.
118
+ *
119
+ * @param url - Full URL to the MCP endpoint
120
+ * @param options - Optional client options including auth headers or OAuth provider
121
+ */
122
+ static fromUrl(url, options) {
123
+ const config = {
124
+ url,
125
+ headers: options?.headers,
126
+ authProvider: options?.authProvider,
127
+ };
128
+ return new MCPClient({ type: "http", config }, options);
129
+ }
130
+ /**
131
+ * Connect to the MCP server and discover all available tools.
132
+ *
133
+ * This method is idempotent — calling it when already connected is a no-op.
134
+ * Must be called before {@link getTools}.
135
+ *
136
+ * @throws If the MCP server cannot be reached or the SDK is not installed
137
+ */
138
+ async connect() {
139
+ if (this.connected)
140
+ return;
141
+ // Build module paths at runtime so tsc does not attempt to resolve them at
142
+ // compile time. @modelcontextprotocol/sdk is an optional peer dependency and
143
+ // may not be installed on the build host.
144
+ const pkg = "@modelcontextprotocol/sdk";
145
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
+ const { Client } = await Promise.resolve(`${`${pkg}/client/index.js`}`).then(s => __importStar(require(s)));
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+ const sdkClient = new Client({ name: this.options.clientName, version: this.options.clientVersion }, { capabilities: {} });
149
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
150
+ let transport;
151
+ if (this.transportConfig.type === "stdio") {
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
+ const { StdioClientTransport } = await Promise.resolve(`${`${pkg}/client/stdio.js`}`).then(s => __importStar(require(s)));
154
+ transport = new StdioClientTransport({
155
+ command: this.transportConfig.config.command,
156
+ args: this.transportConfig.config.args ?? [],
157
+ env: this.transportConfig.config.env,
158
+ });
159
+ }
160
+ else {
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ const { StreamableHTTPClientTransport } = await Promise.resolve(`${`${pkg}/client/streamableHttp.js`}`).then(s => __importStar(require(s)));
163
+ const { url, headers, authProvider } = this.transportConfig.config;
164
+ transport = new StreamableHTTPClientTransport(new URL(url), {
165
+ ...(headers ? { requestInit: { headers } } : {}),
166
+ ...(authProvider ? { authProvider } : {}),
167
+ });
168
+ }
169
+ await sdkClient.connect(transport);
170
+ this.sdkClient = sdkClient;
171
+ this.sdkTransport = transport;
172
+ this.connected = true;
173
+ // Paginate through all tools
174
+ const allMcpTools = [];
175
+ let cursor;
176
+ do {
177
+ const response = await sdkClient.listTools(cursor ? { cursor } : {});
178
+ allMcpTools.push(...response.tools);
179
+ cursor = response.nextCursor;
180
+ } while (cursor);
181
+ this._tools = allMcpTools.map((mcpTool) => this.wrapMcpTool(mcpTool));
182
+ }
183
+ /**
184
+ * Return all tools discovered from the MCP server as agention-lib Tool instances.
185
+ *
186
+ * Returns an empty array if {@link connect} has not been called yet.
187
+ * The returned tools can be passed directly to any agent via the `tools` config
188
+ * option or {@link BaseAgent.addTools}.
189
+ */
190
+ getTools() {
191
+ return this._tools;
192
+ }
193
+ /**
194
+ * Disconnect from the MCP server and release all resources.
195
+ *
196
+ * This method is idempotent — calling it when not connected is a no-op.
197
+ * After disconnecting, {@link getTools} returns an empty array.
198
+ */
199
+ async disconnect() {
200
+ if (!this.connected)
201
+ return;
202
+ try {
203
+ if (this.transportConfig.type === "http" && this.sdkTransport) {
204
+ await this.sdkTransport.terminateSession?.();
205
+ }
206
+ if (this.sdkClient) {
207
+ await this.sdkClient.close();
208
+ }
209
+ }
210
+ finally {
211
+ this.sdkClient = null;
212
+ this.sdkTransport = null;
213
+ this._tools = [];
214
+ this.connected = false;
215
+ }
216
+ }
217
+ wrapMcpTool(mcpTool) {
218
+ const inputSchema = {
219
+ type: "object",
220
+ properties: mcpTool.inputSchema?.properties ?? {},
221
+ required: mcpTool.inputSchema?.required,
222
+ };
223
+ return new Tool_1.Tool({
224
+ name: mcpTool.name,
225
+ description: mcpTool.description ?? mcpTool.name,
226
+ inputSchema,
227
+ execute: async (input) => {
228
+ if (!this.connected || !this.sdkClient) {
229
+ throw new Error(`MCPClient: Cannot execute tool "${mcpTool.name}" — client is not connected`);
230
+ }
231
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
+ let result;
233
+ try {
234
+ result = await this.sdkClient.callTool({
235
+ name: mcpTool.name,
236
+ arguments: input,
237
+ });
238
+ }
239
+ catch (error) {
240
+ const message = error instanceof Error ? error.message : String(error);
241
+ throw new Error(`MCPClient: Tool "${mcpTool.name}" execution failed: ${message}`);
242
+ }
243
+ // Extract text content items from MCP result
244
+ if (result?.content && Array.isArray(result.content)) {
245
+ const textItems = result.content
246
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
+ .filter((item) => item.type === "text")
248
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
249
+ .map((item) => item.text);
250
+ if (textItems.length > 0) {
251
+ return textItems.length === 1 ? textItems[0] : textItems.join("\n");
252
+ }
253
+ }
254
+ // Fall back to structured content or full JSON serialization
255
+ if (result?.structuredContent !== undefined) {
256
+ return result.structuredContent;
257
+ }
258
+ return JSON.stringify(result ?? null);
259
+ },
260
+ });
261
+ }
262
+ }
263
+ exports.MCPClient = MCPClient;
264
+ //# sourceMappingURL=MCPClient.js.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * MCP (Model Context Protocol) support for agention-lib.
3
+ *
4
+ * Connects to any MCP server — local stdio processes or remote HTTP endpoints —
5
+ * and exposes their tools as agention-lib {@link Tool} instances compatible with
6
+ * all agent types (ClaudeAgent, OpenAiAgent, MistralAgent, GeminiAgent).
7
+ *
8
+ * @requires @modelcontextprotocol/sdk - Optional peer dependency, install when needed:
9
+ * ```
10
+ * npm install @modelcontextprotocol/sdk
11
+ * ```
12
+ *
13
+ * @example Stdio (local process)
14
+ * ```typescript
15
+ * import { MCPClient, ClaudeAgent } from "@agentionai/agents";
16
+ *
17
+ * const mcp = MCPClient.fromStdio({
18
+ * command: "npx",
19
+ * args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
20
+ * });
21
+ *
22
+ * await mcp.connect();
23
+ *
24
+ * const agent = new ClaudeAgent({
25
+ * id: "file-agent",
26
+ * name: "File Agent",
27
+ * description: "An agent that can work with files",
28
+ * apiKey: process.env.ANTHROPIC_API_KEY!,
29
+ * tools: mcp.getTools(),
30
+ * });
31
+ *
32
+ * const result = await agent.execute("List the files in /tmp");
33
+ * await mcp.disconnect();
34
+ * ```
35
+ *
36
+ * @example HTTP with static API key
37
+ * ```typescript
38
+ * import { MCPClient } from "@agentionai/agents";
39
+ *
40
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
41
+ * headers: { Authorization: "Bearer my-api-key" },
42
+ * });
43
+ *
44
+ * await mcp.connect();
45
+ * agent.addTools(mcp.getTools());
46
+ * await mcp.disconnect();
47
+ * ```
48
+ *
49
+ * @example HTTP with OAuth
50
+ * ```typescript
51
+ * import { MCPClient } from "@agentionai/agents";
52
+ * import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
53
+ *
54
+ * // Implement OAuthClientProvider from the MCP SDK
55
+ * const myOAuthProvider: OAuthClientProvider = { ... };
56
+ *
57
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
58
+ * authProvider: myOAuthProvider,
59
+ * });
60
+ * ```
61
+ */
62
+ export { MCPClient } from "./MCPClient";
63
+ export type { MCPStdioConfig, MCPHttpConfig, MCPClientOptions } from "./types";
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * MCP (Model Context Protocol) support for agention-lib.
4
+ *
5
+ * Connects to any MCP server — local stdio processes or remote HTTP endpoints —
6
+ * and exposes their tools as agention-lib {@link Tool} instances compatible with
7
+ * all agent types (ClaudeAgent, OpenAiAgent, MistralAgent, GeminiAgent).
8
+ *
9
+ * @requires @modelcontextprotocol/sdk - Optional peer dependency, install when needed:
10
+ * ```
11
+ * npm install @modelcontextprotocol/sdk
12
+ * ```
13
+ *
14
+ * @example Stdio (local process)
15
+ * ```typescript
16
+ * import { MCPClient, ClaudeAgent } from "@agentionai/agents";
17
+ *
18
+ * const mcp = MCPClient.fromStdio({
19
+ * command: "npx",
20
+ * args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
21
+ * });
22
+ *
23
+ * await mcp.connect();
24
+ *
25
+ * const agent = new ClaudeAgent({
26
+ * id: "file-agent",
27
+ * name: "File Agent",
28
+ * description: "An agent that can work with files",
29
+ * apiKey: process.env.ANTHROPIC_API_KEY!,
30
+ * tools: mcp.getTools(),
31
+ * });
32
+ *
33
+ * const result = await agent.execute("List the files in /tmp");
34
+ * await mcp.disconnect();
35
+ * ```
36
+ *
37
+ * @example HTTP with static API key
38
+ * ```typescript
39
+ * import { MCPClient } from "@agentionai/agents";
40
+ *
41
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
42
+ * headers: { Authorization: "Bearer my-api-key" },
43
+ * });
44
+ *
45
+ * await mcp.connect();
46
+ * agent.addTools(mcp.getTools());
47
+ * await mcp.disconnect();
48
+ * ```
49
+ *
50
+ * @example HTTP with OAuth
51
+ * ```typescript
52
+ * import { MCPClient } from "@agentionai/agents";
53
+ * import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
54
+ *
55
+ * // Implement OAuthClientProvider from the MCP SDK
56
+ * const myOAuthProvider: OAuthClientProvider = { ... };
57
+ *
58
+ * const mcp = MCPClient.fromUrl("https://my-mcp-server.com/mcp", {
59
+ * authProvider: myOAuthProvider,
60
+ * });
61
+ * ```
62
+ */
63
+ Object.defineProperty(exports, "__esModule", { value: true });
64
+ exports.MCPClient = void 0;
65
+ var MCPClient_1 = require("./MCPClient");
66
+ Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return MCPClient_1.MCPClient; } });
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Configuration for connecting to an MCP server via stdio (local process).
3
+ */
4
+ export interface MCPStdioConfig {
5
+ /** The command to spawn (e.g. "node", "python", "npx") */
6
+ command: string;
7
+ /** Arguments to pass to the command */
8
+ args?: string[];
9
+ /** Environment variables for the spawned process */
10
+ env?: Record<string, string>;
11
+ }
12
+ /**
13
+ * Configuration for connecting to an MCP server via HTTP (remote URL).
14
+ */
15
+ export interface MCPHttpConfig {
16
+ /** Full URL to the MCP endpoint */
17
+ url: string;
18
+ /** Optional HTTP headers for static auth tokens or API keys */
19
+ headers?: Record<string, string>;
20
+ /**
21
+ * Optional OAuth provider for dynamic authorization.
22
+ * Implement the `OAuthClientProvider` interface from `@modelcontextprotocol/sdk`
23
+ * and pass it here for OAuth 2.0 + PKCE flows.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
28
+ *
29
+ * const mcp = MCPClient.fromUrl("https://my-server.com/mcp", {
30
+ * authProvider: myOAuthProvider,
31
+ * });
32
+ * ```
33
+ */
34
+ authProvider?: unknown;
35
+ }
36
+ /**
37
+ * Options shared by all MCPClient connection types.
38
+ */
39
+ export interface MCPClientOptions {
40
+ /**
41
+ * Name to identify this MCP client (sent during SDK handshake).
42
+ * @default "agention-mcp-client"
43
+ */
44
+ clientName?: string;
45
+ /**
46
+ * Version string for the MCP client.
47
+ * @default "1.0.0"
48
+ */
49
+ clientVersion?: string;
50
+ }
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentionai/agents",
3
3
  "author": "Laurent Zuijdwijk",
4
- "version": "0.6.0",
4
+ "version": "0.7.0",
5
5
  "description": "Agent Library",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -110,6 +110,7 @@
110
110
  "@google/generative-ai": "^0.24.1",
111
111
  "@lancedb/lancedb": "^0.23.0",
112
112
  "@mistralai/mistralai": "^1.13.0",
113
+ "@modelcontextprotocol/sdk": "^1.26.0",
113
114
  "apache-arrow": "^18.0.0",
114
115
  "openai": "^6.16.0",
115
116
  "voyageai": "^0.0.3"
@@ -130,6 +131,9 @@
130
131
  "@anthropic-ai/sdk": {
131
132
  "optional": true
132
133
  },
134
+ "@modelcontextprotocol/sdk": {
135
+ "optional": true
136
+ },
133
137
  "openai": {
134
138
  "optional": true
135
139
  },