Configuration¶
All runtime configuration is via environment variables (read by
pydantic-settings in novelai_image_mcp.settings). The
canonical reference is .env.example
in the repository root.
Loading order¶
Process environment (highest priority)
.envfile in the current working directoryBuilt-in defaults (lowest priority)
The .env file is parsed as UTF-8; unknown keys are ignored; variable
names are case-insensitive (NOVELAI_TOKEN and novelai_token are
equivalent).
NovelAI credentials¶
Variable |
Default |
Required |
Notes |
|---|---|---|---|
|
— |
one of |
Persistent API token (preferred). Get it from https://novelai.net → Account. |
|
— |
one of |
Username (email) for access-key login. |
|
— |
one of |
Account password. Combined with |
Important
Set either NOVELAI_TOKEN or the NOVELAI_USERNAME + NOVELAI_PASSWORD
pair. The server raises RuntimeError at startup if neither is present
(see NovelAISettings.has_credentials).
Endpoints¶
Variable |
Default |
Notes |
|---|---|---|
|
|
Image generation / Director / upscale endpoint. |
|
|
Account / subscription / tag-suggestion endpoint. |
|
|
HTTP timeout for any single NovelAI request. |
Tip
Override NOVELAI_IMAGE_BASE_URL to point at a local mock (e.g.
http://localhost:9000) during integration testing. The tests in
apps/server/tests/ use respx
instead and don’t need this.
Generation defaults¶
These tune the defaults used by generate_image (and any other tool that
accepts the same parameters). They are overridable per tool call.
Variable |
Default |
Range |
Notes |
|---|---|---|---|
|
|
See |
V3 / V4 / V4.5 model id. |
|
|
64–49152, multiple of 64 |
Image width in pixels. |
|
|
64–49152, multiple of 64 |
Image height in pixels. |
|
|
1–50 |
Sampler iterations. |
|
|
0–20 |
Classifier-free guidance scale. |
|
|
See |
Sampler id. |
Client¶
Variable |
Default |
Range |
Notes |
|---|---|---|---|
|
|
1–1024 |
Vibe-transfer encoding cache size. Encoding the same reference twice hits the cache instead of re-calling the API. |
Output¶
Variable |
Default |
Notes |
|---|---|---|
|
|
Directory where generated PNGs are saved. Relative paths resolve against the server’s working directory. The directory is created on demand. |
MCP transport¶
Variable |
Default |
Range |
Notes |
|---|---|---|---|
|
|
|
How the server exposes itself to clients. |
|
|
any bind address |
Bind host for |
|
|
1–65535 |
Bind port for |
|
|
path string |
HTTP path for the streamable-http endpoint. Full URL: |
Warning
The default MCP_HOST=127.0.0.1 binds to localhost only. To expose the
server to other machines on your LAN, set MCP_HOST=0.0.0.0 — and put it
behind TLS termination or an authenticated reverse proxy. The MCP
streamable-http transport does not implement authentication.
Putting it all together¶
A production-grade .env for a remote streamable-http deployment:
# ── Auth ──
NOVELAI_TOKEN=pst-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ── Generation defaults (Opus tier, high quality) ──
NOVELAI_DEFAULT_MODEL=nai-diffusion-4-5-full
NOVELAI_DEFAULT_WIDTH=1024
NOVELAI_DEFAULT_HEIGHT=1024
NOVELAI_DEFAULT_STEPS=28
NOVELAI_DEFAULT_SCALE=5.0
NOVELAI_DEFAULT_SAMPLER=k_euler_ancestral
# ── Output (persist to a Docker volume) ──
NOVELAI_OUTPUT_DIR=/app/outputs
# ── Transport ──
MCP_TRANSPORT=streamable-http
MCP_HOST=0.0.0.0
MCP_PORT=8000
MCP_PATH=/mcp
# ── Client ──
NOVELAI_VIBE_CACHE_ENTRIES=128
NOVELAI_TIMEOUT=180
Environment in Docker¶
The Dockerfile
reads from .env via docker-compose.yml’s env_file: directive. To
override a single variable at run time without editing .env:
docker compose run -e MCP_PORT=9000 mcp
For Kubernetes, mount the env file as a Secret or use a ConfigMap /
Secret-aware env provider.
See also¶
Transports — stdio vs streamable-http trade-offs