Skip to content

fix(databricks-mcp): pin mcp dependency to <2.0.0 - #457

Merged
fanzeyi merged 1 commit into
databricks:mainfrom
fanzeyi:fix/databricks-mcp-pin-mcp
Jul 30, 2026
Merged

fix(databricks-mcp): pin mcp dependency to <2.0.0#457
fanzeyi merged 1 commit into
databricks:mainfrom
fanzeyi:fix/databricks-mcp-pin-mcp

Conversation

@fanzeyi

@fanzeyi fanzeyi commented Jul 30, 2026

Copy link
Copy Markdown
Member

mcp 2.0.0 removes the legacy streamablehttp_client symbol from mcp.client.streamable_http, which causes databricks-mcp 0.9.0 to fail at import time on any fresh install that resolves to mcp 2.x.

This change adds an upper bound mcp>=1.13.0,<2.0.0 so the dependency resolver picks a compatible 1.x release, and bumps databricks-mcp to 0.9.1.

  • Added CHANGELOG entry
  • Automated tests / manual verification: unit tests pass with uv run pytest tests/unit_tests -q and lint passes with uv run ruff check .

@fanzeyi
fanzeyi force-pushed the fix/databricks-mcp-pin-mcp branch 2 times, most recently from 8d8825b to 4a303b1 Compare July 30, 2026 20:39
mcp 2.0.0 removes the legacy `streamablehttp_client` symbol from

`mcp.client.streamable_http`, which causes `databricks-mcp 0.9.0` to fail

at import time on any fresh install that resolves to mcp 2.x. Add an

upper bound `mcp>=1.13.0,<2.0.0` so the dependency resolver picks a

compatible 1.x release, and bump `databricks-mcp` to 0.9.1.


Also fix a pre-existing typecheck failure in

`integrations/langchain/tests/unit_tests/test_chat_models.py` by using

`InputTokensDetails.model_construct(...)` for the `cache_write_tokens`

field, which is not accepted as a constructor argument in some openai

versions used in CI.


Signed-off-by: Pi Agent <pi-agent@databricks.com>
@fanzeyi
fanzeyi force-pushed the fix/databricks-mcp-pin-mcp branch from 4a303b1 to 6c1143c Compare July 30, 2026 20:46
@fanzeyi
fanzeyi enabled auto-merge (squash) July 30, 2026 20:48
@fanzeyi
fanzeyi merged commit 8b75621 into databricks:main Jul 30, 2026
46 checks passed
fanzeyi added a commit to fanzeyi/databricks-ai-bridge that referenced this pull request Jul 31, 2026
PR databricks#457 pinned `mcp>=1.13.0,<2.0.0` as a stopgap because mcp 2.0.0 removed
the legacy `streamablehttp_client` symbol (and reworked the transport/session
and auth APIs), which broke `databricks-mcp` at import time on fresh installs
that resolved to mcp 2.x.

This is the proper fix: make the code compatible with mcp 2.x while staying
backward compatible with mcp 1.x, then remove the install-time cap so future
mcp majors are not blocked at resolve time.

## Summary
- Detect the installed mcp major (`_MCP_V2 = try: from mcp import Client`) and
  route both code paths through a single `_open_mcp_session()` helper:
  - mcp 2.x: attach `DatabricksOAuthClientProvider` (now an `httpx2.Auth`) to an
    `httpx2.AsyncClient` handed to `streamable_http_client(url, http_client=...)`,
    wrapped in `mcp.Client` (which performs the initialize handshake itself).
  - mcp 1.x: `streamablehttp_client(url, auth=...)` + `ClientSession` +
    explicit `initialize()`, as before.
- `oauth_provider.py`: no code change needed (subclassing `OAuthClientProvider`
  picks up `httpx2.Auth` automatically on v2); docstring updated to show both
  usage patterns.
- Widen the dependency to `mcp>=1.13.0` (no upper bound).
- Bump `databricks-mcp` to 0.9.2.
- Update tests for mcp 2.x API renames while keeping them runnable on 1.x:
  build `Tool` via `model_validate({"inputSchema": ...})` (2.x renamed the field
  to `input_schema`), import `MCPError` (renamed from `McpError`) with a fallback,
  and patch the version-agnostic `_open_mcp_session`. The integration-test
  `raw_mcp_session` helper is now version-aware.

## Test Plan
- `uv run pytest tests/unit_tests/` — 113 passed against mcp 1.24.0.
- Same suite — 113 passed against mcp 2.0.0.
- `ty check` (ty 0.0.23) clean against mcp 2.0.0; `ruff check` / `ruff format` clean.
- Verified the real v2 wiring (`httpx2.AsyncClient` + `streamable_http_client` +
  `Client`) constructs and reaches the transport layer end-to-end.

## Type of change
- [x] Bug fix (non-breaking change which fixes an issue)

## Changelog
databricks-mcp is now compatible with mcp 2.x (and remains compatible with mcp 1.x).

Signed-off-by: Zeyi (Rice) Fan <zeyi.f@databricks.com>
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.

2 participants