deps¶
所有 MCP 组件共享的依赖提供者:AppContext、get_app_context 与 get_client。
参见
Dependency-injected values shared by the MCP components.
FastMCP resolves parameters declared as Depends(get_...) (or annotated with
Context) when the component runs, and hides them from the component's input
schema. Tools, resources and prompts therefore declare exactly what they need
instead of digging into the request context themselves. AppContext is the
single value the server lifespan yields, and every provider reads from it.
The insiders/routing providers read the request headers instead: an HTTP client opts into the experimental surface with the configured insiders header and describes its route with the configured routing headers. Over stdio there is no HTTP request at all, so the header lookup resolves to an empty mapping, the insiders surface stays disabled and behaviour is unchanged.
- class novelai_image_mcp.deps.AppContext(client, settings)[源代码]¶
基类:
objectShared state yielded by the lifespan to every MCP request.
- 参数:
client (NovelAIClient)
settings (NovelAISettings)
- client: NovelAIClient¶
- settings: NovelAISettings¶
- novelai_image_mcp.deps.get_app_context(ctx=CurrentContext())[源代码]¶
Return the lifespan
AppContextfor the current request.- 参数:
ctx (Context)
- 返回类型:
- novelai_image_mcp.deps.get_client(app=Depends(get_app_context))[源代码]¶
Return the shared
NovelAIClientfor the current request.- 参数:
app (AppContext)
- 返回类型:
- novelai_image_mcp.deps.get_effective_features(config=Depends(get_insiders_config))[源代码]¶
Return the names of the features active for this request.
The header decides per request;
MCP_INSIDERS_DISABLED_FEATURESis the operator kill switch and wins over anything a client sends.- 参数:
config (InsidersConfig)
- 返回类型:
- novelai_image_mcp.deps.get_insiders_config(headers=CurrentHeaders())[源代码]¶
Parse the insiders opt-in header for the current request.
CurrentHeaders()resolves to an empty mapping when there is no HTTP request, so over stdio the insiders surface stays disabled and behaviour is unchanged.- 参数:
- 返回类型:
- novelai_image_mcp.deps.get_route_scoped_output()[源代码]¶
True when generated images belong under a per-route subdirectory.
- 返回类型: