We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 278d141 commit 2445540Copy full SHA for 2445540
pydantic_ai_slim/pydantic_ai/mcp.py
@@ -627,8 +627,11 @@ async def _map_tool_result_part(
627
return self._get_content(resource)
628
elif isinstance(part, mcp_types.ResourceLink):
629
result = await self.read_resource(str(part.uri))
630
- # If resource not found, return an empty string as it's impossible to fetch anyway
631
- return result if result is not None else ''
+ # Rather than hide an invalid resource link, we raise an error so it's consistent with any
+ # other error that could happen during resource reading.
632
+ if result is None:
633
+ raise MCPError(message=f'Invalid ResourceLink {part.uri} returned by tool', code=-32002)
634
+ return result
635
else:
636
assert_never(part)
637
0 commit comments