anthropics / anthropics/claude-agent-sdk-python
Allow SDK MCP Servers to return structured data
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 1.3k
- Avg merge
- 2d 31m
- Merged PRs (30d)
- 1
Description
Currently it only allows either a text or image response due to how it collects the results from the tool:
https://github.com/anthropics/claude-agent-sdk-python/blob/main/src/claude_agent_sdk/__init__.py#L322
When I want to return JSON now, I have to JSON marshal it, and then return that, causing a lot of extra tokens and also makes it harder to read for the Agent when it goes over the amount of tokens and has to write away the tool results to a file, because everything is written away to a single line in this format.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/claude_agent_sdk/__init__.py around line 322, where MCP tool results are collected and limited to text or image responses. Trace that result handling and verify that structured JSON can pass through without callers manually serializing it, including readable output when results are written to a file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100