From ad127bec4074cd2e0df9a2481e00bbe661969bfc Mon Sep 17 00:00:00 2001 From: ck0park <5241953+ck0park@users.noreply.github.com> Date: Sat, 11 Apr 2026 09:57:01 +0900 Subject: [PATCH] fix: wrap list_corpora response in MCP CallToolResult shape (fixes #1700) GET /api/corpus returned a bare array, which the MCP server wrapper (callWorkerAPI) forwards directly. MCP's tools/call validation rejects non-object results with "expected object, received array", so the list_corpora MCP tool was completely unusable. Every other corpus endpoint is a POST that already returns the {content:[...]} shape, so this is a targeted one-file fix. --- src/services/worker/http/routes/CorpusRoutes.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/worker/http/routes/CorpusRoutes.ts b/src/services/worker/http/routes/CorpusRoutes.ts index 836e477a..928a06ea 100644 --- a/src/services/worker/http/routes/CorpusRoutes.ts +++ b/src/services/worker/http/routes/CorpusRoutes.ts @@ -72,7 +72,14 @@ export class CorpusRoutes extends BaseRouteHandler { */ private handleListCorpora = this.wrapHandler((_req: Request, res: Response): void => { const corpora = this.corpusStore.list(); - res.json(corpora); + // Wrap in MCP CallToolResult shape so the MCP server wrapper (callWorkerAPI) + // can forward it without failing tools/call schema validation. + // See: #1700 — every other corpus endpoint is a POST that already returns + // {content:[...]}, but this GET used to return a bare array, which MCP + // rejects with "expected object, received array". + res.json({ + content: [{ type: 'text', text: JSON.stringify(corpora, null, 2) }] + }); }); /**