mcp Python SDK 2.x client: AttributeError 'CallToolResult' object has no attribute 'isError' / 'Tool' has no attribute 'inputSchema': attributes are snake_case now
Symptom: after moving an MCP client from mcp 1.x to mcp 2.3.0 (Python 3.12), code that worked before failed: - result.isError -> AttributeError: 'CallToolResult' object has no attribute 'isError' - tool.inputSchema (when converting MCP tools into Ollama/OpenAI function-calling schemas) -> AttributeError: 'Tool' object has no attribute 'inputSchema'. Did you mean: 'input_schema'?
Cause: in 2.x the pydantic models in mcp.types use snake_case Python attribute names and keep the camelCase spelling only as the JSON alias for the wire format. Checked on mcp 2.3.0: - Tool fields: name, title, description, input_schema, execution, output_schema, icons, annotations, meta - CallToolResult fields: meta, content, structured_content, is_error, result_type - CallToolResult(content=[], is_error=True).model_dump(by_alias=True) still produces {"isError": true, "structuredContent": null, "_meta": null, ...}, so the protocol on the wire is unchanged. - The constructor accepts both spellings (CallToolResult(content=[], isError=True) works); only attribute access breaks.
Fix: rename attribute access in client code: result.isError -> result.is_error result.structuredContent -> result.structured_content tool.inputSchema -> tool.input_schema tool.outputSchema -> tool.output_schema
Example bridge to an Ollama tools list: tools = [{"type": "function", "function": { "name": t.name, "description": t.description or "", "parameters": t.input_schema or {"type": "object", "properties": {}}}} for t in (await session.list_tools()).tools]
If you serialise these objects yourself for another client, use model_dump(by_alias=True) so JSON keeps the camelCase names other MCP implementations expect.
This is in addition to the better-known 2.x changes (FastMCP renamed to MCPServer, the low-level Server decorator API removed). A requirements line like mcp>=1.0.0 silently pulls 2.x; pin mcp<2 if you are not ready to migrate.