Skip to content

fix(mcp): decouple AnyUrl import from mcp dependency#19695

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a
May 4, 2026
Merged

fix(mcp): decouple AnyUrl import from mcp dependency#19695
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented May 4, 2026

Salvage of #16043 onto current main.

Summary

AnyUrl was imported inside the same try block as mcp.client.auth. When the mcp package isn't installed, AnyUrl was undefined and _build_client_metadata() raised NameError at call time (rather than degrading gracefully). Move the AnyUrl import into its own try/except + add pytest.importorskip('mcp') on the 3 tests that exercise the helper.

Validation

scripts/run_tests.sh tests/tools/test_mcp_oauth.py -> passed

Original PR: #16043

AnyUrl was imported inside the same try block as mcp.client.auth, so
when the mcp package was not installed, AnyUrl was undefined and
_build_client_metadata raised NameError at runtime.

Moved the AnyUrl import to its own try/except block so it's available
whenever pydantic is installed (which is a core dependency), regardless
of whether the mcp SDK is present.

Also added pytest.importorskip('mcp') to the three
test_build_client_metadata tests that exercise _build_client_metadata,
since that function depends on OAuthClientMetadata from the mcp package.
@teknium1 teknium1 merged commit 135b4c8 into main May 4, 2026
7 of 10 checks passed
@teknium1 teknium1 deleted the hermes/hermes-8c54fd4a branch May 4, 2026 11:42
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets tool/mcp MCP client and OAuth labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants