fix: repeat MCP tool data as JSON text for clients without structured content

This commit is contained in:
Sameh Khamis committed 2026-10-02 15:21:36 -07:00
1 parent df0e0f32e8
commit 2e071b62d3
4 files changed
+10 -3

No files matched your search

+4 -1
View File
@@ -125,7 +125,10 @@ test('tool results carry text and structured content; failures stay generic', as
(await request('tools/call', { name: 'count', arguments: { n: 3 } }))
.result,
{
content: [{ type: 'text', text: '3 things.' }],
content: [
{ type: 'text', text: '3 things.' },
{ type: 'text', text: '{"n":3}' },
],
structuredContent: { n: 3 },
isError: false,
},
+3
View File
@@ -80,8 +80,11 @@ export function createMcpServer({
signal,
});
return {
// The data is repeated as JSON text for clients that do not read
// structuredContent.
content: [
{ type: 'text', text: result.summary },
{ type: 'text', text: JSON.stringify(result.data) },
...(result.images || []).map((item) => ({
type: 'image',
data: item.data,
+1 -1
View File
@@ -97,7 +97,7 @@ test('a snapshot returns the frame as an image with its credit', async () => {
method: 'tools/call',
params: { name: 'get_cctv_snapshot', arguments: { camera_id: 'austin-1' } },
});
assert.deepEqual(response.result.content[1], {
assert.deepEqual(response.result.content[2], {
type: 'image',
data: 'iVBORw0KGgo=',
mimeType: 'image/png',