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[] = [];