Skip to content

Allow SDK MCP Servers to return structured data #695

@jerbob92

Description

@jerbob92

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions