posit-dev / posit-dev/mcptools
No support for structuredContent in tool results (MCP spec 2025-06-18)
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 196
- Forks
- 21
- Avg merge
- 1h 14m
- Merged PRs (30d)
- 1
Description
Problem
The MCP spec (2025-06-18) defines a structuredContent field on tool results — a JSON object that provides machine-readable structured output alongside the human-readable content text.
Currently, as_tool_call_result() only produces content (text-only). There's no path for structuredContent.
Expected
When a tool returns a list/data structure, the result should include both:
{
"content": [
{"type": "text", "text": "{\"auc\": 0.92, \"tss\": 0.81}"}
],
"structuredContent": {
"auc": 0.92,
"tss": 0.81
}
}
content: Human-readable text (for backwards compatibility)structuredContent: Machine-readable JSON (for clients that support it)
Per spec: "For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block."
Use Case
SDM MCP server with ~70 tools. Each tool produces structured results (model metrics, file paths, area statistics). Clients that understand structuredContent get validated, typed data. Others fall back to text. This is the biggest quality-of-life improvement for tool-heavy servers.
Fix
In as_tool_call_result(), if the tool result is a list (and not an ellmer Content object), include it as structuredContent alongside the text serialization.
Related to #103 (outputSchema) — if a tool declares an outputSchema, the structuredContent should be validated against it.
Contributor guide
No contributing guide indexed for this repository
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 by locating and reading as_tool_call_result(), focusing on how list results and ellmer Content objects are currently serialized. Add structuredContent for list results while retaining serialized text in content, and preserve existing behavior for Content objects. Verify that tool results contain both representations and consider the relationship with outputSchema in issue #103.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100