From 5b07a8a9b4a67864a1aef0190faadb5dba788cc4 Mon Sep 17 00:00:00 2001 From: memosr Date: Thu, 4 Jun 2026 15:47:09 +0300 Subject: [PATCH] =?UTF-8?q?fix(mcp):=20use=20request.params.name=20in=20ca?= =?UTF-8?q?tch=20block=20=E2=80=94=20name=20is=20out=20of=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error handler at typescript/framework-extensions/model-context-protocol/ README.md:58 referenced \`${name}\` inside a catch block where \`name\` is not defined. The function uses \`async (request) =>\` and destructures \`name\` from \`request.params\` only at the top of the try block, so it is not accessible from the catch. In a browser, this silently resolves to \`window.name\` (an unrelated string). In Node.js (where MCP servers actually run), this throws ReferenceError before the intended error message is constructed. Changed to \`${request.params.name}\` which is in scope throughout the handler, matching the access pattern used everywhere else in the file. --- .../framework-extensions/model-context-protocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/framework-extensions/model-context-protocol/README.md b/typescript/framework-extensions/model-context-protocol/README.md index 413792e7f..c118e0422 100644 --- a/typescript/framework-extensions/model-context-protocol/README.md +++ b/typescript/framework-extensions/model-context-protocol/README.md @@ -55,7 +55,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return toolHandler(request.params.name, request.params.arguments); } catch (error) { - throw new Error(`Tool ${name} failed: ${error}`); + throw new Error(`Tool ${request.params.name} failed: ${error}`); } });