NovelAI Image MCP

io.github.xinvxueyuan由 GitHub 帳號 xinvxueyuan 發布v0.7.1更新於 Oct 31, 2026

NovelAI image generation as MCP tools: txt2img, img2img, inpaint, upscale, Director, ControlNet.

已驗證STDIO僅桌面媒體與設計AI 與機器學習

概覽

AI 產生的概覽

把 NovelAI 影像生成能力開放給 AI 助理:文生圖、圖生圖、局部重繪、放大、Director 編輯與 ControlNet 標註。

可以做什麼
  • 生成與編輯影像:文生圖、帶強度/雜訊的圖生圖、需要遮罩的局部重繪,以及 4 倍放大
  • 呼叫 Director 工具(線稿、素描、去背、去除雜物、上色、表情)與 ControlNet 標註(hed、midas、塗鴉、mlsd、uniformer)
  • 輔助撰寫提示詞:標籤建議,以及把參考圖編碼成 vibe token
  • 檢視帳戶:訂閱狀態、Anlas 餘額、使用者資料,並在不呼叫 API 的情況下估算 Anlas 消耗
  • 透過資源檢視模型、取樣器與預設值,並讀回已產生的 PNG;影像以 base64 內容區塊回傳,同時存到磁碟
適用情境
適合在對話中讓助理產生或修改 NovelAI 影像,也適合圍繞 NovelAI 帳戶撰寫可重複的生成、放大與標註流程。
執行需求
以 stdio 在本機執行(透過 uvx 或 pip 安裝 PyPI 套件,或使用 Docker 映像)。需要 NovelAI 帳戶及 NOVELAI_TOKEN 持久 API 權杖,或 NOVELAI_USERNAME 加 NOVELAI_PASSWORD;需要連線到 NovelAI API 的網路。選用設定包括輸出目錄、預設模型、尺寸、步數、取樣器,以及帶 MCP_AUTH_TOKEN 的 HTTP 傳輸。
安裝前請注意
NOVELAI_TOKEN 是付費帳戶的憑證,應放在主機環境或密鑰參照中,不要寫進共用設定。生成會消耗 Anlas,也就是產生費用,建議先估算消耗。產生的 PNG 會寫入輸出目錄;選用的 HTTP 模式接受用戶端自報的路由標頭,這些標頭可被偽造,只應在可信閘道後方啟用。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 NovelAI Image MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

NovelAI Image MCP

Languages

English简体中文日本語
English简体中文日本語

[CI] [Docs] [License: MIT] [Python 3.13+] [uv] [REUSE status] [DeepWiki] [skills.sh]

[NovelAI Image MCP - MCP server for integrating NovelAI Image generation into AI | Product Hunt] [Featured on Lifto]

An MCP (Model Context Protocol) server that exposes NovelAI image generation to AI agents (Claude Desktop, Cline, custom agents, remote clients), plus a sync CLI and three skills.sh packages that teach those agents how to drive either surface.

Built on FastMCP 4 (the fastmcp framework over the MCP SDK v2 mcp>=2.3.0), it covers txt2img / img2img / inpaint, 4× upscale, Director tools (line art, emotion, background removal, …), ControlNet annotation, tag suggestions, vibe encoding and account subscription — all through the standard MCP tool interface.

📖 Documentation: xinvxueyuan.github.io/NovelAI-Image-MCP

Three ways to drive it

All three wrap the same async NovelAIClient; they differ in how you invoke it.

  • MCP tools — interactive agent sessions (Claude Desktop, Cline, …). The agent sees base64 Image content blocks.
  • CLI — shell scripting, CI jobs, one-off commands. Saves a PNG and prints its path; no image blocks.
  • Agent skills — portable instructions that tell an agent how to use the other two. They inherit the mode they drive.

Features

  • 11 MCP tools covering the full NovelAI image API surface.
  • 2 prompts + 3 resources + 1 resource template: house-style prompt drafting and tool sequencing (novelai_prompt_writer, novelai_image_workflow), plus novelai://models, novelai://samplers, novelai://defaults and novelai://outputs/{name} for discovering the model/sampler vocabulary and reading generated PNGs back.
  • Three agent skills (novelai-cli, novelai-mcp-tools, novelai-workflows) grouped as CLI / MCP Tools / Workflows, installable with one npx skills add command.
  • A sync typer CLI with six subcommands for scripting outside an MCP host.
  • Two transports: stdio (local agents) + HTTP (remote / multi-client), the latter optionally protected by a bearer token (MCP_AUTH_TOKEN).
  • Opt-in routing and audit (HTTP): a client that sends X-MCP-Insiders gets per-route output directories, per-route loggers and an append-only JSONL audit trail (prompts and credentials are never written verbatim). Without the header nothing changes. See Insiders header, routing and audit.
  • Structured results: enum-validated tool schemas, MCP tool annotations and ToolError for expected failures.
  • Dual image return: base64 Image content blocks (the agent sees the image) and PNG saved to disk (path returned as text).
  • Monorepo: uv workspace (Python) + pnpm workspace (Node tooling) orchestrated by Turbo; MIT-licensed, Docker-ready, GitHub Pages docs.

