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.
This commit is contained in:
@@ -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) }]
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user