use json block for mcp tool output (and re-enable markdown rendering) (#635)

This commit is contained in:
Olcan
2025-05-30 15:59:23 -07:00
committed by GitHub
parent 2e57989aec
commit c81148a0cc
3 changed files with 8 additions and 5 deletions

View File

@@ -116,7 +116,8 @@ describe('DiscoveredMCPTool', () => {
timeout: MCP_TOOL_DEFAULT_TIMEOUT_MSEC, 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.llmContent).toBe(expectedOutput);
expect(result.returnDisplay).toBe(expectedOutput); expect(result.returnDisplay).toBe(expectedOutput);
}); });

View File

@@ -42,7 +42,7 @@ Returns the MCP server response as a json string.
name, name,
description, description,
parameterSchema, parameterSchema,
false, // isOutputMarkdown true, // isOutputMarkdown
false, // canUpdateOutput false, // canUpdateOutput
); );
} }
@@ -93,9 +93,10 @@ Returns the MCP server response as a json string.
timeout: this.timeout ?? MCP_TOOL_DEFAULT_TIMEOUT_MSEC, timeout: this.timeout ?? MCP_TOOL_DEFAULT_TIMEOUT_MSEC,
}, },
); );
const output = '```json\n' + JSON.stringify(result, null, 2) + '\n```';
return { return {
llmContent: JSON.stringify(result, null, 2), llmContent: output,
returnDisplay: JSON.stringify(result, null, 2), returnDisplay: output,
}; };
} }
} }

View File

@@ -768,7 +768,8 @@ describe('DiscoveredMCPTool', () => {
timeout: 10 * 60 * 1000, 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.llmContent).toBe(expectedOutput);
expect(result.returnDisplay).toBe(expectedOutput); expect(result.returnDisplay).toBe(expectedOutput);
}); });