[v2] Use the documented middleware accessor in the tracing opt-out example

Open Beginner friendly
#3,934 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
91/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

Open docs/run/opentelemetry.md at the “Turning it off” example and compare it with the middleware accessor described in docs/advanced/middleware.md. Replace both uses of mcp._lowlevel_server.middleware with mcp.middleware, retaining the provisional API warning and OpenTelemetryMiddleware import. Done when the example uses the documented accessor in both places and preserves those notes.

Written by the indexing model from the issue text.

Description

v2
What happened?

While integrating the SDK into mcpstat, I needed to disable the SDK's inbound server spans while preserving other middleware.

The "Turning it off" example uses mcp._lowlevel_server.middleware. This works, but MCPServer exposes the same list through the documented mcp.middleware accessor.

Could the example use mcp.middleware in both places, retaining the existing provisional API warning? This would avoid accessing the internal _lowlevel_server attribute.

AI assisted with source review and wording.

What did you expect?

Use mcp.middleware in both places in the example, retaining the existing warning about the provisional middleware API and OpenTelemetryMiddleware import.

This would be a documentation-only change. I would be happy to contribute it if the maintainers consider it useful.

Code to reproduce

SDK version

Integration: mcp 2.3.0. Documentation and accessor checked on main at 77001c9.

Area

Documentation

Dominant language
Python
Stars
25k
Forks
4.2k
Avg merge
10m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/python-sdk

All issues in modelcontextprotocol/python-sdk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.