Quick start

1. Install the agent skills

bash
npx skills add --yes --global xinvxueyuan/NovelAI-Image-MCP

--yes skips the interactive picker; --global installs to ~/.agents/skills/ so every project on the machine can use them. Drop --global to install into the current project's .agents/skills/ instead. See Agent skills for what each skill covers.

2. Install the server (from source, development)

bash
# 1. Clonegit clone https://github.com/xinvxueyuan/NovelAI-Image-MCP.gitcd NovelAI-Image-MCP
# 2. Sync the uv workspace (installs server + docs + dev tools)uv sync
# 3. Configure credentialscp .env.example .env#   set NOVELAI_TOKEN=...  (preferred)#   or  NOVELAI_USERNAME + NOVELAI_PASSWORD
# 4. Run (stdio — for local agents)uv run python -m novelai_image_mcp serve
# 5. Or over HTTPMCP_TRANSPORT=http uv run python -m novelai_image_mcp serve#   → http://127.0.0.1:8000/mcp

3. Install the server (PyPI, runtime only)

bash
pip install novelai-image-mcpexport NOVELAI_TOKEN=pst-...novelai-image-mcp serve

Optional: Node tooling (contributors)

If you plan to contribute, install the cross-cutting Node toolchain (turbo, husky, markdownlint) via pnpm:

bash
corepack enable pnpm      # one-timepnpm install --frozen-lockfile

This wires the husky pre-commit + commit-msg hooks and gives you turbo / markdownlint-cli2 for local development. The MCP server has zero Node runtime dependencies — this step is only for contributors.

Connect an agent

The MCP server supports two transports (stdio + http), all configured under mcpServers:

stdio (local agent — Claude Desktop / Cline)

claude_desktop_config.json:

