The CallToolResult#structuredContent type is insufficient to represent list or array of objects.
Closed this issue · 2 comments
tzolov commented
Bug description
CallToolResult#structuredContent is typed as Map<String, Object>, preventing structured responses like List<DomainObject> or DomainObject[].
Environment
- Affects: 0.12.x, 0.13.x
- Breaking Change: Yes
Expected behavior
Support all valid JSON response types including arrays and lists.
tzolov commented
Apparently this an issue inherited from the MCP Spec: This MCP issue is addressed here: modelcontextprotocol/modelcontextprotocol#834
Currently the MCP CallToolResult schema reference defines structuredContent)?: { [key: string]: unknown };. Later is not capable to represent JSON array types as pointed in #834
Kehrlann commented
As discussed today, the MCP spec type examples seem written in Typescript, so you can experiment here. e.g.
interface CallToolResult {
_meta?: { [key: string]: unknown };
//content: ContentBlock[];
isError?: boolean;
structuredContent?: { [key: string]: unknown };
[key: string]: unknown;
}
// e.g. this does not compile
const x: CallToolResult = {
structuredContent: [{"x": 42}]
}