spring-projects / spring-projects/spring-ai
CallToolResult: support EmbeddedResources
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Using org.springframework.ai.tool.annotation.Tool with return of io.modelcontextprotocol.spec.McpSchema.CallToolResult does not work for io.modelcontextprotocol.spec.McpSchema.EmbeddedResource;
Limitation is probably inside org.springframework.ai.mcp.McpToolUtils, which only provides ImageContent and TextContent but not io.modelcontextprotocol.spec.McpSchema.EmbeddedResource;
return new SharedSyncToolSpecification(tool, (exchangeOrContext, request) -> {
try {
String callResult = toolCallback.call(ModelOptionsUtils.toJsonString(request.arguments()),
new ToolContext(Map.of(TOOL_CONTEXT_MCP_EXCHANGE_KEY, exchangeOrContext)));
if (mimeType != null && mimeType.toString().startsWith("image")) {
return new McpSchema.CallToolResult(List
.of(new McpSchema.ImageContent(List.of(Role.ASSISTANT), null, callResult, mimeType.toString())),
false);
}
return new McpSchema.CallToolResult(List.of(new McpSchema.TextContent(callResult)), false);
}
catch (Exception e) {
return new McpSchema.CallToolResult(List.of(new McpSchema.TextContent(e.getMessage())), true);
}
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in org.springframework.ai.mcp.McpToolUtils and trace how CallToolResult content is handled for ImageContent and TextContent. Compare that path with McpSchema.EmbeddedResource and verify that tool results containing embedded resources are supported without regressing the existing content types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100