Title: Define and document the public Python SDK API surface · Issue #1701 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Define and document the public Python SDK API surface · Issue #1701 · modelcontextprotocol/python-sdk
X Title: Define and document the public Python SDK API surface · Issue #1701 · modelcontextprotocol/python-sdk
Description: Description Summary The Python SDK exposes a variety of classes and functions across packages and submodules. Some are clearly meant to be public, others are internal but not marked as such. Tests and user code sometimes rely on internal...
Open Graph Description: Description Summary The Python SDK exposes a variety of classes and functions across packages and submodules. Some are clearly meant to be public, others are internal but not marked as such. Tests ...
X Description: Description Summary The Python SDK exposes a variety of classes and functions across packages and submodules. Some are clearly meant to be public, others are internal but not marked as such. Tests ...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1701
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Define and document the public Python SDK API surface","articleBody":"### Description\n\n## Summary\n\nThe Python SDK exposes a variety of classes and functions across packages and submodules. Some are clearly meant to be public, others are internal but not marked as such. Tests and user code sometimes rely on internals (e.g. private attributes).\n\nThis makes it hard for users to know what is safe to depend on and hard for maintainers to evolve internals without risking breakage.\n\n## Problems\n\n- **Ambiguous boundaries:** It’s not always clear which symbols in `mcp.*` and subpackages are part of the supported public API.\n- **Private attribute usage:** Some tests/examples access internal attributes (e.g. `_mcp_server`), which blurs the line between public and internal.\n- **Versioning risk:** Changes to internal structures can accidentally turn into breaking changes for users who imported them directly.\n\n## Proposal\n\n1. **Define an explicit public API**\n\n - Use `__all__` and/or a `mcp.public` (or similar) module to list what is considered stable public API.\n - Document the intended public surface in the README or a dedicated “API Reference”.\n\n2. **Mark internals clearly**\n\n - Move clearly internal modules into an `_internal` subpackage where possible.\n - Use leading underscores and documentation to indicate non-public attributes.\n\n3. **Gradual tightening**\n\n - Update examples and tests to use only public APIs where feasible.\n - Where users are expected to interact with lower-level constructs, expose them via documented, stable paths.\n\n## Why this matters\n\n- **Stability:** Users can rely on documented APIs without fear of accidental breakage.\n- **Refactorability:** Internal changes become safer when the public surface is well-defined.\n- **Onboarding:** New users can quickly see which APIs are meant for them.\n\n## Acceptance criteria\n\n- [ ] A documented list of public, supported APIs for the Python SDK.\n- [ ] Internal modules/types are clearly marked (e.g., `_internal` packages) where appropriate.\n- [ ] Examples and tests avoid relying on private attributes when a public alternative exists.\n- [ ] Future changes can be evaluated against this public surface for compatibility.\n\n\n### References\n\n_No response_","author":{"url":"https://github.com/dgenio","@type":"Person","name":"dgenio"},"datePublished":"2025-11-28T15:39:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1701/python-sdk/issues/1701"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1d147c8e-e159-5e93-5801-ff10cd603b54 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0A6:DC32E:F0F0FF:13DE0C4:6A5BC1EC |
| html-safe-nonce | d4e072a2b585d59647210b2f64562dac82e17f576fc89408752953dc33ea7803 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEE2OkRDMzJFOkYwRjBGRjoxM0RFMEM0OjZBNUJDMUVDIiwidmlzaXRvcl9pZCI6IjI1MTIyODg4MjYwNTc4MDIyMjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7afdda1fc03940501f23357984651d5c9f6ab843340c967a3fc4149c3dc11f34 |
| hovercard-subject-tag | issue:3675296025 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/1701/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80b7fa05ffb49f269fb8c0f2fb21599af259ed8d954c230acd99d699e7a185f8/modelcontextprotocol/python-sdk/issues/1701 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80b7fa05ffb49f269fb8c0f2fb21599af259ed8d954c230acd99d699e7a185f8/modelcontextprotocol/python-sdk/issues/1701 |
| og:image:alt | Description Summary The Python SDK exposes a variety of classes and functions across packages and submodules. Some are clearly meant to be public, others are internal but not marked as such. Tests ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dgenio |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width