Open
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
When using tools via MCP servers, the call_tool
method returns the raw CallToolResult
object instead of its content, causing inconsistency with how regular tools work:
Without MCP (regular Tool):
ToolReturnPart(tool_name='get_weather_forecast', content='Weather Forecast Response\nAction: search, Domain: weather-...')
With MCP Server:
ToolReturnPart(tool_name='get_weather_forecast', content=CallToolResult(meta=None, content=[TextContent(type='text', text='Weather Forecast Response\nAction: search, Domain: weather-...')]))
This inconsistency causes issues for those who expect the same structure regardless of how tools are implemented.
Proposed Solution
Modify the call_tool
method in the MCPServer
class to return result.content
instead of the raw CallToolResult
object. This would ensure consistent behavior between MCP tools and regular tools.
Affected Components
pydantic_ai_slim/pydantic_ai/mcp.py
### Example Code
```Python
Python, Pydantic AI & LLM client version
python3.11
pydantic-ai==0.0.52
openai:gpt-4o,llama3.1:8b