fix: cap mcp below 2.0 and stop a failed mcp import breaking import any_agent - #951
Merged
Merged
Conversation
11 tasks
Codecov Report❌ Patch coverage is
... and 42 files with indirect coverage changes 🚀 New features to boost your workflow:
|
11 tasks
…any_agent` mcp 2.0 renamed `mcp.client.streamable_http.streamablehttp_client` to `streamable_http_client`. The dependency was declared `mcp>=1.5.0` with no upper bound, so a fresh install resolves mcp 2.x and `import any_agent` fails outright with `NameError: name 'MCPTool' is not defined`. Two separate problems, fixed separately: 1. Cap the dependency at `mcp>=1.5.0,<2`. This is what unbreaks installs. any-agent is in soft deprecation and is not migrating to mcp 2.x. 2. `mcp_client.py` already tries to degrade gracefully: it records `missing_mcp_error` and raises a readable ImportError from `model_post_init`. That guard never ran, because `ClientSession` and `MCPTool` are referenced in annotations evaluated at class-creation time, so the module raised NameError during import instead. Bind both names to placeholders in the except branch so the guard works as intended. Note that (2) alone does not fix the import under mcp 2.x, because mozilla-ai-tinyagent 0.1.1 carries the identical bug and is imported first via `any_agent.config`. It needs the same fix upstream; the cap in (1) is what protects any-agent users today. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
njbrake
force-pushed
the
fix/mcp-v2-import-break
branch
from
September 21, 2026 15:39
d4410a2 to
b842b7c
Compare
11 tasks
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.
Description
mcp 2.0 renamed
streamablehttp_clienttostreamable_http_client. The dependency was uncapped (mcp>=1.5.0), so a fresh install resolves mcp 2.x andimport any_agentfails withNameError: name 'MCPTool' is not defined.Two separate fixes:
mcp>=1.5.0,<2. This is what unbreaks installs. Soft deprecation means no migration to mcp 2.x for now.mcp_client.pyrecordsmissing_mcp_errorand raises a readable ImportError frommodel_post_init, but that guard never ran:ClientSessionandMCPToolappear in annotations evaluated at class creation, so import raised NameError first. Both now get placeholders in theexcept ImportErrorbranch.Fix 2 alone is not enough.
mozilla-ai-tinyagent0.1.1 has the identical bug and is imported first viaany_agent.config, so the cap is what protects users today. Reported upstream at mozilla-ai/tinyagent#22.Verified against a real mcp 2.2.0 install: with both copies guarded,
import any_agentsucceeds andMCPClient(...)raises the intended ImportError.PR Type
Relevant issues
Upstream: mozilla-ai/tinyagent#22
Checklist
Note on "existing tests pass":
tests/unitgives 278 passed with 4 failures that are present onmainbefore this change and unrelated to it (any-llm-sdkno longer has agatewayprovider, plus two OpenAI-path tests).AI Usage Information
AI Model used: Claude Opus 5
AI Developer Tool used: Claude Code
Any other info you'd like to share: Written under @njbrake's direction. The reasoning and decisions are his.
I am an AI Agent filling out this form (check box if true)