From b37f08ae3a2b1ea2fc416f83d271c813a0490113 Mon Sep 17 00:00:00 2001 From: Matt <77928207+mattzcarey@users.noreply.github.com> Date: Fri, 28 Nov 2025 16:14:26 +0000 Subject: [PATCH] fix: update registerTool signature for proper typed ToolCallback (#1188) Co-authored-by: Gavin Co-authored-by: Konstantin Konstantinov Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com> --- src/server/mcp.test.ts | 24 ++++++++++++------------ src/server/mcp.ts | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/server/mcp.test.ts b/src/server/mcp.test.ts index 2ad40ba5..aa9a1477 100644 --- a/src/server/mcp.test.ts +++ b/src/server/mcp.test.ts @@ -639,7 +639,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { async () => ({ content: [ { - type: 'text' as const, + type: 'text', text: 'Test response' } ] @@ -694,7 +694,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { async () => ({ content: [ { - type: 'text' as const, + type: 'text', text: 'Test response' } ] @@ -876,7 +876,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { } }, async () => ({ - content: [{ type: 'text' as const, text: 'Test response' }] + content: [{ type: 'text', text: 'Test response' }] }) ); @@ -1928,7 +1928,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { { description: 'A valid tool name' }, - async () => ({ content: [{ type: 'text' as const, text: 'Success' }] }) + async () => ({ content: [{ type: 'text', text: 'Success' }] }) ); // Test tool name with warnings (starts with dash) @@ -1937,7 +1937,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { { description: 'A tool name that generates warnings' }, - async () => ({ content: [{ type: 'text' as const, text: 'Success' }] }) + async () => ({ content: [{ type: 'text', text: 'Success' }] }) ); // Test invalid tool name (contains spaces) @@ -1946,7 +1946,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { { description: 'An invalid tool name' }, - async () => ({ content: [{ type: 'text' as const, text: 'Success' }] }) + async () => ({ content: [{ type: 'text', text: 'Success' }] }) ); // Verify that warnings were issued (both for warnings and validation failures) @@ -3894,7 +3894,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { // Tool 1: Only name mcpServer.tool('tool_name_only', async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] })); // Tool 2: Name and annotations.title @@ -3905,7 +3905,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { title: 'Annotations Title' }, async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] }) ); @@ -3917,7 +3917,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { description: 'Tool with regular title' }, async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] }) ); @@ -3932,7 +3932,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { } }, async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] }) ); @@ -5009,7 +5009,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { description: 'Tool with regular title' }, async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] }) ); @@ -5024,7 +5024,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => { } }, async () => ({ - content: [{ type: 'text' as const, text: 'Response' }] + content: [{ type: 'text', text: 'Response' }] }) ); diff --git a/src/server/mcp.ts b/src/server/mcp.ts index 68a81764..c097ae53 100644 --- a/src/server/mcp.ts +++ b/src/server/mcp.ts @@ -1030,7 +1030,7 @@ export class McpServer { /** * Registers a tool with a config object and callback. */ - registerTool( + registerTool( name: string, config: { title?: string;