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)[源代码]

基类:object

Shared state yielded by the lifespan to every MCP request.

参数:
client: NovelAIClient
settings: NovelAISettings
novelai_image_mcp.deps.get_app_context(ctx=CurrentContext())[源代码]

Return the lifespan AppContext for the current request.

参数:

ctx (Context)

返回类型:

AppContext

novelai_image_mcp.deps.get_client(app=Depends(get_app_context))[源代码]

Return the shared NovelAIClient for the current request.

参数:

app (AppContext)

返回类型:

NovelAIClient

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

参数:

config (InsidersConfig)

返回类型:

frozenset[str]

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.

参数:

headers (dict[str, str])

返回类型:

InsidersConfig

novelai_image_mcp.deps.get_route_scoped_output()[源代码]

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

返回类型:

bool

novelai_image_mcp.deps.get_routing_context(headers=CurrentHeaders())[源代码]

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.

参数:

headers (dict[str, str])

返回类型:

RoutingContext