@openserv-labs/sdk 1.6.0 → 1.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.
package/README.md CHANGED
@@ -41,6 +41,7 @@ A powerful TypeScript framework for building non-deterministic AI agents with ad
41
41
  - [Upload File](#upload-file)
42
42
  - [Integration Management](#integration-management)
43
43
  - [Call Integration](#call-integration)
44
+ - [MCP](#mcp)
44
45
  - [Advanced Usage](#advanced-usage)
45
46
  - [OpenAI Process Runtime](#openai-process-runtime)
46
47
  - [Error Handling](#error-handling)
@@ -573,6 +574,63 @@ const response = await agent.callIntegration({
573
574
  })
574
575
  ```
575
576
 
577
+ ### MCP
578
+
579
+ Easily connect your agent to external [Model Context Protocol](https://modelcontextprotocol.org) (MCP) servers and automatically import their tools as capabilities.
580
+
581
+ #### Configure MCP servers
582
+
583
+ Provide an `mcpServers` object when creating the agent. Each key is a **server ID** of your choice. Supported transports are `http`, `sse`, and `stdio`.
584
+
585
+ ```typescript
586
+ import { Agent } from '@openserv-labs/sdk'
587
+
588
+ const agent = new Agent({
589
+ systemPrompt: 'You are a search-engine assistant.',
590
+ mcpServers: {
591
+ Exa: {
592
+ transport: 'http',
593
+ url: 'https://server.smithery.ai/exa/mcp?api_key=YOUR_API_KEY',
594
+ autoRegisterTools: true // automatically turn MCP tools into capabilities
595
+ }
596
+ }
597
+ })
598
+
599
+ await agent.start()
600
+ ```
601
+
602
+ ##### Local (stdio) transport
603
+
604
+ ```typescript
605
+ mcpServers: {
606
+ LocalLLM: {
607
+ transport: 'stdio',
608
+ command: 'my-mcp-binary',
609
+ args: ['--model', 'gpt-4o'],
610
+ env: { OPENAI_API_KEY: process.env.OPENAI_API_KEY },
611
+ autoRegisterTools: true
612
+ }
613
+ }
614
+ ```
615
+
616
+ ##### Server-Sent Events (sse) transport
617
+
618
+ ```typescript
619
+ mcpServers: {
620
+ Anthropic: {
621
+ transport: 'sse',
622
+ url: 'https://my-mcp-server.com/sse',
623
+ autoRegisterTools: false
624
+ }
625
+ }
626
+ ```
627
+
628
+ #### Using MCP tools
629
+
630
+ If `autoRegisterTools` is `true`, each MCP tool becomes a capability named `mcp_<serverId>_<toolName>`.
631
+
632
+ You can also access the raw MCP client via `agent.mcpClients['MCP_SERVER_ID']` to list tools (`getTools`) or execute them directly (`executeTool`) inside your agents own capabilities.
633
+
576
634
  ## Advanced Usage
577
635
 
578
636
  ### OpenAI Process Runtime
package/dist/agent.d.ts CHANGED
@@ -4,12 +4,13 @@ import type { doTaskActionSchema, respondChatMessageActionSchema } from './types
4
4
  import { actionSchema } from './types';
5
5
  import type { ChatCompletionMessageParam, ChatCompletion } from 'openai/resources/chat/completions';
6
6
  import OpenAI from 'openai';
7
- import type { z } from 'zod';
7
+ import { z } from 'zod';
8
8
  import { Capability } from './capability';
9
+ import { type MCPServerConfig, MCPClient } from './mcp';
9
10
  /**
10
11
  * Configuration options for creating a new Agent instance.
11
12
  */
12
- export interface AgentOptions {
13
+ export interface AgentOptions<T extends string> {
13
14
  /**
14
15
  * The port number for the agent's HTTP server.
15
16
  * Defaults to 7378 if not specified.
@@ -38,8 +39,12 @@ export interface AgentOptions {
38
39
  * @param context - Additional context about where the error occurred
39
40
  */
40
41
  onError?: (error: Error, context?: Record<string, unknown>) => void;
42
+ /**
43
+ * Configuration for MCP servers to connect to
44
+ */
45
+ mcpServers?: Record<T, MCPServerConfig>;
41
46
  }
42
- export declare class Agent {
47
+ export declare class Agent<M extends string> {
43
48
  private options;
44
49
  /**
45
50
  * The Express application instance used to handle HTTP requests.
@@ -76,7 +81,7 @@ export declare class Agent {
76
81
  * Each capability is an instance of the Capability class with a name, description, schema, and run function.
77
82
  * @protected
78
83
  */
79
- protected tools: Array<Capability<z.ZodTypeAny>>;
84
+ protected tools: Array<Capability<M, z.ZodTypeAny>>;
80
85
  /**
81
86
  * The OpenServ API key used for authentication.
82
87
  * Can be provided in options or via OPENSERV_API_KEY environment variable.
@@ -101,6 +106,11 @@ export declare class Agent {
101
106
  * @protected
102
107
  */
103
108
  protected _openai?: OpenAI;
109
+ /**
110
+ * Map of MCP clients by server ID.
111
+ * @private
112
+ */
113
+ mcpClients: Record<M, MCPClient<M>>;
104
114
  /**
105
115
  * Getter that converts the agent's tools into OpenAI function calling format.
106
116
  * Used when making chat completion requests to OpenAI.
@@ -124,7 +134,8 @@ export declare class Agent {
124
134
  * @param {AgentOptions} options - Configuration options for the agent
125
135
  * @throws {Error} If OpenServ API key is not provided in options or environment
126
136
  */
127
- constructor(options: AgentOptions);
137
+ constructor(options: AgentOptions<M>);
138
+ private initializeMCPClients;
128
139
  /**
129
140
  * Adds a single capability (tool) to the agent.
130
141
  * Each capability must have a unique name and defines a function that can be called via the API.
@@ -146,7 +157,7 @@ export declare class Agent {
146
157
  name: string;
147
158
  description: string;
148
159
  schema: S;
149
- run(this: Agent, params: {
160
+ run(this: Agent<M>, params: {
150
161
  args: z.infer<S>;
151
162
  action?: z.infer<typeof actionSchema>;
152
163
  }, messages: ChatCompletionMessageParam[]): string | Promise<string>;
@@ -169,7 +180,7 @@ export declare class Agent {
169
180
  name: string;
170
181
  description: string;
171
182
  schema: T[K];
172
- run(this: Agent, params: {
183
+ run(this: Agent<M>, params: {
173
184
  args: z.infer<T[K]>;
174
185
  action?: z.infer<typeof actionSchema>;
175
186
  }, messages: ChatCompletionMessageParam[]): string | Promise<string>;
@@ -438,5 +449,15 @@ export declare class Agent {
438
449
  * @throws {Error} If the integration call fails
439
450
  */
440
451
  callIntegration(integration: IntegrationCallRequest): Promise<any>;
452
+ /**
453
+ * Registers a list of MCP tool descriptors as capabilities on the agent.
454
+ * Each tool is wrapped in a function that calls `executeMCPTool`.
455
+ * The capability name is prefixed with `mcp_<serverId>_`.
456
+ *
457
+ * @param serverId - The ID of the MCP server these tools belong to.
458
+ * @param tools - An array of {@link MCPToolDescriptor} objects to register.
459
+ * @private
460
+ */
461
+ private addMCPToolsAsCapabilities;
441
462
  }
442
463
  //# sourceMappingURL=agent.d.ts.map
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,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;YACrC,QAAQ,CAAC,EAAE,0BAA0B,EAAE,CAAA;SACxC,CAAA;KACF;;;IAyBD;;;;;;;OAOG;IACG,eAAe,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE;IAgB5C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAuBnB;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA6C5B;;;;OAIG;IACG,IAAI;IAQV;;;OAGG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;;;;;;;;;;OAaG;IACG,eAAe,CAAC,WAAW,EAAE,sBAAsB;IASzD;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;CAsClC"}
package/dist/agent.js CHANGED
@@ -15,8 +15,10 @@ const logger_1 = require("./logger");
15
15
  const types_1 = require("./types");
16
16
  const http_errors_1 = require("http-errors");
17
17
  const zod_to_json_schema_1 = require("zod-to-json-schema");
18
+ const json_schema_to_zod_1 = require("@n8n/json-schema-to-zod");
18
19
  const openai_1 = __importDefault(require("openai"));
19
20
  const capability_1 = require("./capability");
21
+ const mcp_1 = require("./mcp");
20
22
  const PLATFORM_URL = process.env.OPENSERV_API_URL || 'https://api.openserv.ai';
21
23
  const RUNTIME_URL = process.env.OPENSERV_RUNTIME_URL || 'https://agents.openserv.ai';
22
24
  const DEFAULT_PORT = Number.parseInt(process.env.PORT || '') || 7378;
@@ -96,6 +98,11 @@ class Agent {
96
98
  * @protected
97
99
  */
98
100
  _openai;
101
+ /**
102
+ * Map of MCP clients by server ID.
103
+ * @private
104
+ */
105
+ mcpClients = {};
99
106
  /**
100
107
  * Getter that converts the agent's tools into OpenAI function calling format.
101
108
  * Used when making chat completion requests to OpenAI.
@@ -175,6 +182,20 @@ class Agent {
175
182
  logger_1.logger.warn('OPENSERV_AUTH_TOKEN is not set. All requests will be allowed.');
176
183
  }
177
184
  this.setupRoutes();
185
+ this.initializeMCPClients();
186
+ }
187
+ initializeMCPClients() {
188
+ if (this.options.mcpServers) {
189
+ for (const serverId in this.options.mcpServers) {
190
+ const serverConfig = this.options.mcpServers[serverId];
191
+ if (!serverConfig) {
192
+ logger_1.logger.warn(`MCP server configuration for serverId "${serverId}" is undefined.`);
193
+ continue;
194
+ }
195
+ const client = new mcp_1.MCPClient(serverId, serverConfig);
196
+ this.mcpClients[serverId] = client;
197
+ }
198
+ }
178
199
  }
179
200
  /**
180
201
  * Adds a single capability (tool) to the agent.
@@ -722,13 +743,40 @@ class Agent {
722
743
  * @throws {Error} If server fails to start
723
744
  */
724
745
  async start() {
725
- return new Promise((resolve, reject) => {
746
+ await new Promise((resolve, reject) => {
726
747
  this.server = this.app.listen(this.port, () => {
727
748
  logger_1.logger.info(`Agent server started on port ${this.port}`);
728
749
  resolve();
729
750
  });
730
751
  this.server.on('error', reject);
731
752
  });
753
+ const connectionPromises = Object.values(this.mcpClients).map(client => client.connect());
754
+ const results = await Promise.allSettled(connectionPromises);
755
+ for (const result of results) {
756
+ if (result.status === 'rejected') {
757
+ logger_1.logger.error({ error: result.reason }, 'Failed to connect MCP client');
758
+ }
759
+ }
760
+ try {
761
+ for (const key in this.mcpClients) {
762
+ const mcpClient = this.mcpClients[key];
763
+ const serverId = mcpClient.serverId;
764
+ const serverConfig = this.options.mcpServers?.[serverId];
765
+ if (!serverConfig?.autoRegisterTools) {
766
+ continue;
767
+ }
768
+ const tools = mcpClient.getTools();
769
+ if (tools.length === 0) {
770
+ logger_1.logger.info(`MCP server "${serverId}" connected, but no tools found/returned to auto-register.`);
771
+ continue;
772
+ }
773
+ this.addMCPToolsAsCapabilities(serverId, tools);
774
+ logger_1.logger.info(`Auto-registered ${tools.length} tools for MCP server "${serverId}".`);
775
+ }
776
+ }
777
+ catch (mcpError) {
778
+ logger_1.logger.error({ error: mcpError }, 'Error during MCP tools registration');
779
+ }
732
780
  }
733
781
  /**
734
782
  * Stops the agent's HTTP server.
@@ -769,6 +817,46 @@ class Agent {
769
817
  const response = await this.apiClient.post(`/workspaces/${integration.workspaceId}/integration/${integration.integrationId}/proxy`, integration.details);
770
818
  return response.data;
771
819
  }
820
+ /**
821
+ * Registers a list of MCP tool descriptors as capabilities on the agent.
822
+ * Each tool is wrapped in a function that calls `executeMCPTool`.
823
+ * The capability name is prefixed with `mcp_<serverId>_`.
824
+ *
825
+ * @param serverId - The ID of the MCP server these tools belong to.
826
+ * @param tools - An array of {@link MCPToolDescriptor} objects to register.
827
+ * @private
828
+ */
829
+ addMCPToolsAsCapabilities(serverId, tools) {
830
+ for (const tool of tools) {
831
+ const capabilityName = `mcp_${serverId}_${tool.name}`;
832
+ const inputSchema = tool.inputSchema ?? { type: 'object', properties: {} };
833
+ // Register the capability
834
+ this.addCapability({
835
+ name: capabilityName,
836
+ description: tool.description || `Tool from MCP server ${serverId}`,
837
+ schema: (0, json_schema_to_zod_1.jsonSchemaToZod)(inputSchema),
838
+ async run({ args }) {
839
+ const mcpClient = this.mcpClients[serverId];
840
+ if (!mcpClient) {
841
+ throw new mcp_1.McpError(mcp_1.MCPErrorCodes.INVALID_PARAMS, `Attempted to run tool for unknown MCP serverId: ${serverId}`);
842
+ }
843
+ try {
844
+ const result = await mcpClient.executeTool(tool.name, args);
845
+ // Extract content based on result format
846
+ if (result && typeof result === 'object' && 'content' in result) {
847
+ const content = result.content;
848
+ return typeof content === 'string' ? content : JSON.stringify(content);
849
+ }
850
+ return JSON.stringify(result);
851
+ }
852
+ catch (callError) {
853
+ logger_1.logger.error(`Error calling MCP tool "${capabilityName}":`, callError);
854
+ throw new mcp_1.McpError(mcp_1.MCPErrorCodes.INTERNAL_ERROR, `Failed to execute MCP tool ${tool.name}: ${callError instanceof Error ? callError.message : String(callError)}`);
855
+ }
856
+ }
857
+ });
858
+ }
859
+ }
772
860
  }
773
861
  exports.Agent = Agent;
774
862
  function convertToolToJsonSchema(tool) {
@@ -2,11 +2,11 @@ import type { z } from 'zod';
2
2
  import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
3
3
  import type { CapabilityFuncParams } from './types';
4
4
  import type { Agent } from './agent';
5
- export declare class Capability<Schema extends z.ZodTypeAny> {
5
+ export declare class Capability<M extends string, Schema extends z.ZodTypeAny> {
6
6
  readonly name: string;
7
7
  readonly description: string;
8
8
  readonly schema: Schema;
9
- readonly run: (this: Agent, params: CapabilityFuncParams<Schema>, messages: ChatCompletionMessageParam[]) => string | Promise<string>;
10
- constructor(name: string, description: string, schema: Schema, run: (this: Agent, params: CapabilityFuncParams<Schema>, messages: ChatCompletionMessageParam[]) => string | Promise<string>);
9
+ readonly run: (this: Agent<M>, params: CapabilityFuncParams<Schema>, messages: ChatCompletionMessageParam[]) => string | Promise<string>;
10
+ constructor(name: string, description: string, schema: Schema, run: (this: Agent<M>, params: CapabilityFuncParams<Schema>, messages: ChatCompletionMessageParam[]) => string | Promise<string>);
11
11
  }
12
12
  //# sourceMappingURL=capability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,qBAAa,UAAU,CAAC,MAAM,SAAS,CAAC,CAAC,UAAU;aAE/B,IAAI,EAAE,MAAM;aACZ,WAAW,EAAE,MAAM;aACnB,MAAM,EAAE,MAAM;aACd,GAAG,EAAE,CACnB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,0BAA0B,EAAE,KACnC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAPb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CACnB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,0BAA0B,EAAE,KACnC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAEhC"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,UAAU;aAEjD,IAAI,EAAE,MAAM;aACZ,WAAW,EAAE,MAAM;aACnB,MAAM,EAAE,MAAM;aACd,GAAG,EAAE,CACnB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,0BAA0B,EAAE,KACnC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAPb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CACnB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,0BAA0B,EAAE,KACnC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAEhC"}
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,289 @@
1
+ import { z } from 'zod';
2
+ export type ProtocolClient = any;
3
+ export type MCPTransport = any;
4
+ /**
5
+ * Raw descriptor for a tool as returned by an MCP server's listTools method.
6
+ */
7
+ export type MCPToolDescriptor = {
8
+ /** The name of the tool. */
9
+ name: string;
10
+ /** An optional description of what the tool does. */
11
+ description?: string;
12
+ /** An optional JSON schema defining the input parameters for the tool. */
13
+ inputSchema?: Record<string, unknown>;
14
+ };
15
+ /** Zod schema for validating MCP server configurations using 'stdio' transport. */
16
+ export declare const mcpServerConfigStdioSchema: z.ZodObject<{
17
+ /** Specifies the transport type as 'stdio'. */
18
+ transport: z.ZodLiteral<"stdio">;
19
+ /** The command to execute to start the server. */
20
+ command: z.ZodString;
21
+ /** Arguments to pass to the command. */
22
+ args: z.ZodArray<z.ZodString, "many">;
23
+ /** Optional environment variables for the command. */
24
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
25
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
26
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ transport: "stdio";
29
+ command: string;
30
+ args: string[];
31
+ env?: Record<string, string> | undefined;
32
+ autoRegisterTools?: boolean | undefined;
33
+ }, {
34
+ transport: "stdio";
35
+ command: string;
36
+ args: string[];
37
+ env?: Record<string, string> | undefined;
38
+ autoRegisterTools?: boolean | undefined;
39
+ }>;
40
+ /** Zod schema for validating MCP server configurations using 'sse' transport. */
41
+ export declare const mcpServerConfigSseSchema: z.ZodObject<{
42
+ /** Specifies the transport type as 'sse'. */
43
+ transport: z.ZodLiteral<"sse">;
44
+ /** The URL of the MCP server's SSE endpoint. */
45
+ url: z.ZodString;
46
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
47
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ transport: "sse";
50
+ url: string;
51
+ autoRegisterTools?: boolean | undefined;
52
+ }, {
53
+ transport: "sse";
54
+ url: string;
55
+ autoRegisterTools?: boolean | undefined;
56
+ }>;
57
+ /** Zod schema for validating MCP server configurations using 'http' (Streamable HTTP) transport. */
58
+ export declare const mcpServerConfigHttpSchema: z.ZodObject<{
59
+ /** Specifies the transport type as 'http'. */
60
+ transport: z.ZodLiteral<"http">;
61
+ /** The URL of the MCP server's HTTP endpoint. */
62
+ url: z.ZodString;
63
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
64
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ transport: "http";
67
+ url: string;
68
+ autoRegisterTools?: boolean | undefined;
69
+ }, {
70
+ transport: "http";
71
+ url: string;
72
+ autoRegisterTools?: boolean | undefined;
73
+ }>;
74
+ /**
75
+ * Discriminated union Zod schema for validating MCP server configurations.
76
+ * It differentiates based on the 'transport' property.
77
+ */
78
+ export declare const mcpServerConfigSchema: z.ZodDiscriminatedUnion<"transport", [z.ZodObject<{
79
+ /** Specifies the transport type as 'stdio'. */
80
+ transport: z.ZodLiteral<"stdio">;
81
+ /** The command to execute to start the server. */
82
+ command: z.ZodString;
83
+ /** Arguments to pass to the command. */
84
+ args: z.ZodArray<z.ZodString, "many">;
85
+ /** Optional environment variables for the command. */
86
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
87
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
88
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ transport: "stdio";
91
+ command: string;
92
+ args: string[];
93
+ env?: Record<string, string> | undefined;
94
+ autoRegisterTools?: boolean | undefined;
95
+ }, {
96
+ transport: "stdio";
97
+ command: string;
98
+ args: string[];
99
+ env?: Record<string, string> | undefined;
100
+ autoRegisterTools?: boolean | undefined;
101
+ }>, z.ZodObject<{
102
+ /** Specifies the transport type as 'sse'. */
103
+ transport: z.ZodLiteral<"sse">;
104
+ /** The URL of the MCP server's SSE endpoint. */
105
+ url: z.ZodString;
106
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
107
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ transport: "sse";
110
+ url: string;
111
+ autoRegisterTools?: boolean | undefined;
112
+ }, {
113
+ transport: "sse";
114
+ url: string;
115
+ autoRegisterTools?: boolean | undefined;
116
+ }>, z.ZodObject<{
117
+ /** Specifies the transport type as 'http'. */
118
+ transport: z.ZodLiteral<"http">;
119
+ /** The URL of the MCP server's HTTP endpoint. */
120
+ url: z.ZodString;
121
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
122
+ autoRegisterTools: z.ZodOptional<z.ZodBoolean>;
123
+ }, "strip", z.ZodTypeAny, {
124
+ transport: "http";
125
+ url: string;
126
+ autoRegisterTools?: boolean | undefined;
127
+ }, {
128
+ transport: "http";
129
+ url: string;
130
+ autoRegisterTools?: boolean | undefined;
131
+ }>]>;
132
+ /** Configuration for a single MCP server, covering all transport types. */
133
+ export type MCPServerConfig = z.infer<typeof mcpServerConfigSchema>;
134
+ /** Configuration for an MCP server using 'stdio' (standard input/output) transport. */
135
+ export type MCPServerConfigStdio = z.infer<typeof mcpServerConfigStdioSchema>;
136
+ /** Configuration for an MCP server using 'sse' (Server-Sent Events) transport. */
137
+ export type MCPServerConfigSse = z.infer<typeof mcpServerConfigSseSchema>;
138
+ /** Configuration for an MCP server using 'http' (Streamable HTTP) transport. */
139
+ export type MCPServerConfigHttp = z.infer<typeof mcpServerConfigHttpSchema>;
140
+ /** Dynamically imports the MCP Client class from the MCP SDK. */
141
+ export declare function importClient(): Promise<typeof import("@modelcontextprotocol/sdk/client/index.js", { with: { "resolution-mode": "import" } }).Client>;
142
+ /** Dynamically imports the MCP StdioClientTransport class from the MCP SDK. */
143
+ export declare function importStdioTransport(): Promise<typeof import("@modelcontextprotocol/sdk/client/stdio.js", { with: { "resolution-mode": "import" } }).StdioClientTransport>;
144
+ /** Dynamically imports the MCP SSEClientTransport class from the MCP SDK. */
145
+ export declare function importSSETransport(): Promise<typeof import("@modelcontextprotocol/sdk/client/sse.js", { with: { "resolution-mode": "import" } }).SSEClientTransport>;
146
+ /** Dynamically imports the MCP StreamableHTTPClientTransport class from the MCP SDK. */
147
+ export declare function importHttpTransport(): Promise<typeof import("@modelcontextprotocol/sdk/client/streamableHttp.js", { with: { "resolution-mode": "import" } }).StreamableHTTPClientTransport>;
148
+ /**
149
+ * Creates a new MCP client instance.
150
+ * @param name - The name of the client.
151
+ * @param version - The version of the client.
152
+ * @returns A promise that resolves to an MCPClient instance.
153
+ */
154
+ export declare function createClient(name: string, version: string): Promise<ProtocolClient>;
155
+ /**
156
+ * Creates a new MCP transport layer for stdio communication.
157
+ * @param options - Configuration options for the stdio transport.
158
+ * @param options.command - The command to execute to start the server.
159
+ * @param options.args - Arguments to pass to the command.
160
+ * @param options.env - Optional environment variables for the command.
161
+ * @returns A promise that resolves to an MCPTransport instance for stdio.
162
+ */
163
+ export declare function createStdioTransport(options: {
164
+ command: string;
165
+ args: string[];
166
+ env?: Record<string, string> | undefined;
167
+ }): Promise<MCPTransport>;
168
+ /**
169
+ * Creates a new MCP transport layer for Server-Sent Events (SSE) communication.
170
+ * @param url - The URL of the MCP server's SSE endpoint.
171
+ * @returns A promise that resolves to an MCPTransport instance for SSE.
172
+ */
173
+ export declare function createSSETransport(url: URL): Promise<MCPTransport>;
174
+ /**
175
+ * Creates a new MCP transport layer for Streamable HTTP communication.
176
+ * @param url - The URL of the MCP server's HTTP endpoint.
177
+ * @returns A promise that resolves to an MCPTransport instance for HTTP.
178
+ */
179
+ export declare function createHttpTransport(url: URL): Promise<MCPTransport>;
180
+ /**
181
+ * MCP server class for handling MCP protocol communication.
182
+ * Manages tool registration and execution.
183
+ */
184
+ export declare class MCPClient<T extends string> {
185
+ /** The unique identifier for this MCP server configuration. */
186
+ serverId: T;
187
+ /** Array storing discovered tool descriptors after connection. */
188
+ private tools;
189
+ /** The configuration object for this specific MCP server. */
190
+ private config;
191
+ /** The underlying client instance from the @modelcontextprotocol/sdk. */
192
+ private client;
193
+ /**
194
+ * Creates a new MCPClient instance.
195
+ * Validates the provided configuration.
196
+ *
197
+ * @param serverId - The unique identifier for this MCP server configuration.
198
+ * @param config - The configuration object for the server.
199
+ * @throws {McpError} If the configuration is invalid.
200
+ */
201
+ constructor(serverId: T, config: MCPServerConfig);
202
+ /**
203
+ * Connects to the MCP server using the configured transport.
204
+ * Establishes a connection based on the transport type (stdio or sse)
205
+ * and initializes the client with the appropriate transport layer.
206
+ * @returns {Promise<void>} A promise that resolves when the connection is established and tools (if any) are fetched.
207
+ * @throws {McpError} If connection fails or transport type is invalid
208
+ */
209
+ connect(): Promise<void>;
210
+ /**
211
+ * Fetches the list of tool descriptors from the connected MCP server.
212
+ * Should only be called after a successful connection.
213
+ *
214
+ * @returns {Promise<MCPToolDescriptor[]>} A promise resolving to an array of tool descriptors.
215
+ * @private
216
+ * @throws {McpError} If the client is not connected or the server response is invalid.
217
+ */
218
+ private fetchMCPToolDescriptors;
219
+ /**
220
+ * Validates the MCP server configuration using the Zod schema.
221
+ *
222
+ * @param serverName - The name/ID of the server (for logging).
223
+ * @param config - The configuration object to validate.
224
+ * @returns `true` if valid, `false` otherwise.
225
+ * @private
226
+ */
227
+ private validateMCPServerConfig;
228
+ /**
229
+ * Executes a specific tool on the connected MCP server.
230
+ *
231
+ * @param toolName - The name of the tool to execute.
232
+ * @param parameters - The parameters to pass to the tool.
233
+ * @returns A promise resolving with the result from the tool execution.
234
+ * @throws {McpError} If the client is not connected or the tool execution fails.
235
+ */
236
+ executeTool(toolName: string, parameters: Record<string, unknown>): Promise<unknown>;
237
+ /**
238
+ * Gets the list of discovered tool descriptors for this server.
239
+ * Tools are fetched during the `connect` method.
240
+ *
241
+ * @returns {MCPToolDescriptor[]} An array of discovered tool descriptors.
242
+ */
243
+ getTools(): MCPToolDescriptor[];
244
+ /**
245
+ * Gets the underlying protocol client instance.
246
+ * Primarily for internal use or specific low-level interactions.
247
+ *
248
+ * @returns {ProtocolClient} The raw protocol client instance.
249
+ */
250
+ getClient(): ProtocolClient;
251
+ }
252
+ /**
253
+ * Standard MCP error class with error codes following JSON-RPC spec.
254
+ * Useful for creating and identifying MCP-specific errors.
255
+ */
256
+ export declare class McpError extends Error {
257
+ /** The JSON-RPC error code. */
258
+ code: number;
259
+ /** Optional additional data related to the error. */
260
+ data?: unknown;
261
+ /**
262
+ * Constructs an McpError.
263
+ * @param code - The JSON-RPC error code (see MCPErrorCodes).
264
+ * @param message - A human-readable description of the error.
265
+ * @param data - Optional additional data related to the error.
266
+ */
267
+ constructor(code: number, message: string, data?: unknown);
268
+ }
269
+ /**
270
+ * MCP error codes following the JSON-RPC specification.
271
+ * Provides a standardized set of codes for common MCP errors.
272
+ */
273
+ export declare const MCPErrorCodes: {
274
+ /** Connection was closed. */
275
+ CONNECTION_CLOSED: number;
276
+ /** Request timed out. */
277
+ REQUEST_TIMEOUT: number;
278
+ /** Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. */
279
+ PARSE_ERROR: number;
280
+ /** The JSON sent is not a valid Request object. */
281
+ INVALID_REQUEST: number;
282
+ /** The method does not exist / is not available. */
283
+ METHOD_NOT_FOUND: number;
284
+ /** Invalid method parameter(s). */
285
+ INVALID_PARAMS: number;
286
+ /** Internal JSON-RPC error. */
287
+ INTERNAL_ERROR: number;
288
+ };
289
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,MAAM,MAAM,cAAc,GAAG,GAAG,CAAA;AAEhC,MAAM,MAAM,YAAY,GAAG,GAAG,CAAA;AAE9B;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAA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IAoB1F;;;;;OAKG;IACH,QAAQ,IAAI,iBAAiB,EAAE;IAI/B;;;;;OAKG;IACH,SAAS,IAAI,cAAc;CAG5B;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAM1D;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;IACxB,6BAA6B;;IAE7B,yBAAyB;;IAEzB,4GAA4G;;IAE5G,mDAAmD;;IAEnD,oDAAoD;;IAEpD,mCAAmC;;IAEnC,+BAA+B;;CAEhC,CAAA"}
package/dist/mcp.js ADDED
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCPErrorCodes = exports.McpError = exports.MCPClient = exports.mcpServerConfigSchema = exports.mcpServerConfigHttpSchema = exports.mcpServerConfigSseSchema = exports.mcpServerConfigStdioSchema = void 0;
4
+ exports.importClient = importClient;
5
+ exports.importStdioTransport = importStdioTransport;
6
+ exports.importSSETransport = importSSETransport;
7
+ exports.importHttpTransport = importHttpTransport;
8
+ exports.createClient = createClient;
9
+ exports.createStdioTransport = createStdioTransport;
10
+ exports.createSSETransport = createSSETransport;
11
+ exports.createHttpTransport = createHttpTransport;
12
+ const zod_1 = require("zod");
13
+ const logger_1 = require("./logger");
14
+ // Zod Schemas for MCP Server Configuration
15
+ /** Zod schema for validating MCP server configurations using 'stdio' transport. */
16
+ exports.mcpServerConfigStdioSchema = zod_1.z.object({
17
+ /** Specifies the transport type as 'stdio'. */
18
+ transport: zod_1.z.literal('stdio'),
19
+ /** The command to execute to start the server. */
20
+ command: zod_1.z.string().min(1, 'Command cannot be empty'),
21
+ /** Arguments to pass to the command. */
22
+ args: zod_1.z.array(zod_1.z.string()),
23
+ /** Optional environment variables for the command. */
24
+ env: zod_1.z.record(zod_1.z.string()).optional(),
25
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
26
+ autoRegisterTools: zod_1.z.boolean().optional()
27
+ });
28
+ /** Zod schema for validating MCP server configurations using 'sse' transport. */
29
+ exports.mcpServerConfigSseSchema = zod_1.z.object({
30
+ /** Specifies the transport type as 'sse'. */
31
+ transport: zod_1.z.literal('sse'),
32
+ /** The URL of the MCP server's SSE endpoint. */
33
+ url: zod_1.z.string().url('Invalid URL format for SSE transport'),
34
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
35
+ autoRegisterTools: zod_1.z.boolean().optional()
36
+ });
37
+ /** Zod schema for validating MCP server configurations using 'http' (Streamable HTTP) transport. */
38
+ exports.mcpServerConfigHttpSchema = zod_1.z.object({
39
+ /** Specifies the transport type as 'http'. */
40
+ transport: zod_1.z.literal('http'),
41
+ /** The URL of the MCP server's HTTP endpoint. */
42
+ url: zod_1.z.string().url('Invalid URL format for HTTP transport'),
43
+ /** Whether to automatically discover tools and register them as capabilities upon successful connection. Defaults to false. */
44
+ autoRegisterTools: zod_1.z.boolean().optional()
45
+ });
46
+ /**
47
+ * Discriminated union Zod schema for validating MCP server configurations.
48
+ * It differentiates based on the 'transport' property.
49
+ */
50
+ exports.mcpServerConfigSchema = zod_1.z.discriminatedUnion('transport', [
51
+ exports.mcpServerConfigStdioSchema,
52
+ exports.mcpServerConfigSseSchema,
53
+ exports.mcpServerConfigHttpSchema
54
+ ]);
55
+ /** Dynamically imports the MCP Client class from the MCP SDK. */
56
+ async function importClient() {
57
+ const { Client } = await import('@modelcontextprotocol/sdk/client/index.js');
58
+ return Client;
59
+ }
60
+ /** Dynamically imports the MCP StdioClientTransport class from the MCP SDK. */
61
+ async function importStdioTransport() {
62
+ const { StdioClientTransport } = await import('@modelcontextprotocol/sdk/client/stdio.js');
63
+ return StdioClientTransport;
64
+ }
65
+ /** Dynamically imports the MCP SSEClientTransport class from the MCP SDK. */
66
+ async function importSSETransport() {
67
+ const { SSEClientTransport } = await import('@modelcontextprotocol/sdk/client/sse.js');
68
+ return SSEClientTransport;
69
+ }
70
+ /** Dynamically imports the MCP StreamableHTTPClientTransport class from the MCP SDK. */
71
+ async function importHttpTransport() {
72
+ const { StreamableHTTPClientTransport } = await import('@modelcontextprotocol/sdk/client/streamableHttp.js');
73
+ return StreamableHTTPClientTransport;
74
+ }
75
+ /**
76
+ * Creates a new MCP client instance.
77
+ * @param name - The name of the client.
78
+ * @param version - The version of the client.
79
+ * @returns A promise that resolves to an MCPClient instance.
80
+ */
81
+ async function createClient(name, version) {
82
+ const Client = await importClient();
83
+ return new Client({ name, version });
84
+ }
85
+ /**
86
+ * Creates a new MCP transport layer for stdio communication.
87
+ * @param options - Configuration options for the stdio transport.
88
+ * @param options.command - The command to execute to start the server.
89
+ * @param options.args - Arguments to pass to the command.
90
+ * @param options.env - Optional environment variables for the command.
91
+ * @returns A promise that resolves to an MCPTransport instance for stdio.
92
+ */
93
+ async function createStdioTransport(options) {
94
+ const StdioClientTransport = await importStdioTransport();
95
+ return new StdioClientTransport(options);
96
+ }
97
+ /**
98
+ * Creates a new MCP transport layer for Server-Sent Events (SSE) communication.
99
+ * @param url - The URL of the MCP server's SSE endpoint.
100
+ * @returns A promise that resolves to an MCPTransport instance for SSE.
101
+ */
102
+ async function createSSETransport(url) {
103
+ const SSEClientTransport = await importSSETransport();
104
+ return new SSEClientTransport(url);
105
+ }
106
+ /**
107
+ * Creates a new MCP transport layer for Streamable HTTP communication.
108
+ * @param url - The URL of the MCP server's HTTP endpoint.
109
+ * @returns A promise that resolves to an MCPTransport instance for HTTP.
110
+ */
111
+ async function createHttpTransport(url) {
112
+ const StreamableHTTPClientTransport = await importHttpTransport();
113
+ return new StreamableHTTPClientTransport(url);
114
+ }
115
+ /**
116
+ * MCP server class for handling MCP protocol communication.
117
+ * Manages tool registration and execution.
118
+ */
119
+ class MCPClient {
120
+ /** The unique identifier for this MCP server configuration. */
121
+ serverId;
122
+ /** Array storing discovered tool descriptors after connection. */
123
+ tools = [];
124
+ /** The configuration object for this specific MCP server. */
125
+ config;
126
+ /** The underlying client instance from the @modelcontextprotocol/sdk. */
127
+ client;
128
+ /**
129
+ * Creates a new MCPClient instance.
130
+ * Validates the provided configuration.
131
+ *
132
+ * @param serverId - The unique identifier for this MCP server configuration.
133
+ * @param config - The configuration object for the server.
134
+ * @throws {McpError} If the configuration is invalid.
135
+ */
136
+ constructor(serverId, config) {
137
+ this.config = config;
138
+ this.serverId = serverId;
139
+ if (!this.validateMCPServerConfig(this.serverId, this.config)) {
140
+ throw new McpError(exports.MCPErrorCodes.INVALID_PARAMS, `Invalid configuration for MCP server "${this.serverId}". Check logs for details.`);
141
+ }
142
+ }
143
+ /**
144
+ * Connects to the MCP server using the configured transport.
145
+ * Establishes a connection based on the transport type (stdio or sse)
146
+ * and initializes the client with the appropriate transport layer.
147
+ * @returns {Promise<void>} A promise that resolves when the connection is established and tools (if any) are fetched.
148
+ * @throws {McpError} If connection fails or transport type is invalid
149
+ */
150
+ async connect() {
151
+ let transport;
152
+ const transportType = this.config.transport;
153
+ try {
154
+ logger_1.logger.info(`Connecting to MCP server "${this.serverId}" using ${transportType}...`);
155
+ if (this.config.transport === 'sse') {
156
+ transport = await createSSETransport(new URL(this.config.url));
157
+ }
158
+ else if (this.config.transport === 'http') {
159
+ transport = await createHttpTransport(new URL(this.config.url));
160
+ }
161
+ else if (this.config.transport === 'stdio') {
162
+ transport = await createStdioTransport({
163
+ command: this.config.command,
164
+ args: this.config.args,
165
+ env: this.config.env
166
+ });
167
+ }
168
+ if (!transport) {
169
+ throw new McpError(exports.MCPErrorCodes.INTERNAL_ERROR, `Transport could not be initialized for "${this.serverId}" with type ${transportType}.`);
170
+ }
171
+ this.client = await createClient(`agent-${this.serverId}`, '1.0.0');
172
+ this.client.connect(transport);
173
+ // Wait for the server to be ready
174
+ await new Promise(resolve => setTimeout(resolve, 5000));
175
+ logger_1.logger.info(`Successfully connected to MCP server "${this.serverId}"`);
176
+ this.tools = await this.fetchMCPToolDescriptors();
177
+ }
178
+ catch (error) {
179
+ if (this.client)
180
+ this.client.disconnect();
181
+ if (error instanceof McpError) {
182
+ throw error;
183
+ }
184
+ throw new McpError(exports.MCPErrorCodes.INTERNAL_ERROR, `Failed to connect to MCP server "${this.serverId}" using ${transportType}: ${error instanceof Error ? error.message : String(error)}`);
185
+ }
186
+ }
187
+ /**
188
+ * Fetches the list of tool descriptors from the connected MCP server.
189
+ * Should only be called after a successful connection.
190
+ *
191
+ * @returns {Promise<MCPToolDescriptor[]>} A promise resolving to an array of tool descriptors.
192
+ * @private
193
+ * @throws {McpError} If the client is not connected or the server response is invalid.
194
+ */
195
+ async fetchMCPToolDescriptors() {
196
+ if (!this.client) {
197
+ throw new McpError(exports.MCPErrorCodes.INVALID_PARAMS, `Cannot fetch tool descriptors: No active client found for server "${this.serverId}". Ensure connection was successful.`);
198
+ }
199
+ // Request tool list
200
+ const response = await this.client.listTools();
201
+ if (!response || !Array.isArray(response.tools)) {
202
+ logger_1.logger.warn(`No tools returned from "${this.serverId}"`);
203
+ return [];
204
+ }
205
+ return response.tools;
206
+ }
207
+ /**
208
+ * Validates the MCP server configuration using the Zod schema.
209
+ *
210
+ * @param serverName - The name/ID of the server (for logging).
211
+ * @param config - The configuration object to validate.
212
+ * @returns `true` if valid, `false` otherwise.
213
+ * @private
214
+ */
215
+ validateMCPServerConfig(serverName, config) {
216
+ const result = exports.mcpServerConfigSchema.safeParse(config);
217
+ if (!result.success) {
218
+ logger_1.logger.error(`Invalid configuration for MCP server "${serverName}". Errors: `, result.error.flatten());
219
+ return false;
220
+ }
221
+ return true;
222
+ }
223
+ /**
224
+ * Executes a specific tool on the connected MCP server.
225
+ *
226
+ * @param toolName - The name of the tool to execute.
227
+ * @param parameters - The parameters to pass to the tool.
228
+ * @returns A promise resolving with the result from the tool execution.
229
+ * @throws {McpError} If the client is not connected or the tool execution fails.
230
+ */
231
+ async executeTool(toolName, parameters) {
232
+ if (!this.client) {
233
+ throw new McpError(exports.MCPErrorCodes.CONNECTION_CLOSED, 'Client not connected or initialized');
234
+ }
235
+ try {
236
+ const result = await this.client.callTool({
237
+ name: toolName,
238
+ arguments: parameters
239
+ });
240
+ return result;
241
+ }
242
+ catch (e) {
243
+ throw new McpError(exports.MCPErrorCodes.INTERNAL_ERROR, `Failed to execute tool ${toolName} on server ${this.serverId}: ${e instanceof Error ? e.message : String(e)}`);
244
+ }
245
+ }
246
+ /**
247
+ * Gets the list of discovered tool descriptors for this server.
248
+ * Tools are fetched during the `connect` method.
249
+ *
250
+ * @returns {MCPToolDescriptor[]} An array of discovered tool descriptors.
251
+ */
252
+ getTools() {
253
+ return this.tools;
254
+ }
255
+ /**
256
+ * Gets the underlying protocol client instance.
257
+ * Primarily for internal use or specific low-level interactions.
258
+ *
259
+ * @returns {ProtocolClient} The raw protocol client instance.
260
+ */
261
+ getClient() {
262
+ return this.client;
263
+ }
264
+ }
265
+ exports.MCPClient = MCPClient;
266
+ /**
267
+ * Standard MCP error class with error codes following JSON-RPC spec.
268
+ * Useful for creating and identifying MCP-specific errors.
269
+ */
270
+ class McpError extends Error {
271
+ /** The JSON-RPC error code. */
272
+ code;
273
+ /** Optional additional data related to the error. */
274
+ data;
275
+ /**
276
+ * Constructs an McpError.
277
+ * @param code - The JSON-RPC error code (see MCPErrorCodes).
278
+ * @param message - A human-readable description of the error.
279
+ * @param data - Optional additional data related to the error.
280
+ */
281
+ constructor(code, message, data) {
282
+ super(`MCP error ${code}: ${message}`);
283
+ this.name = 'McpError';
284
+ this.code = code;
285
+ this.data = data;
286
+ }
287
+ }
288
+ exports.McpError = McpError;
289
+ /**
290
+ * MCP error codes following the JSON-RPC specification.
291
+ * Provides a standardized set of codes for common MCP errors.
292
+ */
293
+ exports.MCPErrorCodes = {
294
+ /** Connection was closed. */
295
+ CONNECTION_CLOSED: -32000,
296
+ /** Request timed out. */
297
+ REQUEST_TIMEOUT: -32001,
298
+ /** Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. */
299
+ PARSE_ERROR: -32700,
300
+ /** The JSON sent is not a valid Request object. */
301
+ INVALID_REQUEST: -32600,
302
+ /** The method does not exist / is not available. */
303
+ METHOD_NOT_FOUND: -32601,
304
+ /** Invalid method parameter(s). */
305
+ INVALID_PARAMS: -32602,
306
+ /** Internal JSON-RPC error. */
307
+ INTERNAL_ERROR: -32603
308
+ };
package/dist/types.d.ts CHANGED
@@ -113,7 +113,7 @@ export declare const doTaskActionSchema: z.ZodObject<{
113
113
  };
114
114
  }>, z.ZodObject<{
115
115
  type: z.ZodLiteral<"project-manager-plan-review">;
116
- question: z.ZodObject<z.objectUtil.extendShape<{
116
+ question: z.ZodObject<{
117
117
  tasks: z.ZodArray<z.ZodObject<{
118
118
  index: z.ZodNumber;
119
119
  assigneeAgentId: z.ZodNumber;
@@ -139,9 +139,9 @@ export declare const doTaskActionSchema: z.ZodObject<{
139
139
  taskDescription: string;
140
140
  taskBody: string;
141
141
  }>, "many">;
142
- }, {
142
+ } & {
143
143
  type: z.ZodLiteral<"project-manager-plan-review">;
144
- }>, "strip", z.ZodTypeAny, {
144
+ }, "strip", z.ZodTypeAny, {
145
145
  type: "project-manager-plan-review";
146
146
  tasks: {
147
147
  expectedOutput: string;
@@ -377,6 +377,7 @@ export declare const doTaskActionSchema: z.ZodObject<{
377
377
  capabilities_description: string;
378
378
  }[];
379
379
  }>;
380
+ workspaceExecutionId: z.ZodOptional<z.ZodNumber>;
380
381
  integrations: z.ZodArray<z.ZodObject<{
381
382
  id: z.ZodNumber;
382
383
  connection_id: z.ZodString;
@@ -526,6 +527,7 @@ export declare const doTaskActionSchema: z.ZodObject<{
526
527
  memory: string;
527
528
  createdAt: Date;
528
529
  }[];
530
+ workspaceExecutionId?: number | undefined;
529
531
  }, {
530
532
  type: "do-task";
531
533
  me: {
@@ -619,9 +621,11 @@ export declare const doTaskActionSchema: z.ZodObject<{
619
621
  memory: string;
620
622
  createdAt: Date;
621
623
  }[];
624
+ workspaceExecutionId?: number | undefined;
622
625
  }>;
623
626
  export declare const respondChatMessageActionSchema: z.ZodObject<{
624
627
  type: z.ZodLiteral<"respond-chat-message">;
628
+ workspaceExecutionId: z.ZodOptional<z.ZodNumber>;
625
629
  me: z.ZodIntersection<z.ZodObject<{
626
630
  id: z.ZodNumber;
627
631
  name: z.ZodString;
@@ -804,6 +808,7 @@ export declare const respondChatMessageActionSchema: z.ZodObject<{
804
808
  createdAt: Date;
805
809
  author: "agent" | "user";
806
810
  }[];
811
+ workspaceExecutionId?: number | undefined;
807
812
  }, {
808
813
  type: "respond-chat-message";
809
814
  me: {
@@ -850,6 +855,7 @@ export declare const respondChatMessageActionSchema: z.ZodObject<{
850
855
  createdAt: Date;
851
856
  author: "agent" | "user";
852
857
  }[];
858
+ workspaceExecutionId?: number | undefined;
853
859
  }>;
854
860
  export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
855
861
  type: z.ZodLiteral<"do-task">;
@@ -957,7 +963,7 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
957
963
  };
958
964
  }>, z.ZodObject<{
959
965
  type: z.ZodLiteral<"project-manager-plan-review">;
960
- question: z.ZodObject<z.objectUtil.extendShape<{
966
+ question: z.ZodObject<{
961
967
  tasks: z.ZodArray<z.ZodObject<{
962
968
  index: z.ZodNumber;
963
969
  assigneeAgentId: z.ZodNumber;
@@ -983,9 +989,9 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
983
989
  taskDescription: string;
984
990
  taskBody: string;
985
991
  }>, "many">;
986
- }, {
992
+ } & {
987
993
  type: z.ZodLiteral<"project-manager-plan-review">;
988
- }>, "strip", z.ZodTypeAny, {
994
+ }, "strip", z.ZodTypeAny, {
989
995
  type: "project-manager-plan-review";
990
996
  tasks: {
991
997
  expectedOutput: string;
@@ -1221,6 +1227,7 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
1221
1227
  capabilities_description: string;
1222
1228
  }[];
1223
1229
  }>;
1230
+ workspaceExecutionId: z.ZodOptional<z.ZodNumber>;
1224
1231
  integrations: z.ZodArray<z.ZodObject<{
1225
1232
  id: z.ZodNumber;
1226
1233
  connection_id: z.ZodString;
@@ -1370,6 +1377,7 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
1370
1377
  memory: string;
1371
1378
  createdAt: Date;
1372
1379
  }[];
1380
+ workspaceExecutionId?: number | undefined;
1373
1381
  }, {
1374
1382
  type: "do-task";
1375
1383
  me: {
@@ -1463,8 +1471,10 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
1463
1471
  memory: string;
1464
1472
  createdAt: Date;
1465
1473
  }[];
1474
+ workspaceExecutionId?: number | undefined;
1466
1475
  }>, z.ZodObject<{
1467
1476
  type: z.ZodLiteral<"respond-chat-message">;
1477
+ workspaceExecutionId: z.ZodOptional<z.ZodNumber>;
1468
1478
  me: z.ZodIntersection<z.ZodObject<{
1469
1479
  id: z.ZodNumber;
1470
1480
  name: z.ZodString;
@@ -1647,6 +1657,7 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
1647
1657
  createdAt: Date;
1648
1658
  author: "agent" | "user";
1649
1659
  }[];
1660
+ workspaceExecutionId?: number | undefined;
1650
1661
  }, {
1651
1662
  type: "respond-chat-message";
1652
1663
  me: {
@@ -1693,6 +1704,7 @@ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
1693
1704
  createdAt: Date;
1694
1705
  author: "agent" | "user";
1695
1706
  }[];
1707
+ workspaceExecutionId?: number | undefined;
1696
1708
  }>]>;
1697
1709
  declare const agentChatMessagesResponseSchema: z.ZodObject<{
1698
1710
  agent: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO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,GAAG,QAAQ,CAAA;IAClG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACjD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC/E,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,kBAAkB,CAAA;CAC5B"}
package/dist/types.js CHANGED
@@ -120,6 +120,7 @@ exports.doTaskActionSchema = zod_1.z
120
120
  capabilities_description: zod_1.z.string()
121
121
  }))
122
122
  }),
123
+ workspaceExecutionId: zod_1.z.number().optional(),
123
124
  integrations: zod_1.z.array(zod_1.z.object({
124
125
  id: zod_1.z.number(),
125
126
  connection_id: zod_1.z.string(),
@@ -143,6 +144,7 @@ exports.doTaskActionSchema = zod_1.z
143
144
  exports.respondChatMessageActionSchema = zod_1.z
144
145
  .object({
145
146
  type: zod_1.z.literal('respond-chat-message'),
147
+ workspaceExecutionId: zod_1.z.number().optional(),
146
148
  me: zod_1.z.intersection(zod_1.z.object({
147
149
  id: zod_1.z.number(),
148
150
  name: zod_1.z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openserv-labs/sdk",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "OpenServ Agent SDK - Create AI agents easily",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,8 @@
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
44
  "@asteasolutions/zod-to-openapi": "^7.3.0",
45
+ "@modelcontextprotocol/sdk": "^1.10.2",
46
+ "@n8n/json-schema-to-zod": "^1.1.0",
45
47
  "axios": "^1.6.8",
46
48
  "axios-retry": "^4.1.0",
47
49
  "bcryptjs": "^3.0.2",