deps¶
Dependency providers shared by every MCP component: AppContext, get_app_context and get_client.
See also
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)[source]¶
Bases:
objectShared state yielded by the lifespan to every MCP request.
- Parameters:
client (NovelAIClient)
settings (NovelAISettings)
- client: NovelAIClient¶
- settings: NovelAISettings¶
- novelai_image_mcp.deps.get_app_context(ctx=CurrentContext())[source]¶
Return the lifespan
AppContextfor the current request.- Parameters:
ctx (Context)
- Return type:
- novelai_image_mcp.deps.get_client(app=Depends(get_app_context))[source]¶
Return the shared
NovelAIClientfor the current request.- Parameters:
app (AppContext)
- Return type:
- novelai_image_mcp.deps.get_effective_features(config=Depends(get_insiders_config))[source]¶
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.- Parameters:
config (InsidersConfig)
- Return type:
- novelai_image_mcp.deps.get_insiders_config(headers=CurrentHeaders())[source]¶
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.- Parameters:
- Return type:
- novelai_image_mcp.deps.get_route_scoped_output()[source]¶
True when generated images belong under a per-route subdirectory.
- Return type:
- novelai_image_mcp.deps.get_routing_context(headers=CurrentHeaders())[source]¶
Resolve the routing context for the current request.
Routing is attempted only when the
model-routingfeature is active; otherwise the disabled context is returned and every routing field staysNone.- Parameters:
- Return type: