From 4df9b0129b6e8c30cacb09fb3c1ac6330e091deb Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sun, 1 Nov 2026 16:41:38 +0000 Subject: [PATCH] fix: honor mount path in MCP dispatch --- apps/server/src/routes/mcp.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/server/src/routes/mcp.ts b/apps/server/src/routes/mcp.ts index ec052ae..5403de2 100644 --- a/apps/server/src/routes/mcp.ts +++ b/apps/server/src/routes/mcp.ts @@ -1,7 +1,9 @@ import { Hono } from 'hono'; import { BoardClient } from '@tsbb/client'; +import { basePathOf } from '@tsbb/core'; import { handle, LATEST_PROTOCOL_VERSION } from '@tsbb/mcp'; import type { AppEnv, Services } from '../context.ts'; +import { mountAt } from '../mount.ts'; import { packageVersion } from '../version.ts'; /** @@ -30,6 +32,11 @@ export function mcpRoutes( dispatch: (request: Request) => Response | Promise, ) { const app = new Hono(); + // BoardClient builds absolute URLs from the public base URL. Re-enter the + // app through the same mount adapter used by the network listener so a board + // served under a prefix (for example /bbs) has that prefix stripped before + // its internal REST request reaches the root-based routes. + const localDispatch = mountAt(basePathOf(services.baseUrl), dispatch); app.post('/api/mcp', async (c) => { const authorization = c.req.header('authorization'); @@ -38,7 +45,7 @@ export function mcpRoutes( const client = new BoardClient({ server: services.baseUrl, token, - fetch: (input, init) => Promise.resolve(dispatch(new Request(input as string, init))), + fetch: (input, init) => Promise.resolve(localDispatch(new Request(input as string, init))), }); let body: unknown;