When a proxied server returns an error with non-TextContent (e.g., ImageContent), ProxyTool.run() crashes with AttributeError.
The error path in proxy.py does:
if result.isError:
raise ToolError(cast(mcp.types.TextContent, result.content[0]).text)
cast() is a no-op at runtime — if content[0] is ImageContent or EmbeddedResource, accessing .text raises AttributeError.
Reproduction:
import mcp.types
result = mcp.types.CallToolResult(
isError=True,
content=[mcp.types.ImageContent(type="image", data="abc", mimeType="image/png")]
)
result.content[0].text # AttributeError: 'ImageContent' object has no attribute 'text'
Fix: check isinstance(content, TextContent) before accessing .text, fall back to str(content) for other types.
When a proxied server returns an error with non-TextContent (e.g., ImageContent),
ProxyTool.run()crashes withAttributeError.The error path in
proxy.pydoes:cast()is a no-op at runtime — ifcontent[0]isImageContentorEmbeddedResource, accessing.textraisesAttributeError.Reproduction:
Fix: check
isinstance(content, TextContent)before accessing.text, fall back tostr(content)for other types.