Skip to content

Commit eef0f05

Browse files
committed
fix: update shim return types and test mocks to use CallToolResult
- Update browser/node shim imports and return types from CallToolResultContent to CallToolResult - Fix integration test mocks to return proper CallToolResult objects with content property - Update mcpCache.test.ts to use correct CallToolResult type and format - Update mcpToolFilter.integration.test.ts callTool method to return {content: [...]} format - All tests pass, no linting errors These are the final mechanical fixes for type consistency across the codebase.
1 parent 8c83f3f commit eef0f05

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

packages/agents-core/src/shims/mcp-server/browser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
BaseMCPServerSSE,
33
BaseMCPServerStdio,
44
BaseMCPServerStreamableHttp,
5-
CallToolResultContent,
5+
CallToolResult,
66
MCPServerSSEOptions,
77
MCPServerStdioOptions,
88
MCPServerStreamableHttpOptions,
@@ -28,7 +28,7 @@ export class MCPServerStdio extends BaseMCPServerStdio {
2828
callTool(
2929
_toolName: string,
3030
_args: Record<string, unknown> | null,
31-
): Promise<CallToolResultContent> {
31+
): Promise<CallToolResult> {
3232
throw new Error('Method not implemented.');
3333
}
3434
invalidateToolsCache(): Promise<void> {
@@ -55,7 +55,7 @@ export class MCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
5555
callTool(
5656
_toolName: string,
5757
_args: Record<string, unknown> | null,
58-
): Promise<CallToolResultContent> {
58+
): Promise<CallToolResult> {
5959
throw new Error('Method not implemented.');
6060
}
6161
invalidateToolsCache(): Promise<void> {
@@ -84,7 +84,7 @@ export class MCPServerSSE extends BaseMCPServerSSE {
8484
callTool(
8585
_toolName: string,
8686
_args: Record<string, unknown> | null,
87-
): Promise<CallToolResultContent> {
87+
): Promise<CallToolResult> {
8888
throw new Error('Method not implemented.');
8989
}
9090

packages/agents-core/src/shims/mcp-server/node.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
BaseMCPServerStdio,
66
BaseMCPServerStreamableHttp,
77
BaseMCPServerSSE,
8-
CallToolResultContent,
8+
CallToolResult,
99
DefaultMCPServerStdioOptions,
1010
InitializeResult,
1111
MCPServerStdioOptions,
@@ -124,7 +124,7 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
124124
async callTool(
125125
toolName: string,
126126
args: Record<string, unknown> | null,
127-
): Promise<CallToolResultContent> {
127+
): Promise<CallToolResult> {
128128
const { CallToolResultSchema } = await import(
129129
'@modelcontextprotocol/sdk/types.js'
130130
).catch(failedToImport);
@@ -149,7 +149,7 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
149149
() =>
150150
`Called tool ${toolName} (args: ${JSON.stringify(args)}, result: ${JSON.stringify(result)})`,
151151
);
152-
return result as CallToolResultContent;
152+
return result as CallToolResult;
153153
}
154154

155155
get name() {
@@ -245,7 +245,7 @@ export class NodeMCPServerSSE extends BaseMCPServerSSE {
245245
async callTool(
246246
toolName: string,
247247
args: Record<string, unknown> | null,
248-
): Promise<CallToolResultContent> {
248+
): Promise<CallToolResult> {
249249
const { CallToolResultSchema } = await import(
250250
'@modelcontextprotocol/sdk/types.js'
251251
).catch(failedToImport);
@@ -270,7 +270,7 @@ export class NodeMCPServerSSE extends BaseMCPServerSSE {
270270
() =>
271271
`Called tool ${toolName} (args: ${JSON.stringify(args)}, result: ${JSON.stringify(result)})`,
272272
);
273-
return result as CallToolResultContent;
273+
return result as CallToolResult;
274274
}
275275

276276
get name() {
@@ -371,7 +371,7 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
371371
async callTool(
372372
toolName: string,
373373
args: Record<string, unknown> | null,
374-
): Promise<CallToolResultContent> {
374+
): Promise<CallToolResult> {
375375
const { CallToolResultSchema } = await import(
376376
'@modelcontextprotocol/sdk/types.js'
377377
).catch(failedToImport);
@@ -396,7 +396,7 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
396396
() =>
397397
`Called tool ${toolName} (args: ${JSON.stringify(args)}, result: ${JSON.stringify(result)})`,
398398
);
399-
return result as CallToolResultContent;
399+
return result as CallToolResult;
400400
}
401401

402402
get name() {

packages/agents-core/test/mcpCache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getAllMcpTools } from '../src/mcp';
33
import type { FunctionTool } from '../src/tool';
44
import { withTrace } from '../src/tracing';
55
import { NodeMCPServerStdio } from '../src/shims/mcp-server/node';
6-
import type { CallToolResultContent } from '../src/mcp';
6+
import type { CallToolResult } from '../src/mcp';
77
import { RunContext } from '../src/runContext';
88
import { Agent } from '../src/agent';
99

@@ -27,8 +27,8 @@ class StubServer extends NodeMCPServerStdio {
2727
async callTool(
2828
_toolName: string,
2929
_args: Record<string, unknown> | null,
30-
): Promise<CallToolResultContent> {
31-
return [];
30+
): Promise<CallToolResult> {
31+
return { content: [] };
3232
}
3333
}
3434

packages/agents-core/test/mcpToolFilter.integration.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,25 @@ class StubFilesystemServer extends NodeMCPServerStdio {
6060
async callTool(name: string, args: any) {
6161
const blocked = (this.toolFilter as any)?.blockedToolNames ?? [];
6262
if (blocked.includes(name)) {
63-
return [
64-
{ type: 'text', text: `Tool "${name}" is blocked by MCP filter` },
65-
];
63+
return {
64+
content: [
65+
{ type: 'text', text: `Tool "${name}" is blocked by MCP filter` },
66+
],
67+
};
6668
}
6769
if (name === 'list_directory') {
6870
const files = fs.readdirSync(this.dir);
69-
return [{ type: 'text', text: files.join('\n') }];
71+
return { content: [{ type: 'text', text: files.join('\n') }] };
7072
}
7173
if (name === 'read_file') {
7274
const text = fs.readFileSync(path.join(this.dir, args.path), 'utf8');
73-
return [{ type: 'text', text }];
75+
return { content: [{ type: 'text', text }] };
7476
}
7577
if (name === 'write_file') {
7678
fs.writeFileSync(path.join(this.dir, args.path), args.text, 'utf8');
77-
return [{ type: 'text', text: 'ok' }];
79+
return { content: [{ type: 'text', text: 'ok' }] };
7880
}
79-
return [];
81+
return { content: [] };
8082
}
8183
}
8284

0 commit comments

Comments
 (0)