From 37e732b0aeb0a08171895e1296bd8b998d4852fe Mon Sep 17 00:00:00 2001 From: Vishal Habib Date: Fri, 25 Sep 2026 21:30:29 -0400 Subject: [PATCH] fix: pass tool annotations to McpServer.tool() before the callback #210 added readOnlyHint/destructiveHint annotations, but they were passed after the callback, wrapped in { annotations }. McpServer.tool() only reads annotations between paramsSchema and the callback, so the trailing argument was ignored and tools/list returned no annotations. Fixes #266 Co-Authored-By: Claude Opus 5.5 --- src/index.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6353f75..03e5e0d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,13 +89,20 @@ export class MyMCP extends McpAgent { }); getMcpTools(env, host, canonicalUrl, ctx).forEach((tool) => { - this.server.tool( - tool.name, - tool.description, - tool.paramsSchema, - async (args: any) => tool.cb(args), - tool.annotations ? { annotations: tool.annotations } : undefined, - ); + const cb = async (args: any) => tool.cb(args); + // Annotations must come between paramsSchema and the callback; + // McpServer.tool() ignores any argument after the callback. + if (tool.annotations) { + this.server.tool( + tool.name, + tool.description, + tool.paramsSchema, + tool.annotations, + cb, + ); + } else { + this.server.tool(tool.name, tool.description, tool.paramsSchema, cb); + } }); } }