Skip to content

Conversation

ppcantidio
Copy link
Contributor

✨ Summary

Fixes #1989 – runtime errors raised by the MCP backend now surface as ModelRetry, allowing the caller’s retry logic to work correctly.

Additional improvements bundled into the same patch:
1. Export hygiene – replace the accidental string‐literal all with a tuple so IDEs and static analysers discover the five public server classes.
2. Type-annotation & formatting clean-ups – wrap long generics/context-manager signatures to the Black default line length for readability.

@ppcantidio
Copy link
Contributor Author

@DouweM can u review please?

@Kludex
Copy link
Member

Kludex commented Jun 17, 2025

Please revert the cosmetic updates.

@ppcantidio ppcantidio force-pushed the fix/mcp-raise-error branch from 06ad9d2 to 7f83dd5 Compare June 17, 2025 10:38
@ppcantidio ppcantidio force-pushed the fix/mcp-raise-error branch from 7f83dd5 to 8a66f59 Compare June 17, 2025 10:40
@ppcantidio
Copy link
Contributor Author

Please revert the cosmetic updates.

done

@DouweM DouweM self-assigned this Jun 17, 2025
@DouweM DouweM changed the title fix(mcp): handle McpError in tool call and improve code readability Handle McpError from MCP tool calls Jun 17, 2025
@DouweM DouweM merged commit 388ecc2 into pydantic:main Jun 17, 2025
18 checks passed
@Kludex
Copy link
Member

Kludex commented Jun 18, 2025

Which kind of error would be solvable retrying tho?

@prithugoswami
Copy link

@Kludex maybe the ones where a wrong argument was supplied? Or where there is a scope to adjust the parameters to get a better response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

call_tool returns un-recoverable McpError; should surface a ModelRetry so the agent can self-correct
4 participants