API リファレンス

novelai_image_mcp の公開 Python API に対する autodoc 生成のリファレンスです。 各ページは apps/server/src/novelai_image_mcp/ 配下のソースを直接イントロスペクトするため、常に現在の main ブランチを反映します。

モジュール

モジュール

説明

server

FastMCP のコンポジションルート + ライフスパン + トランスポート選択

deps

AppContext と Depends プロバイダー

mcp_auth

オプションの HTTP ベアラートークン認証(MCP_AUTH_TOKEN)

middleware

ツール呼び出しのログ、ルーティング監査、実験的ツールのゲート

routing

ヘッダー駆動のルーティング: ルート解決とサニタイズ

insiders

X-MCP-Insiders オプトインヘッダーのパーサー

features

insiders の機能レジストリとその解決規則

audit

追記専用の JSONL 監査トレイル: レコードの形、秘匿化、上限

prompts

2 つのプロンプトテンプレート

resources

novelai://... リソース

schemas

構造化出力モデル

settings

NovelAISettings + MCPServerSettings

tools

11 個の MCP ツール関数

nai クライアント

NovelAI HTTP クライアント(NovelAIClient + enum + モデル)

API を直接使う

nai/ サブパッケージは MCP に依存しません — 単体で利用できます:

import asyncio
import httpx
from novelai_image_mcp.nai import create_novelai_client, GenerationRequest, Action, Model
from novelai_image_mcp.settings import NovelAISettings

async def main():
    settings = NovelAISettings(token="pst-...")
    async with httpx.AsyncClient(timeout=settings.timeout) as http_client:
        client = create_novelai_client(settings, http_client=http_client)
        request = GenerationRequest(
            prompt="1girl, masterpiece",
            action=Action.GENERATE,
            model=Model.V4_5,
            width=832, height=1216,
        )
        images = await client.generate(request)
        await client.aclose()

asyncio.run(main())

型チェック

API は完全に型注釈されており、standard モードの pyright を通過します。IDE (Pyright、Pylance、mypy)は、このドキュメントに表示されるのと同じ型情報を提示します。

関連項目