Skip to content

Commit 1e90969

Browse files
committed
Revert "chore: use .tool instead of .registerTool"
Now with actual fix for our mock... I thought there was something wrong This reverts commit f881902.
1 parent 070a8d2 commit 1e90969

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/tools/tool.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -470,18 +470,29 @@ export abstract class ToolBase {
470470
}
471471
};
472472

473-
this.registeredTool = (
474-
server.mcpServer.tool as (
475-
// Note: We use explicit type casting here to avoid "excessively deep and possibly infinite" errors
476-
// that occur when TypeScript tries to infer the complex generic types from `typeof this.argsShape`
477-
// in the abstract class context.
478-
name: string,
479-
description: string,
480-
argsShape: ZodRawShape,
481-
annotations: ToolAnnotations,
482-
cb: (args: ToolArgs<ZodRawShape>, { signal }: ToolExecutionContext) => Promise<CallToolResult>
483-
) => RegisteredTool
484-
)(this.name, this.description, this.argsShape, this.annotations, callback);
473+
this.registeredTool =
474+
// Note: We use explicit type casting here to avoid "excessively deep and possibly infinite" errors
475+
// that occur when TypeScript tries to infer the complex generic types from `typeof this.argsShape`
476+
// in the abstract class context.
477+
(
478+
server.mcpServer.registerTool as (
479+
name: string,
480+
config: {
481+
description?: string;
482+
inputSchema?: ZodRawShape;
483+
annotations?: ToolAnnotations;
484+
},
485+
cb: (args: ToolArgs<ZodRawShape>, extra: ToolExecutionContext) => Promise<CallToolResult>
486+
) => RegisteredTool
487+
)(
488+
this.name,
489+
{
490+
description: this.description,
491+
inputSchema: this.argsShape,
492+
annotations: this.annotations,
493+
},
494+
callback
495+
);
485496

486497
return true;
487498
}

tests/unit/toolBase.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ describe("ToolBase", () => {
132132
beforeEach(() => {
133133
const mockServer = {
134134
mcpServer: {
135-
tool: (
135+
registerTool: (
136136
name: string,
137-
description: string,
138-
paramsSchema: unknown,
139-
annotations: ToolAnnotations,
137+
{
138+
description,
139+
}: { description: string; inputSchema: ZodRawShape; annotations: ToolAnnotations },
140140
cb: ToolCallback<ZodRawShape>
141141
): void => {
142142
expect(name).toBe(testTool.name);

0 commit comments

Comments
 (0)