Skip to content

mcp integration breaks on mcp 2.x: _supported_versions has no upper bound #19439

Description

@maxrogers-to

ddtrace 4.8.2 through 4.13.0rc3, mcp 2.0.0, py3.14.

_supported_versions() in ddtrace/contrib/internal/mcp/patch.py returns
{"mcp": ">=1.10.0"} with no upper bound. mcp 2.0.0 dropped mcp.shared.session, so
the version check passes and patch() then dies on the import.

repro:

pip install ddtrace==4.12.2 mcp==2.0.0
DD_TRACE_ENABLED=true python -c "import ddtrace.auto; import mcp"

File ".../ddtrace/contrib/internal/mcp/patch.py", line 288, in patch
    from mcp.shared.session import BaseSession
ModuleNotFoundError: No module named 'mcp.shared.session'

mcp.types and mcp.client.session are still there, it's only mcp.shared.session
that went away.

not fatal, the patch failure gets swallowed, but it's a traceback on every boot and no
mcp spans either way.

DD_TRACE_SAFE_INSTRUMENTATION_ENABLED=true doesn't catch it, 2.0.0 satisfies the
declared spec.

pip install mcp pulls 2.x now, so anything unpinned lands here:
https://github.com/modelcontextprotocol/python-sdk/releases/tag/v2.0.0

those release notes also tell people to pin <2 if they haven't migrated, which is what
the spec should be doing.

working around it with DD_PATCH_MODULES=mcp:false. still on main and 4.13.0rc3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions