diff --git a/packages/server/src/tools/mcp-tool.test.ts b/packages/server/src/tools/mcp-tool.test.ts index 331696f7..5c784c5d 100644 --- a/packages/server/src/tools/mcp-tool.test.ts +++ b/packages/server/src/tools/mcp-tool.test.ts @@ -116,7 +116,8 @@ describe('DiscoveredMCPTool', () => { timeout: MCP_TOOL_DEFAULT_TIMEOUT_MSEC, }, ); - const expectedOutput = JSON.stringify(expectedMcpResult, null, 2); + const expectedOutput = + '```json\n' + JSON.stringify(expectedMcpResult, null, 2) + '\n```'; expect(result.llmContent).toBe(expectedOutput); expect(result.returnDisplay).toBe(expectedOutput); }); diff --git a/packages/server/src/tools/mcp-tool.ts b/packages/server/src/tools/mcp-tool.ts index 80e6bbde..d02b8632 100644 --- a/packages/server/src/tools/mcp-tool.ts +++ b/packages/server/src/tools/mcp-tool.ts @@ -42,7 +42,7 @@ Returns the MCP server response as a json string. name, description, parameterSchema, - false, // isOutputMarkdown + true, // isOutputMarkdown false, // canUpdateOutput ); } @@ -93,9 +93,10 @@ Returns the MCP server response as a json string. timeout: this.timeout ?? MCP_TOOL_DEFAULT_TIMEOUT_MSEC, }, ); + const output = '```json\n' + JSON.stringify(result, null, 2) + '\n```'; return { - llmContent: JSON.stringify(result, null, 2), - returnDisplay: JSON.stringify(result, null, 2), + llmContent: output, + returnDisplay: output, }; } } diff --git a/packages/server/src/tools/tool-registry.test.ts b/packages/server/src/tools/tool-registry.test.ts index c93109ae..121e91c8 100644 --- a/packages/server/src/tools/tool-registry.test.ts +++ b/packages/server/src/tools/tool-registry.test.ts @@ -768,7 +768,8 @@ describe('DiscoveredMCPTool', () => { timeout: 10 * 60 * 1000, }, ); - const expectedOutput = JSON.stringify(mcpResult, null, 2); + const expectedOutput = + '```json\n' + JSON.stringify(mcpResult, null, 2) + '\n```'; expect(result.llmContent).toBe(expectedOutput); expect(result.returnDisplay).toBe(expectedOutput); });