@cogitator-ai/mcp 19.2.10 → 19.3.1

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
@@ -183,15 +183,17 @@ interface MCPRetryConfig {
183
183
 
184
184
  #### Automatic Retry Behavior
185
185
 
186
- All MCP operations (`listToolDefinitions`, `callTool`, `listResources`, `readResource`, `readResourceContents`, `listPrompts`, `getPrompt`) automatically retry on transient failures:
186
+ Requests that are safe to send twice (`listToolDefinitions`, `listResources`, `readResource`, `readResourceContents`, `listPrompts`, `getPrompt`) automatically retry on transient failures:
187
187
 
188
188
  - Connection errors (ECONNREFUSED, ECONNRESET, closed connections)
189
189
  - Request timeouts
190
190
  - Network failures
191
191
 
192
+ A tool call is different: after a timeout or a lost connection the server may still be running it, or may have finished it, and a second call could deploy twice or send a second email. So `callTool` sends a call once and throws `MCPToolInterruptedError` (`reason: 'timeout' | 'connection-lost'`) instead of retrying, unless the call is marked `idempotent: true`. Tools from `getTools()` / `wrapMCPTools()` set `idempotent` from the server's tool annotations: a tool with `readOnlyHint` or `idempotentHint` is retried like a read, any other is not. A connection lost by an earlier call is restored before the next call is sent.
193
+
192
194
  Deterministic failures are **not** retried: JSON-RPC protocol errors from the server (invalid params, unknown tool, internal handler errors), tool results with `isError: true`, and calls whose `signal` was aborted fail immediately.
193
195
 
194
- When a connection error is detected (with `autoReconnect` and `retryOnConnectionLoss` on, the defaults), the client will:
196
+ When a connection error is detected on a retried request (with `autoReconnect` and `retryOnConnectionLoss` on, the defaults), the client will:
195
197
 
196
198
  1. Close the existing connection
197
199
  2. Create a new transport and client
@@ -244,6 +246,8 @@ const result = await client.callTool('tool_name', { arg: 'value' });
244
246
  const controller = new AbortController();
245
247
  await client.callTool('slow_tool', {}, { signal: controller.signal, timeout: 10_000 });
246
248
 
249
+ await client.callTool('get_status', {}, { idempotent: true });
250
+
247
251
  const resources = await client.listResources();
248
252
 
249
253
  const content = await client.readResource('file://path/to/file');
@@ -259,7 +263,7 @@ await client.close();
259
263
 
260
264
  ### Tool Results and Errors
261
265
 
262
- `callTool` returns the server's `structuredContent` when present; otherwise the content blocks are unwrapped — text blocks are JSON-parsed when possible (other blocks stay as content objects), a single block's value is returned on its own, multiple blocks are returned as an array, and an empty result is `null`.
266
+ `callTool` returns the server's `structuredContent` when present, otherwise text blocks are unwrapped: JSON-parsed when possible, a single block's value on its own, several as an array, and an empty result is `null`. Content with images, audio or binary resources comes back as a `toolContent()` result of `@cogitator-ai/core` (images as `image` parts, audio and blobs as `file` parts), so an agent's model sees a screenshot as an image instead of base64 text, and audio stays out of the context. A link to a resource becomes a line of text.
263
267
 
264
268
  When the server reports a tool failure (`isError: true`), `callTool` throws an `MCPToolError` carrying the tool name and the original content blocks. Tools produced by `getTools()` / `wrapMCPTools()` therefore surface MCP tool failures as regular Cogitator tool errors, and they forward the run's abort signal to the server.
265
269
 
@@ -343,10 +347,14 @@ interface MCPServerConfig {
343
347
  sessions?: boolean; // Session per client (needed for elicitation); default: off
344
348
 
345
349
  logging?: boolean; // Diagnostic logging to stderr (stdout stays clean for stdio JSON-RPC)
350
+
351
+ toolInvoker?: ToolInvoker; // Runs tool calls, e.g. your Cogitator; default: one of its own
346
352
  }
347
353
  ```
348
354
 
349
- Tool arguments are validated by the MCP SDK against the tool's full Zod schema (including refinements, transforms and object modifiers such as `z.looseObject`). Invalid arguments and thrown errors are returned to the client as `isError` tool results. Errors thrown by resource `read` and prompt `get` handlers are returned as JSON-RPC errors.
355
+ Tool calls run the way an agent run executes them, through a `ToolInvoker` (`cogitator.invokeTool()`): the arguments are validated, a tool with `requiresApproval` (or one the guardrails flag) is asked from the person at the client through MCP elicitation, the guardrails apply, sandboxed tools run in the sandbox and `tool.timeout` holds. Pass your `Cogitator` as `toolInvoker` so its sandbox and guardrails are the ones used, otherwise the server uses a Cogitator of its own without configuration. A call that needs approval when nobody can be asked (a client without elicitation, or HTTP without `sessions: true`) does not run: it comes back as an `isError` result that says so, unless the invoker's `guardrails.onToolApproval` decides it.
356
+
357
+ Tool arguments are validated once, by the MCP SDK against the tool's full Zod schema (including refinements, transforms and object modifiers such as `z.looseObject`). Invalid arguments and thrown errors are returned to the client as `isError` tool results. Errors thrown by resource `read` and prompt `get` handlers are returned as JSON-RPC errors.
350
358
 
351
359
  ### Server Methods
352
360
 
@@ -638,12 +646,13 @@ Create a script that Claude Desktop can execute:
638
646
  ```typescript
639
647
  // serve-tools.ts
640
648
  import { serveMCPTools } from '@cogitator-ai/mcp';
641
- import { builtinTools } from '@cogitator-ai/core';
649
+ import { Cogitator, calculator, datetime, webSearch } from '@cogitator-ai/core';
642
650
 
643
- await serveMCPTools([...builtinTools], {
651
+ await serveMCPTools([calculator, datetime, webSearch], {
644
652
  name: 'cogitator-tools',
645
653
  version: '1.0.0',
646
654
  transport: 'stdio',
655
+ toolInvoker: new Cogitator({ sandbox: { allowNativeFallback: false } }),
647
656
  });
648
657
  ```
649
658
 
@@ -752,6 +761,10 @@ const tools = await wrapMCPTools(client, {
752
761
 
753
762
  The prefix only renames the Cogitator tool; calls still go to the server under the original name, with the run's abort signal.
754
763
 
764
+ Tool names are made safe for every LLM provider (letters, digits, `_` and `-`, at most 64 characters): `admin.list_users` becomes `admin_list_users`, a longer name is cut and ends with a hash of the full one, and two names of a server that would end up the same (`files.read`, `files_read`) are told apart by a hash on the changed one. `normalizeMCPToolName(name)` gives the name a tool gets. When an agent uses several servers, give each its own `namePrefix`, since two servers can both have a `search` tool: the registry warns when two tools of an agent share a name, and only one of them would reach the model.
765
+
766
+ Input schemas with `$ref` (such as a FastMCP tool with a nested Pydantic model) keep their definitions: the model sees the full schema and arguments are validated against it, recursive definitions included.
767
+
755
768
  ### Adapter Options
756
769
 
757
770
  ```typescript
@@ -1067,7 +1080,7 @@ const textResult = resultToMCPContent('Hello world');
1067
1080
  // [{ type: 'text', text: 'Hello world' }]
1068
1081
  ```
1069
1082
 
1070
- A tool result that is already an array of MCP content blocks (text, image, audio, resource) is passed through unchanged, so a served tool can return images or embedded resources; `null`/`undefined` becomes an empty text block.
1083
+ A tool result that is already an array of MCP content blocks (text, image, audio, resource) is passed through unchanged, so a served tool can return images or embedded resources, `null`/`undefined` becomes an empty text block. A `toolContent()` result, and an object with a base64 `image` such as a browser screenshot, becomes text and image blocks, with `file` parts as audio blocks (`audio/*`) or embedded resource blobs.
1071
1084
 
1072
1085
  ---
1073
1086
 
@@ -19,16 +19,20 @@ export declare function zodToJsonSchema(schema: ZodTypeAny): {
19
19
  /**
20
20
  * Convert JSON Schema to a Zod schema
21
21
  *
22
- * Note: This is a simplified conversion that handles common cases.
23
- * Complex schemas may need manual adjustment.
22
+ * Handles the keywords tool schemas use: types, enums, constants, unions, intersections, nested
23
+ * objects and arrays, string and number bounds, and local `$ref`s to `$defs` / `definitions`
24
+ * (or any `#/...` pointer), recursive ones included.
24
25
  */
25
26
  export declare function jsonSchemaToZod(schema: {
26
27
  type: string;
27
28
  properties?: Record<string, JsonSchemaProperty>;
28
29
  required?: string[];
29
30
  additionalProperties?: boolean | JsonSchemaProperty;
31
+ $defs?: Record<string, JsonSchemaProperty>;
32
+ definitions?: Record<string, JsonSchemaProperty>;
30
33
  }): ZodObject<Record<string, ZodTypeAny>, z.core.$ZodObjectConfig>;
31
34
  interface JsonSchemaProperty {
35
+ $ref?: string;
32
36
  type?: string | string[];
33
37
  const?: unknown;
34
38
  nullable?: boolean;
@@ -54,22 +58,40 @@ interface JsonSchemaProperty {
54
58
  */
55
59
  export declare function cogitatorToMCP(tool: Tool): MCPToolDefinition;
56
60
  /**
57
- * Convert a Cogitator ToolSchema to MCP tool definition format
61
+ * Convert a Cogitator ToolSchema to MCP tool definition format. The input schema keeps every
62
+ * keyword, `$defs` included, made self-contained by `toToolParameters`.
58
63
  */
59
64
  export declare function toolSchemaToMCP(schema: ToolSchema): MCPToolDefinition;
65
+ /**
66
+ * A tool name every LLM provider accepts: letters, digits, `_` and `-`, starting with a letter or
67
+ * `_`, at most 64 characters (the strictest of the OpenAI, Anthropic, Gemini and Bedrock rules).
68
+ * A valid name is kept as it is. Other characters, such as the dots of `admin.list_users`,
69
+ * become `_`, and a name too long is cut and ends with a hash of the full name, so different
70
+ * names stay different.
71
+ */
72
+ export declare function normalizeMCPToolName(name: string): string;
60
73
  /**
61
74
  * Convert an MCP tool definition to a Cogitator Tool
62
75
  *
63
- * The resulting tool will execute calls through the provided MCPClient.
76
+ * The resulting tool will execute calls through the provided MCPClient, under the tool's original
77
+ * name. The Cogitator name is `namePrefix` plus the MCP name, normalized for LLM providers (see
78
+ * `normalizeMCPToolName`). Calls are retried after a timeout only when the server marks the tool
79
+ * read-only or idempotent.
64
80
  */
65
- export declare function mcpToCogitator(mcpTool: MCPToolDefinition, client: MCPClient, options?: ToolAdapterOptions): Tool;
81
+ export declare function mcpToCogitator(mcpTool: MCPToolDefinition, client: MCPClient, options?: ToolAdapterOptions & {
82
+ /** The Cogitator name to use instead of the normalized one */
83
+ name?: string;
84
+ }): Tool;
66
85
  /**
67
86
  * Wrap all tools from an MCP client as Cogitator tools
68
87
  *
88
+ * Names are normalized for LLM providers and kept distinct. Give each server its own
89
+ * `namePrefix` when an agent uses several servers whose tools could share names.
90
+ *
69
91
  * @example
70
92
  * ```typescript
71
93
  * const client = await MCPClient.connect({ ... });
72
- * const tools = await wrapMCPTools(client);
94
+ * const tools = await wrapMCPTools(client, { namePrefix: 'github_' });
73
95
  *
74
96
  * const agent = new Agent({
75
97
  * tools: [...tools, ...otherTools],
@@ -78,11 +100,16 @@ export declare function mcpToCogitator(mcpTool: MCPToolDefinition, client: MCPCl
78
100
  */
79
101
  export declare function wrapMCPTools(client: MCPClient, options?: ToolAdapterOptions): Promise<Tool[]>;
80
102
  /**
81
- * Convert a tool execution result to MCP content format
103
+ * Convert a tool execution result to MCP content format. A result with media (`toolContent()`,
104
+ * or an object with a base64 `image` such as a browser screenshot) becomes text, image, audio
105
+ * and resource blocks instead of JSON text.
82
106
  */
83
107
  export declare function resultToMCPContent(result: unknown): MCPToolContent[];
84
108
  /**
85
- * Convert MCP content to a simple result value
109
+ * Convert MCP content to a simple result value: the text (parsed as JSON when it is JSON) of a
110
+ * single block, an array of values for several text blocks, and a `toolContent()` result when
111
+ * there are images, audio or binary resources, so they reach the model as media instead of
112
+ * base64 text.
86
113
  */
87
114
  export declare function mcpContentToResult(content: MCPToolContent[]): unknown;
88
115
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"tool-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/tool-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAe,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG;IACnD,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAeA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC;CACrD,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAmCjE;AAED,UAAU,kBAAkB;IAC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1B,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAAG;IAC7B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACA,IAAI,CAgCN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,CAMjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,EAAE,CAuBpE;AAkDD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAwBrE"}
@@ -4,7 +4,9 @@
4
4
  * Converts between Cogitator Tool format and MCP Tool format.
5
5
  * Enables bidirectional interoperability.
6
6
  */
7
+ import { createHash } from 'node:crypto';
7
8
  import { z } from 'zod';
9
+ import { toToolParameters, toolContent, toolResultParts } from '@cogitator-ai/core';
8
10
  /**
9
11
  * Convert a Zod schema to JSON Schema
10
12
  */
@@ -21,10 +23,14 @@ export function zodToJsonSchema(schema) {
21
23
  /**
22
24
  * Convert JSON Schema to a Zod schema
23
25
  *
24
- * Note: This is a simplified conversion that handles common cases.
25
- * Complex schemas may need manual adjustment.
26
+ * Handles the keywords tool schemas use: types, enums, constants, unions, intersections, nested
27
+ * objects and arrays, string and number bounds, and local `$ref`s to `$defs` / `definitions`
28
+ * (or any `#/...` pointer), recursive ones included.
26
29
  */
27
30
  export function jsonSchemaToZod(schema) {
31
+ return objectSchemaToZod(schema, { root: schema, refs: new Map() });
32
+ }
33
+ function objectSchemaToZod(schema, ctx) {
28
34
  if (schema.type !== 'object') {
29
35
  return z.object({});
30
36
  }
@@ -34,7 +40,7 @@ export function jsonSchemaToZod(schema) {
34
40
  const shape = {};
35
41
  const required = new Set(schema.required ?? []);
36
42
  for (const [key, prop] of Object.entries(schema.properties)) {
37
- let zodType = jsonSchemaPropertyToZod(prop);
43
+ let zodType = jsonSchemaPropertyToZod(prop, ctx);
38
44
  if (prop.description) {
39
45
  zodType = zodType.describe(prop.description);
40
46
  }
@@ -50,7 +56,7 @@ export function jsonSchemaToZod(schema) {
50
56
  return z.looseObject(shape);
51
57
  }
52
58
  if (typeof schema.additionalProperties === 'object' && schema.additionalProperties !== null) {
53
- return z.object(shape).catchall(jsonSchemaPropertyToZod(schema.additionalProperties));
59
+ return z.object(shape).catchall(jsonSchemaPropertyToZod(schema.additionalProperties, ctx));
54
60
  }
55
61
  return z.object(shape);
56
62
  }
@@ -60,13 +66,45 @@ function isJsonLiteral(value) {
60
66
  typeof value === 'number' ||
61
67
  typeof value === 'boolean');
62
68
  }
63
- function jsonSchemaPropertyToZod(prop) {
64
- const schema = jsonSchemaPropertyToZodInner(prop);
69
+ function jsonSchemaPropertyToZod(prop, ctx) {
70
+ const schema = jsonSchemaPropertyToZodInner(prop, ctx);
65
71
  return prop.nullable === true ? schema.nullable() : schema;
66
72
  }
67
- function jsonSchemaPropertyToZodInner(prop) {
73
+ /**
74
+ * The schema a local `$ref` points to. It is built once per ref and wrapped in `z.lazy`, so a
75
+ * definition that refers to itself (a tree, a linked list) validates to any depth.
76
+ */
77
+ function refToZod(ref, ctx) {
78
+ const cached = ctx.refs.get(ref);
79
+ if (cached)
80
+ return cached;
81
+ const target = resolvePointer(ctx.root, ref);
82
+ if (target === undefined)
83
+ return z.unknown();
84
+ let built;
85
+ const lazy = z.lazy(() => built ?? z.unknown());
86
+ ctx.refs.set(ref, lazy);
87
+ built = jsonSchemaPropertyToZod(target, ctx);
88
+ return lazy;
89
+ }
90
+ function resolvePointer(root, ref) {
91
+ if (!ref.startsWith('#'))
92
+ return undefined;
93
+ let node = root;
94
+ for (const raw of ref.slice(1).split('/').filter(Boolean)) {
95
+ const segment = decodeURIComponent(raw).replace(/~1/g, '/').replace(/~0/g, '~');
96
+ if (typeof node !== 'object' || node === null || !(segment in node))
97
+ return undefined;
98
+ node = node[segment];
99
+ }
100
+ return typeof node === 'object' && node !== null ? node : undefined;
101
+ }
102
+ function jsonSchemaPropertyToZodInner(prop, ctx) {
103
+ if (typeof prop.$ref === 'string') {
104
+ return refToZod(prop.$ref, ctx);
105
+ }
68
106
  if (Array.isArray(prop.type)) {
69
- const variants = prop.type.map((type) => jsonSchemaPropertyToZodInner({ ...prop, type }));
107
+ const variants = prop.type.map((type) => jsonSchemaPropertyToZodInner({ ...prop, type }, ctx));
70
108
  if (variants.length === 0) {
71
109
  return z.unknown();
72
110
  }
@@ -79,12 +117,12 @@ function jsonSchemaPropertyToZodInner(prop) {
79
117
  return z.literal(prop.const);
80
118
  }
81
119
  if (prop.allOf && prop.allOf.length > 0) {
82
- const schemas = prop.allOf.map((variant) => jsonSchemaPropertyToZod(variant));
120
+ const schemas = prop.allOf.map((variant) => jsonSchemaPropertyToZod(variant, ctx));
83
121
  return schemas.reduce((acc, schema) => z.intersection(acc, schema));
84
122
  }
85
123
  const unionVariants = prop.oneOf ?? prop.anyOf;
86
124
  if (unionVariants && unionVariants.length > 0) {
87
- const schemas = unionVariants.map((variant) => jsonSchemaPropertyToZod(variant));
125
+ const schemas = unionVariants.map((variant) => jsonSchemaPropertyToZod(variant, ctx));
88
126
  if (schemas.length === 1) {
89
127
  return schemas[0];
90
128
  }
@@ -138,20 +176,20 @@ function jsonSchemaPropertyToZodInner(prop) {
138
176
  case 'boolean':
139
177
  return z.boolean();
140
178
  case 'array': {
141
- const itemSchema = prop.items ? jsonSchemaPropertyToZod(prop.items) : z.unknown();
179
+ const itemSchema = prop.items ? jsonSchemaPropertyToZod(prop.items, ctx) : z.unknown();
142
180
  return z.array(itemSchema);
143
181
  }
144
182
  case 'object': {
145
183
  if (prop.properties) {
146
- return jsonSchemaToZod({
184
+ return objectSchemaToZod({
147
185
  type: 'object',
148
186
  properties: prop.properties,
149
187
  required: prop.required,
150
188
  additionalProperties: prop.additionalProperties,
151
- });
189
+ }, ctx);
152
190
  }
153
191
  if (typeof prop.additionalProperties === 'object' && prop.additionalProperties !== null) {
154
- return z.record(z.string(), jsonSchemaPropertyToZod(prop.additionalProperties));
192
+ return z.record(z.string(), jsonSchemaPropertyToZod(prop.additionalProperties, ctx));
155
193
  }
156
194
  return z.record(z.string(), z.unknown());
157
195
  }
@@ -178,49 +216,82 @@ function compilePattern(pattern) {
178
216
  * Convert a Cogitator Tool to MCP tool definition format
179
217
  */
180
218
  export function cogitatorToMCP(tool) {
181
- const schema = tool.toJSON();
182
- return {
183
- name: schema.name,
184
- description: schema.description,
185
- inputSchema: {
186
- type: 'object',
187
- properties: schema.parameters.properties,
188
- required: schema.parameters.required,
189
- },
190
- };
219
+ return toolSchemaToMCP(tool.toJSON());
191
220
  }
192
221
  /**
193
- * Convert a Cogitator ToolSchema to MCP tool definition format
222
+ * Convert a Cogitator ToolSchema to MCP tool definition format. The input schema keeps every
223
+ * keyword, `$defs` included, made self-contained by `toToolParameters`.
194
224
  */
195
225
  export function toolSchemaToMCP(schema) {
196
226
  return {
197
227
  name: schema.name,
198
228
  description: schema.description,
199
- inputSchema: {
200
- type: 'object',
201
- properties: schema.parameters.properties,
202
- required: schema.parameters.required,
203
- },
229
+ inputSchema: toToolParameters(schema.parameters),
204
230
  };
205
231
  }
232
+ const TOOL_NAME_LIMIT = 64;
233
+ const PROVIDER_SAFE_NAME = /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/;
234
+ /**
235
+ * A tool name every LLM provider accepts: letters, digits, `_` and `-`, starting with a letter or
236
+ * `_`, at most 64 characters (the strictest of the OpenAI, Anthropic, Gemini and Bedrock rules).
237
+ * A valid name is kept as it is. Other characters, such as the dots of `admin.list_users`,
238
+ * become `_`, and a name too long is cut and ends with a hash of the full name, so different
239
+ * names stay different.
240
+ */
241
+ export function normalizeMCPToolName(name) {
242
+ if (PROVIDER_SAFE_NAME.test(name))
243
+ return name;
244
+ let safe = name.replace(/[^a-zA-Z0-9_-]/g, '_');
245
+ if (!/^[a-zA-Z_]/.test(safe))
246
+ safe = `_${safe}`;
247
+ if (safe.length <= TOOL_NAME_LIMIT)
248
+ return safe;
249
+ return withHash(safe, name);
250
+ }
251
+ function withHash(safe, original) {
252
+ const suffix = `_${createHash('sha256').update(original).digest('hex').slice(0, 8)}`;
253
+ return `${safe.slice(0, TOOL_NAME_LIMIT - suffix.length)}${suffix}`;
254
+ }
255
+ /**
256
+ * The provider-safe names of a server's tools. Two tools whose names normalize to the same one
257
+ * (`a.b` and `a_b`) are told apart by a hash of the original name on the one that was changed.
258
+ */
259
+ function toolNames(definitions, prefix) {
260
+ const names = new Map();
261
+ const owners = new Map();
262
+ for (const def of definitions) {
263
+ const name = normalizeMCPToolName(`${prefix}${def.name}`);
264
+ names.set(def.name, name);
265
+ owners.set(name, [...(owners.get(name) ?? []), def.name]);
266
+ }
267
+ for (const [name, originals] of owners) {
268
+ if (originals.length < 2)
269
+ continue;
270
+ for (const original of originals) {
271
+ const full = `${prefix}${original}`;
272
+ if (full !== name)
273
+ names.set(original, withHash(name, full));
274
+ }
275
+ }
276
+ return names;
277
+ }
206
278
  /**
207
279
  * Convert an MCP tool definition to a Cogitator Tool
208
280
  *
209
- * The resulting tool will execute calls through the provided MCPClient.
281
+ * The resulting tool will execute calls through the provided MCPClient, under the tool's original
282
+ * name. The Cogitator name is `namePrefix` plus the MCP name, normalized for LLM providers (see
283
+ * `normalizeMCPToolName`). Calls are retried after a timeout only when the server marks the tool
284
+ * read-only or idempotent.
210
285
  */
211
286
  export function mcpToCogitator(mcpTool, client, options) {
212
- const name = options?.namePrefix ? `${options.namePrefix}${mcpTool.name}` : mcpTool.name;
287
+ const name = options?.name ?? normalizeMCPToolName(`${options?.namePrefix ?? ''}${mcpTool.name}`);
213
288
  const description = options?.descriptionTransform
214
289
  ? options.descriptionTransform(mcpTool.description)
215
290
  : mcpTool.description;
216
- const rawInputSchema = mcpTool.inputSchema;
217
- const inputSchema = {
218
- type: 'object',
219
- properties: rawInputSchema.properties,
220
- required: rawInputSchema.required,
221
- additionalProperties: rawInputSchema.additionalProperties,
222
- };
223
- const parameters = jsonSchemaToZod(inputSchema);
291
+ const inputSchema = mcpTool.inputSchema;
292
+ const parameters = jsonSchemaToZod({ ...inputSchema, type: 'object' });
293
+ const annotations = mcpTool.annotations;
294
+ const idempotent = annotations?.readOnlyHint === true || annotations?.idempotentHint === true;
224
295
  const tool = {
225
296
  name,
226
297
  description,
@@ -228,16 +299,13 @@ export function mcpToCogitator(mcpTool, client, options) {
228
299
  execute: async (params, context) => {
229
300
  return client.callTool(mcpTool.name, (params ?? {}), {
230
301
  signal: context?.signal,
302
+ idempotent,
231
303
  });
232
304
  },
233
305
  toJSON: () => ({
234
306
  name,
235
307
  description,
236
- parameters: {
237
- type: 'object',
238
- properties: mcpTool.inputSchema.properties ?? {},
239
- required: mcpTool.inputSchema.required,
240
- },
308
+ parameters: toToolParameters(mcpTool.inputSchema),
241
309
  }),
242
310
  };
243
311
  return tool;
@@ -245,10 +313,13 @@ export function mcpToCogitator(mcpTool, client, options) {
245
313
  /**
246
314
  * Wrap all tools from an MCP client as Cogitator tools
247
315
  *
316
+ * Names are normalized for LLM providers and kept distinct. Give each server its own
317
+ * `namePrefix` when an agent uses several servers whose tools could share names.
318
+ *
248
319
  * @example
249
320
  * ```typescript
250
321
  * const client = await MCPClient.connect({ ... });
251
- * const tools = await wrapMCPTools(client);
322
+ * const tools = await wrapMCPTools(client, { namePrefix: 'github_' });
252
323
  *
253
324
  * const agent = new Agent({
254
325
  * tools: [...tools, ...otherTools],
@@ -257,10 +328,13 @@ export function mcpToCogitator(mcpTool, client, options) {
257
328
  */
258
329
  export async function wrapMCPTools(client, options) {
259
330
  const definitions = await client.listToolDefinitions();
260
- return definitions.map((def) => mcpToCogitator(def, client, options));
331
+ const names = toolNames(definitions, options?.namePrefix ?? '');
332
+ return definitions.map((def) => mcpToCogitator(def, client, { ...options, name: names.get(def.name) }));
261
333
  }
262
334
  /**
263
- * Convert a tool execution result to MCP content format
335
+ * Convert a tool execution result to MCP content format. A result with media (`toolContent()`,
336
+ * or an object with a base64 `image` such as a browser screenshot) becomes text, image, audio
337
+ * and resource blocks instead of JSON text.
264
338
  */
265
339
  export function resultToMCPContent(result) {
266
340
  if (result === null || result === undefined) {
@@ -269,6 +343,10 @@ export function resultToMCPContent(result) {
269
343
  if (typeof result === 'string') {
270
344
  return [{ type: 'text', text: result }];
271
345
  }
346
+ const parts = toolResultParts(result);
347
+ if (parts) {
348
+ return parts.map(partToMCPContent);
349
+ }
272
350
  if (typeof result === 'object') {
273
351
  if (Array.isArray(result) && result.length > 0 && result.every(isMCPToolContent)) {
274
352
  return result;
@@ -277,6 +355,25 @@ export function resultToMCPContent(result) {
277
355
  }
278
356
  return [{ type: 'text', text: String(result) }];
279
357
  }
358
+ function partToMCPContent(part, index) {
359
+ switch (part.type) {
360
+ case 'text':
361
+ return { type: 'text', text: part.text };
362
+ case 'image':
363
+ return { type: 'image', data: part.data, mimeType: part.mediaType };
364
+ case 'file':
365
+ return part.mediaType.startsWith('audio/')
366
+ ? { type: 'audio', data: part.data, mimeType: part.mediaType }
367
+ : {
368
+ type: 'resource',
369
+ resource: {
370
+ uri: `attachment:///${encodeURIComponent(part.filename ?? `file-${index + 1}`)}`,
371
+ mimeType: part.mediaType,
372
+ blob: part.data,
373
+ },
374
+ };
375
+ }
376
+ }
280
377
  /**
281
378
  * Check whether a value is a well-formed MCP tool content block
282
379
  */
@@ -303,12 +400,19 @@ function isMCPToolContent(value) {
303
400
  }
304
401
  }
305
402
  /**
306
- * Convert MCP content to a simple result value
403
+ * Convert MCP content to a simple result value: the text (parsed as JSON when it is JSON) of a
404
+ * single block, an array of values for several text blocks, and a `toolContent()` result when
405
+ * there are images, audio or binary resources, so they reach the model as media instead of
406
+ * base64 text.
307
407
  */
308
408
  export function mcpContentToResult(content) {
309
409
  if (!content || content.length === 0) {
310
410
  return null;
311
411
  }
412
+ if (content.some((item) => item.type !== 'text' && item.type !== 'resource') ||
413
+ content.some(isBlobResource)) {
414
+ return toolContent(...content.map(mcpContentToPart));
415
+ }
312
416
  const values = content.map((item) => {
313
417
  if (item.type === 'text') {
314
418
  try {
@@ -322,4 +426,25 @@ export function mcpContentToResult(content) {
322
426
  });
323
427
  return values.length === 1 ? values[0] : values;
324
428
  }
429
+ function isBlobResource(item) {
430
+ return item.type === 'resource' && typeof item.resource.blob === 'string';
431
+ }
432
+ function mcpContentToPart(item) {
433
+ switch (item.type) {
434
+ case 'text':
435
+ return { type: 'text', text: item.text };
436
+ case 'image':
437
+ return { type: 'image', data: item.data, mediaType: item.mimeType };
438
+ case 'audio':
439
+ return { type: 'file', data: item.data, mediaType: item.mimeType };
440
+ case 'resource':
441
+ if (typeof item.resource.blob === 'string') {
442
+ const mediaType = item.resource.mimeType ?? 'application/octet-stream';
443
+ return mediaType.startsWith('image/')
444
+ ? { type: 'image', data: item.resource.blob, mediaType }
445
+ : { type: 'file', data: item.resource.blob, mediaType, filename: item.resource.uri };
446
+ }
447
+ return { type: 'text', text: item.resource.text ?? '' };
448
+ }
449
+ }
325
450
  //# sourceMappingURL=tool-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-adapter.js","sourceRoot":"","sources":["../../src/adapter/tool-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAmC,MAAM,KAAK,CAAC;AAKzD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAKhD,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE;QACxC,eAAe,EAAE,KAAK;QACtB,EAAE,EAAE,QAAQ;QACZ,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,OAAO,MAAM,CAAC,OAAO,CAAC;IAEtB,OAAO,MAIN,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAK/B;IACC,IAAI,MAAM,CAAC,IAAI,KAAK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