-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
According to the MCP spec, a tool call response that provides structuredContent
is not required to also provide content
. It is only recommended. Thus content
may be empty, which causes pydantic-ai to see the tool call response as empty.
MCP Specification section 5.2.6 Structured Content:
For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block.
While it is a valid argument that the content
field should be provided by the server, this appears to be controlled on a per-tool basis, and not by the SDK in use, which makes it harder to enforce. Since the MCP spec clearly indicates that content
is not required, and the language even implies that it's leagacy, I figure pydantic-ai should be supporting and preferring structuredContent
when present.
Specifically the issue is here, where only content
is supported:
content = [await self._map_tool_result_part(part) for part in result.content] |
References
No response