You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d8959ef
Browse filesBrowse the repository at this point in the historyBrowse files
fix: support valid JSON value in tool structured content output (#551)
- Change CallToolResult.structuredContent type from Map<String,Object> to Object
to support both objects and arrays
- Update JsonSchemaValidator to validate any Object type, not just Maps
- Add test cases for array-type structured output validation
- Fix type casting in existing tests to handle the more generic Object type
- Deprecate CallToolResult constructors in favor of builder pattern
- Update server implementations to use CallToolResult builder
This allows tools to return arrays as structured content, not just objects,
which is required by the MCP specification for tools with array-type output schemas.
It is realated to MPC spec fix: modelcontextprotocol/modelcontextprotocol#834Fixes#550
BREAKING CHANGE!
Migration Guide:
----------------
1. If you're accessing CallToolResult.structuredContent():
- Add explicit casting when you know it's a Map:
Before: result.structuredContent().get("key")
After: ((Map<String,Object>) result.structuredContent()).get("key")
- Or check the type first:
if (result.structuredContent() instanceof Map) {
Map<String,Object> map = (Map<String,Object>) result.structuredContent();
// use map
} else if (result.structuredContent() instanceof List) {
List<?> list = (List<?>) result.structuredContent();
// use list
}
2. If you're creating CallToolResult instances:
- Switch to using the builder pattern:
Before: new CallToolResult(content, isError, structuredContent)
After: CallToolResult.builder()
.content(content)
.isError(isError)
.structuredContent(structuredContent)
.build()
3. If you're implementing JsonSchemaValidator:
- Update your validate() method signature:
Before: validate(Map<String,Object> schema, Map<String,Object> structuredContent)
After: validate(Map<String,Object> schema, Object structuredContent)
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
0 commit comments