@@ -169,7 +169,7 @@ export class McpServer {
169
169
}
170
170
171
171
const args = parseResult . data ;
172
- const cb = tool . callback as ToolCallback < ZodRawShape , ZodRawShape > ;
172
+ const cb = tool . callback as ToolCallback < ZodRawShape > ;
173
173
try {
174
174
result = await Promise . resolve ( cb ( args , extra ) ) ;
175
175
} catch ( error ) {
@@ -184,7 +184,7 @@ export class McpServer {
184
184
} ;
185
185
}
186
186
} else {
187
- const cb = tool . callback as ToolCallback < undefined , ZodRawShape > ;
187
+ const cb = tool . callback as ToolCallback < undefined > ;
188
188
try {
189
189
result = await Promise . resolve ( cb ( extra ) ) ;
190
190
} catch ( error ) {
@@ -772,7 +772,7 @@ export class McpServer {
772
772
inputSchema : ZodRawShape | undefined ,
773
773
outputSchema : ZodRawShape | undefined ,
774
774
annotations : ToolAnnotations | undefined ,
775
- callback : ToolCallback < ZodRawShape | undefined , ZodRawShape | undefined >
775
+ callback : ToolCallback < ZodRawShape | undefined >
776
776
) : RegisteredTool {
777
777
const registeredTool : RegisteredTool = {
778
778
title,
@@ -929,7 +929,7 @@ export class McpServer {
929
929
outputSchema ?: OutputArgs ;
930
930
annotations ?: ToolAnnotations ;
931
931
} ,
932
- cb : ToolCallback < InputArgs , OutputArgs >
932
+ cb : ToolCallback < InputArgs >
933
933
) : RegisteredTool {
934
934
if ( this . _registeredTools [ name ] ) {
935
935
throw new Error ( `Tool ${ name } is already registered` ) ;
@@ -944,7 +944,7 @@ export class McpServer {
944
944
inputSchema ,
945
945
outputSchema ,
946
946
annotations ,
947
- cb as ToolCallback < ZodRawShape | undefined , ZodRawShape | undefined >
947
+ cb as ToolCallback < ZodRawShape | undefined >
948
948
) ;
949
949
}
950
950
@@ -1138,16 +1138,6 @@ export class ResourceTemplate {
1138
1138
}
1139
1139
}
1140
1140
1141
- /**
1142
- * Type helper to create a strongly-typed CallToolResult with structuredContent
1143
- */
1144
- type TypedCallToolResult < OutputArgs extends undefined | ZodRawShape > =
1145
- OutputArgs extends ZodRawShape
1146
- ? CallToolResult & {
1147
- structuredContent ?: z . objectOutputType < OutputArgs , ZodTypeAny > ;
1148
- }
1149
- : CallToolResult ;
1150
-
1151
1141
/**
1152
1142
* Callback for a tool handler registered with Server.tool().
1153
1143
*
@@ -1158,46 +1148,36 @@ type TypedCallToolResult<OutputArgs extends undefined | ZodRawShape> =
1158
1148
* - `content` if the tool does not have an outputSchema
1159
1149
* - Both fields are optional but typically one should be provided
1160
1150
*/
1161
- export type ToolCallback <
1162
- InputArgs extends undefined | ZodRawShape = undefined ,
1163
- OutputArgs extends undefined | ZodRawShape = undefined
1164
- > = InputArgs extends ZodRawShape
1151
+ export type ToolCallback < Args extends undefined | ZodRawShape = undefined > =
1152
+ Args extends ZodRawShape
1165
1153
? (
1166
- args : z . objectOutputType < InputArgs , ZodTypeAny > ,
1167
- extra : RequestHandlerExtra < ServerRequest , ServerNotification >
1168
- ) =>
1169
- | TypedCallToolResult < OutputArgs >
1170
- | Promise < TypedCallToolResult < OutputArgs > >
1171
- : (
1172
- extra : RequestHandlerExtra < ServerRequest , ServerNotification >
1173
- ) =>
1174
- | TypedCallToolResult < OutputArgs >
1175
- | Promise < TypedCallToolResult < OutputArgs > > ;
1154
+ args : z . objectOutputType < Args , ZodTypeAny > ,
1155
+ extra : RequestHandlerExtra < ServerRequest , ServerNotification > ,
1156
+ ) => CallToolResult | Promise < CallToolResult >
1157
+ : ( extra : RequestHandlerExtra < ServerRequest , ServerNotification > ) => CallToolResult | Promise < CallToolResult > ;
1176
1158
1177
1159
export type RegisteredTool = {
1178
1160
title ?: string ;
1179
1161
description ?: string ;
1180
1162
inputSchema ?: AnyZodObject ;
1181
1163
outputSchema ?: AnyZodObject ;
1182
1164
annotations ?: ToolAnnotations ;
1183
- callback : ToolCallback < ZodRawShape | undefined , ZodRawShape | undefined > ;
1165
+ callback : ToolCallback < undefined | ZodRawShape > ;
1184
1166
enabled : boolean ;
1185
1167
enable ( ) : void ;
1186
1168
disable ( ) : void ;
1187
- update <
1188
- InputArgs extends ZodRawShape ,
1189
- OutputArgs extends ZodRawShape
1190
- > ( updates : {
1191
- name ?: string | null ;
1192
- title ?: string ;
1193
- description ?: string ;
1194
- paramsSchema ?: InputArgs ;
1195
- outputSchema ?: OutputArgs ;
1196
- annotations ?: ToolAnnotations ;
1197
- callback ?: ToolCallback < InputArgs , OutputArgs >
1198
- enabled ?: boolean
1199
- } ) : void ;
1200
- remove ( ) : void ;
1169
+ update < InputArgs extends ZodRawShape , OutputArgs extends ZodRawShape > (
1170
+ updates : {
1171
+ name ?: string | null ,
1172
+ title ?: string ,
1173
+ description ?: string ,
1174
+ paramsSchema ?: InputArgs ,
1175
+ outputSchema ?: OutputArgs ,
1176
+ annotations ?: ToolAnnotations ,
1177
+ callback ?: ToolCallback < InputArgs > ,
1178
+ enabled ?: boolean
1179
+ } ) : void
1180
+ remove ( ) : void
1201
1181
} ;
1202
1182
1203
1183
const EMPTY_OBJECT_JSON_SCHEMA = {
0 commit comments