Stop advertising MCP_* env vars for MCPServer settings; drop pydantic-settings (#3170)
This commit is contained in:
parent
7163d8263f
commit
3212591946
2 changed files with 24 additions and 19 deletions
|
|
@ -34,7 +34,6 @@ You don't need to know any of this to use the SDK, but if you're wondering what
|
|||
* `mcp-types`: every protocol type (requests, results, content blocks) as its own package, versioned in lockstep with the SDK. Every `from mcp_types import ...` in these docs is this package.
|
||||
* [`anyio`](https://anyio.readthedocs.io/): the async runtime. The whole SDK is written against anyio, so it runs on either `asyncio` or `trio`.
|
||||
* [`pydantic`](https://docs.pydantic.dev/): what every `mcp_types` model is built on, plus all schema generation and validation.
|
||||
* [`pydantic-settings`](https://docs.pydantic.dev/latest/concepts/pydantic_settings/): server configuration via `MCP_*` environment variables and `.env` files.
|
||||
* [`httpx2`](https://pypi.org/project/httpx2/): the HTTP client behind the Streamable HTTP and SSE *client* transports, with server-sent events support built in.
|
||||
* [`starlette`](https://www.starlette.io/), [`uvicorn`](https://www.uvicorn.org/), [`sse-starlette`](https://pypi.org/project/sse-starlette/), and [`python-multipart`](https://pypi.org/project/python-multipart/): the HTTP *server* transports.
|
||||
* [`jsonschema`](https://pypi.org/project/jsonschema/): validates a tool's structured output against its declared output schema.
|
||||
|
|
|
|||
|
|
@ -684,6 +684,22 @@ app = Starlette(routes=[Mount("/", app=mcp.streamable_http_app(json_response=Tru
|
|||
|
||||
If you were mutating these via `mcp.settings` after construction (e.g., `mcp.settings.port = 9000`), pass them to `run()` / `sse_app()` / `streamable_http_app()` instead — these fields no longer exist on `Settings`. The `debug` and `log_level` parameters remain on the constructor.
|
||||
|
||||
### `MCP_*` environment variables and `.env` files are no longer read
|
||||
|
||||
The `Settings` docstring advertised configuration via `MCP_*` environment variables and a `.env` file (e.g. `MCP_DEBUG=true`), but constructor arguments have always taken precedence, so those environment variables never took effect. `Settings` is now a plain Pydantic model rather than a `pydantic-settings` `BaseSettings`, and `pydantic-settings` is no longer a dependency of the SDK.
|
||||
|
||||
If you want environment-driven configuration, read the environment yourself and pass the values to the constructor:
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
from mcp.server.mcpserver import MCPServer
|
||||
|
||||
mcp = MCPServer("Demo", debug=os.environ.get("MCP_DEBUG") == "true")
|
||||
```
|
||||
|
||||
If your own code uses `pydantic-settings`, add it to your project's dependencies directly.
|
||||
|
||||
### Streamable HTTP request bodies are limited to 4 MiB
|
||||
|
||||
V2 applies a 4 MiB default limit to Streamable HTTP POST bodies and returns HTTP 413 before parsing
|
||||
|
|
|
|||
Loading…
Reference in a new issue