mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 11:24:00 +00:00
fix: repeat MCP tool data as JSON text for clients without structured content
This commit is contained in:
1 parent
df0e0f32e8
commit
2e071b62d3
4 files changed
+10
-3
No files matched your search
+2
-1
@@ -32,7 +32,8 @@ checks completely; unsupported keywords are rejected at definition time.
|
|||||||
`run(args, { services, signal })` resolves to `{ summary, data }`: one sentence
|
`run(args, { services, signal })` resolves to `{ summary, data }`: one sentence
|
||||||
for people and a structured object for programs. A tool may also return `images`,
|
for people and a structured object for programs. A tool may also return `images`,
|
||||||
each `{ mimeType, data }` with base64 data; the MCP adapter sends them as image
|
each `{ mimeType, data }` with base64 data; the MCP adapter sends them as image
|
||||||
content.
|
content. MCP results carry the summary and the data as JSON text, plus the data
|
||||||
|
as `structuredContent`, for clients that read only one of them.
|
||||||
|
|
||||||
`composeCatalog({ tools, services, replace, interceptors })` builds a catalog:
|
`composeCatalog({ tools, services, replace, interceptors })` builds a catalog:
|
||||||
|
|
||||||
|
|||||||
@@ -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 } }))
|
(await request('tools/call', { name: 'count', arguments: { n: 3 } }))
|
||||||
.result,
|
.result,
|
||||||
{
|
{
|
||||||
content: [{ type: 'text', text: '3 things.' }],
|
content: [
|
||||||
|
{ type: 'text', text: '3 things.' },
|
||||||
|
{ type: 'text', text: '{"n":3}' },
|
||||||
|
],
|
||||||
structuredContent: { n: 3 },
|
structuredContent: { n: 3 },
|
||||||
isError: false,
|
isError: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,8 +80,11 @@ export function createMcpServer({
|
|||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
// The data is repeated as JSON text for clients that do not read
|
||||||
|
// structuredContent.
|
||||||
content: [
|
content: [
|
||||||
{ type: 'text', text: result.summary },
|
{ type: 'text', text: result.summary },
|
||||||
|
{ type: 'text', text: JSON.stringify(result.data) },
|
||||||
...(result.images || []).map((item) => ({
|
...(result.images || []).map((item) => ({
|
||||||
type: 'image',
|
type: 'image',
|
||||||
data: item.data,
|
data: item.data,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ test('a snapshot returns the frame as an image with its credit', async () => {
|
|||||||
method: 'tools/call',
|
method: 'tools/call',
|
||||||
params: { name: 'get_cctv_snapshot', arguments: { camera_id: 'austin-1' } },
|
params: { name: 'get_cctv_snapshot', arguments: { camera_id: 'austin-1' } },
|
||||||
});
|
});
|
||||||
assert.deepEqual(response.result.content[1], {
|
assert.deepEqual(response.result.content[2], {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
data: 'iVBORw0KGgo=',
|
data: 'iVBORw0KGgo=',
|
||||||
mimeType: 'image/png',
|
mimeType: 'image/png',
|
||||||
|
|||||||
Reference in new issue
Block a user