Fix docs/release follow-ups from the mcp-types package split (#2977)
This commit is contained in:
parent
1b92efedc8
commit
3a8da8c0c3
2 changed files with 71 additions and 35 deletions
|
|
@ -9,27 +9,32 @@ nav = mkdocs_gen_files.Nav()
|
|||
root = Path(__file__).parent.parent.parent
|
||||
src = root / "src"
|
||||
|
||||
for path in sorted(src.rglob("*.py")):
|
||||
module_path = path.relative_to(src).with_suffix("")
|
||||
doc_path = path.relative_to(src).with_suffix(".md")
|
||||
full_doc_path = Path("api", doc_path)
|
||||
# `src/mcp-types` is a distribution directory, not an import package, so each
|
||||
# package's dotted module path is taken relative to its own parent: deriving it
|
||||
# from `src/` would emit the unimportable `mcp-types.mcp_types.*`.
|
||||
for package in (src / "mcp", src / "mcp-types" / "mcp_types"):
|
||||
base = package.parent
|
||||
for path in sorted(package.rglob("*.py")):
|
||||
module_path = path.relative_to(base).with_suffix("")
|
||||
doc_path = path.relative_to(base).with_suffix(".md")
|
||||
full_doc_path = Path("api", doc_path)
|
||||
|
||||
parts = tuple(module_path.parts)
|
||||
parts = tuple(module_path.parts)
|
||||
|
||||
if parts[-1] == "__init__":
|
||||
parts = parts[:-1]
|
||||
doc_path = doc_path.with_name("index.md")
|
||||
full_doc_path = full_doc_path.with_name("index.md")
|
||||
elif parts[-1].startswith("_"):
|
||||
continue
|
||||
if parts[-1] == "__init__":
|
||||
parts = parts[:-1]
|
||||
doc_path = doc_path.with_name("index.md")
|
||||
full_doc_path = full_doc_path.with_name("index.md")
|
||||
elif parts[-1].startswith("_"):
|
||||
continue
|
||||
|
||||
nav[parts] = doc_path.as_posix()
|
||||
nav[parts] = doc_path.as_posix()
|
||||
|
||||
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
|
||||
ident = ".".join(parts)
|
||||
fd.write(f"::: {ident}")
|
||||
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
|
||||
ident = ".".join(parts)
|
||||
fd.write(f"::: {ident}")
|
||||
|
||||
mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root))
|
||||
mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root))
|
||||
|
||||
with mkdocs_gen_files.open("api/SUMMARY.md", "w") as nav_file:
|
||||
nav_file.writelines(nav.build_literate_nav())
|
||||
|
|
|
|||
|
|
@ -213,10 +213,11 @@ The WebSocket transport has been removed: `mcp.client.websocket.websocket_client
|
|||
### `mcp.types` moved to the `mcp-types` package
|
||||
|
||||
The protocol wire types now live in a standalone distribution, `mcp-types`, imported as
|
||||
`mcp_types`. It depends only on `pydantic`, so code that just needs to (de)serialize MCP
|
||||
traffic can install it without the full SDK. The `mcp` package depends on `mcp-types` and
|
||||
`mcp_types`. Its only runtime dependencies are `pydantic` and `typing-extensions`, so code
|
||||
that just needs to (de)serialize MCP traffic can install it without the full SDK. The `mcp` package depends on `mcp-types` and
|
||||
continues to re-export the type names at the top level, so `from mcp import Tool` is
|
||||
unchanged. Only the `mcp.types` submodule and `mcp.shared.version` were removed.
|
||||
unchanged. Only the `mcp.types` submodule and `mcp.shared.version` were removed. The
|
||||
package's API reference is at [`mcp_types`](api/mcp_types/index.md).
|
||||
|
||||
**Why:** keeping the wire types in their own package lets tooling and lightweight clients
|
||||
depend on the protocol schema without pulling in `httpx`, `starlette`, `uvicorn`, and the
|
||||
|
|
@ -225,18 +226,18 @@ rest of the server/transport stack.
|
|||
**Before (v1):**
|
||||
|
||||
```python
|
||||
from mcp.types import Tool, CallToolResult
|
||||
from mcp.types import Tool, Resource
|
||||
from mcp.shared.version import LATEST_PROTOCOL_VERSION
|
||||
```
|
||||
|
||||
**After (v2):**
|
||||
|
||||
```python
|
||||
from mcp_types import Tool, CallToolResult
|
||||
from mcp_types import Tool, Resource
|
||||
from mcp_types.version import LATEST_PROTOCOL_VERSION
|
||||
|
||||
# Top-level re-exports are unchanged:
|
||||
from mcp import Tool, CallToolResult
|
||||
# Names `mcp` already re-exported at the top level are unchanged:
|
||||
from mcp import Tool, Resource
|
||||
```
|
||||
|
||||
### Removed type aliases and classes
|
||||
|
|
@ -814,7 +815,7 @@ async def my_tool(ctx: Context[MyLifespanState]) -> str: ...
|
|||
|
||||
### Version constants
|
||||
|
||||
`SUPPORTED_PROTOCOL_VERSIONS` is deprecated — it's now the union of `HANDSHAKE_PROTOCOL_VERSIONS` (initialize-handshake versions) and `MODERN_PROTOCOL_VERSIONS` (per-request-envelope versions). If you were using it to mean "versions the initialize handshake accepts", switch to `HANDSHAKE_PROTOCOL_VERSIONS`. Named scalars derived from these tuples are now exported alongside them — `LATEST_HANDSHAKE_VERSION`, `LATEST_MODERN_VERSION`, `OLDEST_SUPPORTED_VERSION` — so prefer those over indexing the tuples directly.
|
||||
`SUPPORTED_PROTOCOL_VERSIONS` is deprecated — it's now the union of `HANDSHAKE_PROTOCOL_VERSIONS` (initialize-handshake versions) and `MODERN_PROTOCOL_VERSIONS` (per-request-envelope versions). If you were using it to mean "versions the initialize handshake accepts", switch to `HANDSHAKE_PROTOCOL_VERSIONS`. Named scalars derived from these tuples are now exported alongside them — `LATEST_HANDSHAKE_VERSION`, `LATEST_MODERN_VERSION`, `OLDEST_SUPPORTED_VERSION` — so prefer those over indexing the tuples directly. All of these live in `mcp_types.version` (previously `mcp.shared.version`): `from mcp_types.version import HANDSHAKE_PROTOCOL_VERSIONS`.
|
||||
|
||||
### `ProgressContext` and `progress()` context manager removed
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue