INNER CODE UNIT · Python

create_mcp_server

kubernetes-sigs/agent-sandbox · clients/integrations/mcp-server/k8s_agent_sandbox_mcp_server/server.py:45

def create_mcp_server(settings: Settings | None = None):

    settings = settings or Settings()

    @asynccontextmanager
    async def lifespan(server: FastMCP):

        client = AsyncSandboxClient(
            connection_config=settings.connection,
            cleanup=False,
        )
        # The yielded mapping reaches tools via ctx.lifespan_context but is not
        # published on the ASGI app, so probe routes cannot read it. Stash what
        # they need on the server object, which routes reach as
        # request.app.state.fastmcp_server. Before this runs, /readyz correctly
        # reports "starting".
        server.sandbox_client = client
        server.probe_settings = settings

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…