novelai_image_mcp.server¶
The MCP server composition root. Owns the shared httpx.AsyncClient and
NovelAIClient via an MCP lifespan, registers all 11 tools, and selects
the transport at startup.
See also
Architecture → MCPServer composition root
for a narrative walkthrough of how the lifespan + tools wire together.
MCP server: lifespan owns the shared httpx session + NovelAIClient.
The server is a thin composition root over nai.NovelAIClient. The lifespan
creates one long-lived httpx.AsyncClient (connection pooling) and one
NovelAIClient; every tool reads them from ctx.request_context.lifespan_context
(the MCP v2 Context API). Transport is selected at runtime from
MCP_TRANSPORT (stdio by default, streamable-http for remote deployments).
- class novelai_image_mcp.server.AppContext(client, settings)[source]¶
Bases:
objectShared state yielded by the lifespan to every tool invocation.
- Parameters:
client (NovelAIClient)
settings (NovelAISettings)
- client: NovelAIClient¶
- settings: NovelAISettings¶