API reference

Autodoc-generated reference for the public Python API of novelai_image_mcp. These pages introspect the in-tree source under apps/server/src/novelai_image_mcp/, so they always reflect the current main branch.

Modules

Module

Description

server

MCPServer composition root + lifespan

settings

NovelAISettings + MCPServerSettings

tools

The 11 MCP tool functions

nai client

The NovelAI HTTP client (NovelAIClient + enums + models)

Using the API directly

The nai/ subpackage is MCP-agnostic — you can use it standalone:

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())

Type checking

The API is fully type-annotated and passes pyright in standard mode. IDEs (Pyright, Pylance, mypy) will surface the same type information you see in these docs.

See also