Let FastMCPError propagate unchanged from managers#2698
Conversation
When a dependency raises ToolError or other FastMCPError subclasses, they were getting wrapped in RuntimeError with a generic "Failed to resolve dependency" message. This made it hard to use ToolError for validation in dependencies. Now FastMCPError subclasses propagate unchanged, matching the pattern used elsewhere in the codebase. Closes #2633 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Uses pydocket 0.16.0's `names=` parameter for explicit registration keys: - Tools/prompts: registered by `.key` - Resources/templates: registered by `.name` Removes `_create_named_fn_wrapper` function. Closes #2642
|
CLosing - too many conflicts. We will cherry pick instead |
WalkthroughThis pull request consolidates exception handling across multiple manager and utility modules to treat FastMCPError as the primary exception type requiring special propagation. Changes include replacing specific exception handlers (PromptError, ResourceError, ToolError) with FastMCPError handlers in prompt_manager, resource_manager, and tool_manager. The dependency resolver is updated to re-raise FastMCPError unchanged instead of wrapping it as RuntimeError. Error middleware now unwraps exceptions to map to root causes. Additionally, the server removes the Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (6)
🧰 Additional context used📓 Path-based instructions (1)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (4)📓 Common learnings📚 Learning: 2025-12-21T21:37:55.031ZApplied to files:
📚 Learning: 2025-11-26T21:51:44.174ZApplied to files:
📚 Learning: 2025-12-21T21:37:55.031ZApplied to files:
🧬 Code graph analysis (6)src/fastmcp/server/server.py (3)
src/fastmcp/server/middleware/error_handling.py (1)
src/fastmcp/resources/resource_manager.py (2)
src/fastmcp/prompts/prompt_manager.py (1)
src/fastmcp/server/dependencies.py (1)
src/fastmcp/tools/tool_manager.py (1)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge 2.x fixes to main, including #2697, which ensures FastMCP errors propogate. Some of these are redundant but the new commit history will simplify future merges from the release branch.