fix(mcplocal): fetch project instructions with the caller's token (#113)
Some checks failed
Some checks failed
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JaFvfHrQyUKCGv6o3N2Wir
This commit is contained in:
@@ -176,9 +176,13 @@ export function registerProjectMcpEndpoint(app: FastifyInstance, mcpdClient: Mcp
|
|||||||
chain.push(createAgentsPlugin());
|
chain.push(createAgentsPlugin());
|
||||||
router.setPlugin(composePlugins(chain));
|
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 {
|
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`,
|
`/api/v1/projects/${encodeURIComponent(projectName)}/instructions`,
|
||||||
);
|
);
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user