Repository navigation
[Bug Fix] Replace non-existent McpError with FastMCPError in MCP tools - #239
Merged
bruuuuuceliu merged 1 commit intoApr 15, 2026
Merged
Conversation
`McpError` does not exist in any released version of fastmcp (tested 1.0 through 3.2.4). This causes an ImportError in `tools/mcp.py` that cascades through the entire package — because `tools/__init__.py` eagerly imports MCPToolkit, every import touching agents, workflows, or prompts fails with: ImportError: cannot import name 'McpError' from 'fastmcp.exceptions' Changes: - Replace `McpError` with `FastMCPError` (the actual base exception class in fastmcp) in `evoagentx/tools/mcp.py` (import + except) - Update `docs/tutorial/mcp.md` to match - Pin `fastmcp>=2.2.0,<3.0` in pyproject.toml — 2.2.0 is the first version that exports both `Client` and `ClientError` Fixes ANative-Lab#238
bruuuuuceliu
approved these changes
Apr 15, 2026
bruuuuuceliu
left a comment
Collaborator
There was a problem hiding this comment.
FastMCPError is the right base class from fastmcp's own exception hierarchy — good fix to align with that. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #238
evoagentx/tools/mcp.pyimportsMcpErrorfromfastmcp.exceptions, but this class does not exist in any released version offastmcp(tested 1.0 through 3.2.4). Sincetools/__init__.pyeagerly importsMCPToolkit, thisImportErrorcascades and breaks all core imports — agents, workflows, and prompts all fail.Root Cause
The import chain that fails:
fastmcp.exceptionsexportsFastMCPErroras the base exception class — notMcpError. Here's the actual exception hierarchy in fastmcp 2.2.0:FastMCPErrorException(base for all MCP errors)ClientErrorExceptionToolErrorFastMCPErrorResourceErrorFastMCPErrorPromptErrorFastMCPErrorValidationErrorFastMCPErrorChanges
evoagentx/tools/mcp.pyMcpError→FastMCPError(import on line 25, except clause on line 247)docs/tutorial/mcp.mdpyproject.tomlfastmcp>=2.2.0,<3.0(2.2.0 is the first version with bothClientandClientError)Reproduction
Testing
After the fix:
Compatibility
Tested across fastmcp versions:
ClientClientErrorFastMCPErrorThe pin
>=2.2.0,<3.0ensures a working range.