deps

Dependency providers shared by every MCP component: AppContext, get_app_context and 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)[source]

Bases: object

Shared state yielded by the lifespan to every MCP request.

Parameters:
client: NovelAIClient
settings: NovelAISettings
novelai_image_mcp.deps.get_app_context(ctx=CurrentContext())[source]

Return the lifespan AppContext for the current request.

Parameters:

ctx (Context)

Return type:

AppContext

novelai_image_mcp.deps.get_client(app=Depends(get_app_context))[source]

Return the shared NovelAIClient for the current request.

Parameters:

app (AppContext)

Return type:

NovelAIClient

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_FEATURES is the operator kill switch and wins over anything a client sends.

Parameters:

config (InsidersConfig)

Return type:

frozenset[str]

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:

headers (dict[str, str])

Return type:

InsidersConfig

novelai_image_mcp.deps.get_route_scoped_output()[source]

True when generated images belong under a per-route subdirectory.

Return type:

bool

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-routing feature is active; otherwise the disabled context is returned and every routing field stays None.

Parameters:

headers (dict[str, str])

Return type:

RoutingContext