json
{  "mcpServers": {    "novelai-image": {      "type": "stdio",      "command": "uv",      "args": [        "run",        "--directory",        "/path/to/NovelAI-Image-MCP",        "python",        "-m",        "novelai_image_mcp",        "serve"      ],      "env": {        "NOVELAI_TOKEN": "${input:novelai_token}"      }    }  }}
Alternative: uvx (published package)
json
{  "mcpServers": {    "novelai-image": {      "command": "uvx",      "args": ["novelai-image-mcp", "serve"],      "env": { "NOVELAI_TOKEN": "pst-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }    }  }}

Set NOVELAI_TOKEN (or NOVELAI_USERNAME + NOVELAI_PASSWORD) in the host environment before launching — uvx inherits the parent shell env.

http (remote / Docker deployment)

After docker compose up --build (server listens on http://HOST:8000/mcp):

json
{  "mcpServers": {    "novelai-image-http": {      "type": "http",      "url": "http://127.0.0.1:8000/mcp",      "headers": {        "Authorization": "Bearer pst-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"      }    }  }}

Replace http://127.0.0.1:8000/mcp with your self-deployed endpoint (e.g. https://mcp.example.com/mcp behind a TLS-terminating reverse proxy). Swap the literal token placeholder for a host-managed secret reference if your MCP host supports one (Claude Desktop, Cline, etc. expose this via their own secrets UI).

Standard FastMCP entry points

The repository ships a fastmcp.json whose source points at apps/server/mcp_server.py, so plain FastMCP tooling works too (run from the repository root, after uv sync):

bash
uv run fastmcp run fastmcp.json                     # stdio serveruv run fastmcp inspect                              # list tools/prompts/resourcesuv run --directory apps/server fastmcp dev inspector mcp_server.py   # Inspector

fastmcp.json has no environment block on purpose: the workspace virtualenv already has the package installed, and an environment entry would make FastMCP build a second, throwaway environment for every run.

CLI (sync, for scripting)

The CLI exposes six subcommands: serve, generate, upscale, director, annotate, info.

bash
# Run the MCP server (stdio by default; -t http for the HTTP transport)novelai-image-mcp serve
# Text-to-image — prints one absolute PNG path per generated imagenovelai-image-mcp generate --prompt "a cat, masterpiece" --width 832 --height 1216
# 4x upscale (V5 model only)novelai-image-mcp upscale --image ./in.png --factor 4
# Director tools: lineart | sketch | bg-removal | declutter | colorize | emotionnovelai-image-mcp director lineart ./photo.png --defry 5
# ControlNet annotation: hed | midas | fake_scribble | mlsd | uniformernovelai-image-mcp annotate ./photo.png --model hed
# Subscription / Anlas balancenovelai-image-mcp info
novelai-image-mcp --help

Install it with pip install novelai-image-mcp, run it ad hoc with uvx novelai-image-mcp <command>, or from the monorepo with uv run --directory apps/server novelai-image-mcp <command>. Every image-producing command saves a PNG to NOVELAI_OUTPUT_DIR (default outputs) and prints its path; -o / --output-dir overrides the directory for one invocation. The full flag list lives in the novelai-cli skill.

Agent skills

Three skills.sh packages ship in skills/. They teach AI agents (Claude Code, Codex, GitHub Copilot, Cursor, …) how to drive the CLI and the MCP tools, so you do not have to paste docs into the conversation.

bash
npx skills add --yes --global xinvxueyuan/NovelAI-Image-MCP
mermaid
graph TD    Q{How will you drive NovelAI?}    Q -->|"Interactive session with an MCP host"| MCP["MCP tools<br/>11 tools over stdio / http"]    Q -->|"Shell script, CI job, one-off command"| CLI["CLI<br/>novelai-image-mcp generate ..."]    Q -->|"Let an agent pick the right one"| SK["Agent skills<br/>novelai-cli / novelai-mcp-tools / novelai-workflows"]    SK --> MCP    SK --> CLI
SkillGroupWhat it teaches
novelai-cliCLITyper CLI commands (serve, generate, upscale, director, annotate, info) for shell scripting
novelai-mcp-toolsMCP ToolsThe 11 MCP tools — model selection, parameters, return shape, Anlas cost
novelai-workflowsWorkflowsMulti-step creative pipelines (txt2img→upscale, annotate→img2img, Director edits)

Skills and the CLI/MCP tools are complementary, not either/or: install all three and the agent picks the mode that fits the task. Each skill points at the other two instead of repeating them. See the Agent skills docs for the group descriptions and a mode-comparison table.

Repository layout

This is a uv + pnpm monorepo:

text
NovelAI-Image-MCP/├── apps/│   ├── server/                 # MCP server (the installable PyPI package)│   │   ├── src/novelai_image_mcp/   # 11 MCP tools + NovelAI HTTP client│   │   ├── tests/│   │   ├── docker/              # smoke-test entrypoint│   │   ├── Dockerfile           # built with repo root as context│   │   └── pyproject.toml       # ruff / pyright / pytest config│   └── docs/                    # Sphinx documentation site│       ├── source/              # MyST Markdown + conf.py│       ├── Makefile│       └── pyproject.toml├── skills/                      # skills.sh packages (novelai-cli, ...)├── skills.sh.json               # skill groupings for skills.sh├── .github/                     # workflows, CODEOWNERS, issue templates├── pyproject.toml               # uv workspace root (virtual)├── uv.lock                      # single shared lockfile├── pnpm-workspace.yaml          # pnpm workspace declaration├── pnpm-lock.yaml               # Node toolchain lockfile├── turbo.json                   # cross-workspace task graph├── package.json                 # root scripts + dev toolchain└── docker-compose.yml           # local container orchestration

See CONTRIBUTING.md for the developer guide and apps/docs/source/ for the full documentation source.

Tools

ToolDescription
generate_imageText-to-image (V3 / V4 / V4.5 / V5 models, character prompts; vibes V4/V4.5 only)
image_to_imageImage-to-image with strength/noise
inpaintInpainting (requires an inpaint model + mask)
upscale_image4× upscale (V5 model)
director_toolLine art / sketch / bg-removal / declutter / colorize / emotion
annotate_imageControlNet annotation (hed, midas, scribble, mlsd, uniformer)
suggest_tagsPrompt tag suggestions
encode_vibeEncode a reference image into a vibe token
get_subscriptionAccount subscription + Anlas balance
get_user_dataAccount user data
estimate_anlas_costEstimate Anlas cost for a generation (no API call)

See the tools reference on the docs site for parameters and examples.

Configuration

All settings are environment variables (see .env.example). Key ones:

VariableDefaultNotes
NOVELAI_TOKEN—Persistent API token (preferred auth)
NOVELAI_USERNAME / NOVELAI_PASSWORD—Access-key login (argon2id)
NOVELAI_OUTPUT_DIRoutputsWhere generated PNGs are saved
NOVELAI_DEFAULT_MODELnai-diffusion-4-5-fullModel id used when a tool call omits one
NOVELAI_DEFAULT_WIDTH / NOVELAI_DEFAULT_HEIGHT832 / 1216Default image size
NOVELAI_DEFAULT_STEPS28Default sampling steps (1–50)
NOVELAI_DEFAULT_SCALE5.0Default CFG scale (≤20)
NOVELAI_DEFAULT_SAMPLERk_euler_ancestralDefault sampler
NOVELAI_UPSCALE_MODELnai-diffusion-5-fullModel for the standalone 4× upscaler (V5 line only)
NOVELAI_TIMEOUT120HTTP timeout in seconds
NOVELAI_IMAGE_BASE_URLhttps://image.novelai.netConsolidated API host for generation and account endpoints
NOVELAI_LEGACY_IMAGE_BASE_URLhttps://api.novelai.netPrimary API host; only /ai/annotate-image still uses it
MCP_TRANSPORTstdiostdio or http (streamable-http is a legacy alias)
MCP_HOST / MCP_PORT / MCP_PATH127.0.0.1 / 8000 / /mcpFor the HTTP transport
MCP_AUTH_TOKEN—When set, the HTTP transport requires Authorization: Bearer <token>
MCP_ROUTE_TOKENS—JSON {"<route>": "<token>"} route-bound bearer tokens (401 on route mismatch)
MCP_INSIDERS_HEADERX-MCP-InsidersHeader a client opts in with (HTTP only)
MCP_MODEL_HEADERS / MCP_AGENT_HEADERS / MCP_CLIENT_HEADERSsee belowJSON lists of routing candidates, first non-empty wins
MCP_INSIDERS_DISABLED_FEATURES[]Operator kill switch (JSON list), wins over any client
MCP_ROUTE_SCOPED_OUTPUTtrueWrite images under <output>/<route>/ while routing is active
MCP_AUDIT_LOG_PATH<output>/audit.jsonlAppend-only JSONL audit trail
MCP_LOG_LEVEL—DEBUG/INFO/WARNING/ERROR/CRITICAL

List- and dict-valued settings are read as JSON: MCP_MODEL_HEADERS='["X-MCP-Model"]' works, while A,B raises a settings error and an empty value is not valid JSON.

Routing candidate defaults (JSON lists, first non-empty header wins):

  • MCP_MODEL_HEADERS — ["X-MCP-Model", "X-MCP-Model-Name"]
  • MCP_AGENT_HEADERS — ["X-MCP-Agent-ID", "X-MCP-Agent", "X-MCP-Agent-Source"]
  • MCP_CLIENT_HEADERS — ["X-MCP-Client", "X-MCP-Client-Session-Id"]

Insiders header and routing

Over HTTP a client can opt in to experimental behaviour and declare which route, model, agent and session a request belongs to:

text
X-MCP-Insiders: trueX-MCP-Agent-ID: team-aX-MCP-Model: nai-diffusion-5-full

The server then writes that request's images under <NOVELAI_OUTPUT_DIR>/team-a/, emits one line to the novelai_image_mcp.audit.team-a logger, and appends one record to the audit JSONL (the record keeps a prompt's length and a truncated SHA-256, never the prompt, and never a credential header or an image payload).

Nothing changes without the header -- no scoped directory, no audit file, no tool added or removed -- with one deliberate exception: director_tool's emotion and emotion_level parameters now require the opt-in and fail with a ToolError otherwise (see the CHANGELOG). Routing headers are client-supplied and forgeable, so grant the opt-in only behind a trusted gateway.

Full contract: Insiders header, routing and audit.

NovelAI API reference: image.novelai.net/docs

Development

The project is a uv + pnpm monorepo orchestrated by Turbo. See CONTRIBUTING.md for the full setup; the short version:

bash
uv sync                              # Python workspace (server + docs + dev)pnpm install --frozen-lockfile       # Node toolchain (turbo + husky + markdownlint)
pnpm check                           # lint + typecheck + test (all workspaces)pnpm docs:build                       # build the docs sitepnpm server:serve                     # run the MCP serverpnpm docs:serve                       # sphinx-autobuild with live reload

Per-member commands (via uv):

bash
uv run --directory apps/server ruff check src tests    # lintuv run --directory apps/server -m pyright              # typecheckuv run --directory apps/server -m pytest               # tests

Docker

bash
docker compose up --build      # builds and runs the server (HTTP transport)

The Dockerfile lives at apps/server/Dockerfile but the build context is the repository root (so uv can resolve the workspace graph). See docker-compose.yml.

Documentation

The Sphinx documentation site is built with Furo + MyST Markdown and auto-deploys to GitHub Pages on every push to main:

License

MIT — see LICENSE. Per-file SPDX annotations live in REUSE.toml. Contributions are subject to the Developer Certificate of Origin (the commit-msg hook signs off commits automatically).

Links

來源:README.md,提交 1a60690

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:軟體包安裝失敗。

版本歷史

7
  1. v0.7.1最新Oct 31, 2026
  2. v0.7.0Oct 22, 2026
  3. v0.6.3Oct 19, 2026
  4. v0.6.2Oct 18, 2026
  5. v0.5.1Oct 13, 2026
  6. v0.5.0Oct 10, 2026
  7. v0.4.0Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分