From c66502e5900cc3a665a31bbfed1decb57e0943f0 Mon Sep 17 00:00:00 2001 From: Michal Date: Sat, 15 Aug 2026 21:43:00 +0100 Subject: [PATCH] fix(mcplocal): fetch project instructions with the caller's token (#113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The instructions fetch was the one downstream call in getOrCreateRouter still using mcpdClient — whose token is an empty string in HTTP mode — so mcpd answered 401, the catch swallowed it, and every session initialized with no instructions while nothing looked broken. requestClient exists precisely for this; use it. Closes #113 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JaFvfHrQyUKCGv6o3N2Wir --- src/mcplocal/src/http/project-mcp-endpoint.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mcplocal/src/http/project-mcp-endpoint.ts b/src/mcplocal/src/http/project-mcp-endpoint.ts index 274b6b7..a66645f 100644 --- a/src/mcplocal/src/http/project-mcp-endpoint.ts +++ b/src/mcplocal/src/http/project-mcp-endpoint.ts @@ -176,9 +176,13 @@ export function registerProjectMcpEndpoint(app: FastifyInstance, mcpdClient: Mcp chain.push(createAgentsPlugin()); router.setPlugin(composePlugins(chain)); - // Fetch project instructions and set on router + // Fetch project instructions and set on router. Must ride the CALLER's + // token (requestClient) like every other downstream call here: in HTTP + // mode mcpdClient's own token is empty, mcpd answers 401, and the catch + // below swallowed it — every session initialized with no instructions + // while nothing looked broken (#113). try { - const instructions = await mcpdClient.get<{ prompt: string; servers: Array<{ name: string; description: string }> }>( + const instructions = await requestClient.get<{ prompt: string; servers: Array<{ name: string; description: string }> }>( `/api/v1/projects/${encodeURIComponent(projectName)}/instructions`, ); const parts: string[] = [];