diff --git a/README.md b/README.md index ba4cf20..8821bdd 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ The current `fastmcp.Context` is resolvable within DI via the pre-built `fastmcp | Symbol | Description | |---|---| -| `setup_di(server, container, *, manage_lifespan=True)` | Attaches the container to the server and adds the DI middleware. The server's lifespan opens the container at startup and closes it with `close_async()` at shutdown. When several apps share one container, exactly one of them should own its lifespan: pass `manage_lifespan=False` to every other `setup_di`, or the first app to stop closes the container for the rest. At startup it raises `TypeError` for a `FromDI` used inside `Annotated`. Raises `RuntimeError` when called a second time for the same server. Returns the container | +| `setup_di(server, container, *, manage_lifespan=True)` | Attaches the container to the server and adds the DI middleware. The server's lifespan opens the container at startup and closes it with `close_async()` at shutdown. When the server is mounted in another app whose lifespan runs it, let that app own the container and pass `manage_lifespan=False` here (see [Sharing a container with FastAPI](https://modern-di.modern-python.org/integrations/fastmcp/#sharing-a-container-with-fastapi)). When apps that share a container run with separate lifecycles, pass `manage_lifespan=False` to every `setup_di` and open and close the container yourself with `async with container:`, or the first app to stop closes it for the rest. At startup it raises `TypeError` for a `FromDI` used inside `Annotated`. Raises `RuntimeError` when called a second time for the same server. Returns the container | | `FromDI(dependency)` | Parameter default that resolves a provider (or type) from the request container. Raises `RuntimeError` naming `setup_di` when no request container is active, including in a background task (`task=True`), which FastMCP runs outside middleware | | `fetch_di_container(server)` | Returns the root container attached to the server. Raises `RuntimeError` when `setup_di` was not called | | `fastmcp_context_provider` | `ContextProvider` for the current `fastmcp.Context` (`REQUEST` scope) |