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 → FastMCP composition root for a narrative walkthrough of how the lifespan + tools wire together.
MCP server (FastMCP): lifespan owns the shared httpx session + NovelAIClient.
The server is a thin composition root over nai.NovelAIClient, built on the
FastMCP 4 framework (which itself runs on the MCP SDK v2). The lifespan creates
one long-lived httpx.AsyncClient (connection pooling, with Chrome TLS +
header fingerprint impersonation via create_http_client) and one
NovelAIClient; every MCP component receives them through dependency
injection (see deps) instead of reaching into the request context.
Tools, resources and prompts are attached to the shared mcp instance by
importing their modules at the bottom of this file: each one decorates mcp
at import time and imports mcp back from this module, which is safe because
mcp is already bound by then.
- novelai_image_mcp.server.INSTRUCTIONS¶
The server-level instructions an agent receives, describing the tools, the intended workflow and where generated images land.