novelai_image_mcp.server¶
MCP 服务器的组合根。通过 MCP lifespan 持有共享的 httpx.AsyncClient 与
NovelAIClient,注册全部 11 个工具,并在启动时选择传输方式。
参见
架构 → FastMCP 组合根 了解 lifespan 与工具如何接线在一起的叙述性说明。
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.