Skip to content

Conversation

TheEterna
Copy link
Contributor

  • corrected the return format for structured content results, following the MCP protocol.
  • fix variable name

- corrected the return format for structured content results, following the MCP protocol.
- fix variable name
@TheEterna TheEterna force-pushed the refactor/issue-67-Update-the-AbstractMcpToolMethodCallback.convertValueToCallToolResult branch from 2ab3ee2 to 5dbad11 Compare October 4, 2025 15:35
import io.modelcontextprotocol.spec.McpSchema.CallToolRequest;
import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
import io.modelcontextprotocol.spec.McpSchema.*;
import io.modelcontextprotocol.spec.McpSchema.CallToolResult.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid wildcards

if (this.returnMode == ReturnMode.STRUCTURED) {
String jsonOutput = JsonParser.toJson(result);
Object structuredOutput = JsonParser.fromJson(jsonOutput, Object.class);
callToolResultBuilder.structuredContent(structuredOutput);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structured content is available only to JSON so you can do that :

return CallToolResult.builder().structuredContent(structuredOutput).addTextContent(jsonOutput).build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants