Skip to content

Commit b37f08a

Browse files
mattzcareygchingKKonstantinovfelixweinberger
authored
fix: update registerTool signature for proper typed ToolCallback (#1188)
Co-authored-by: Gavin <gching@users.noreply.github.com> Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com> Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
1 parent 5e0302f commit b37f08a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/server/mcp.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
639639
async () => ({
640640
content: [
641641
{
642-
type: 'text' as const,
642+
type: 'text',
643643
text: 'Test response'
644644
}
645645
]
@@ -694,7 +694,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
694694
async () => ({
695695
content: [
696696
{
697-
type: 'text' as const,
697+
type: 'text',
698698
text: 'Test response'
699699
}
700700
]
@@ -876,7 +876,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
876876
}
877877
},
878878
async () => ({
879-
content: [{ type: 'text' as const, text: 'Test response' }]
879+
content: [{ type: 'text', text: 'Test response' }]
880880
})
881881
);
882882

@@ -1928,7 +1928,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
19281928
{
19291929
description: 'A valid tool name'
19301930
},
1931-
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1931+
async () => ({ content: [{ type: 'text', text: 'Success' }] })
19321932
);
19331933

19341934
// Test tool name with warnings (starts with dash)
@@ -1937,7 +1937,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
19371937
{
19381938
description: 'A tool name that generates warnings'
19391939
},
1940-
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1940+
async () => ({ content: [{ type: 'text', text: 'Success' }] })
19411941
);
19421942

19431943
// Test invalid tool name (contains spaces)
@@ -1946,7 +1946,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
19461946
{
19471947
description: 'An invalid tool name'
19481948
},
1949-
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1949+
async () => ({ content: [{ type: 'text', text: 'Success' }] })
19501950
);
19511951

19521952
// Verify that warnings were issued (both for warnings and validation failures)
@@ -3894,7 +3894,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
38943894

38953895
// Tool 1: Only name
38963896
mcpServer.tool('tool_name_only', async () => ({
3897-
content: [{ type: 'text' as const, text: 'Response' }]
3897+
content: [{ type: 'text', text: 'Response' }]
38983898
}));
38993899

39003900
// Tool 2: Name and annotations.title
@@ -3905,7 +3905,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
39053905
title: 'Annotations Title'
39063906
},
39073907
async () => ({
3908-
content: [{ type: 'text' as const, text: 'Response' }]
3908+
content: [{ type: 'text', text: 'Response' }]
39093909
})
39103910
);
39113911

@@ -3917,7 +3917,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
39173917
description: 'Tool with regular title'
39183918
},
39193919
async () => ({
3920-
content: [{ type: 'text' as const, text: 'Response' }]
3920+
content: [{ type: 'text', text: 'Response' }]
39213921
})
39223922
);
39233923

@@ -3932,7 +3932,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
39323932
}
39333933
},
39343934
async () => ({
3935-
content: [{ type: 'text' as const, text: 'Response' }]
3935+
content: [{ type: 'text', text: 'Response' }]
39363936
})
39373937
);
39383938

@@ -5009,7 +5009,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
50095009
description: 'Tool with regular title'
50105010
},
50115011
async () => ({
5012-
content: [{ type: 'text' as const, text: 'Response' }]
5012+
content: [{ type: 'text', text: 'Response' }]
50135013
})
50145014
);
50155015

@@ -5024,7 +5024,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
50245024
}
50255025
},
50265026
async () => ({
5027-
content: [{ type: 'text' as const, text: 'Response' }]
5027+
content: [{ type: 'text', text: 'Response' }]
50285028
})
50295029
);
50305030

src/server/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ export class McpServer {
10301030
/**
10311031
* Registers a tool with a config object and callback.
10321032
*/
1033-
registerTool<InputArgs extends ZodRawShapeCompat | AnySchema, OutputArgs extends ZodRawShapeCompat | AnySchema>(
1033+
registerTool<OutputArgs extends ZodRawShapeCompat | AnySchema, InputArgs extends undefined | ZodRawShapeCompat | AnySchema = undefined>(
10341034
name: string,
10351035
config: {
10361036
title?: string;

0 commit comments

Comments
 (0)