pixiv-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pixiv-mcpsearch Pixiv for 信濃 水着 and download 2 illustrations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pixiv-mcp
独立的 Pixiv 插画搜索 / 过滤 / 下载工具,提供三种用法:
MCP server(stdio):给 Codex CLI、Claude Desktop / Claude Code、Cursor、Grok Bot 等任意支持 MCP 的 agent 用
CLI:
pixiv-mcp search 信浓 泳装 2,方便测试,也给不支持 MCP 的 agent 用TypeScript 库:
import { PixivService, pixivSearch } from 'pixiv-mcp'
它是从 QQ bot 插件(dsh-qqbot 的 src/pixiv)里拆出来的,过滤规则一条没改,不依赖 QQ bot、cordis/cosmokit、antigravity、会话或传输层。规则细节见 pixiv-feature-spec.md。
运行时依赖只有 @modelcontextprotocol/sdk 和 zod。网络请求用 Node 自带的 fetch,不处理图片、不用浏览器。
安装
需要 Node.js ≥ 20.3(推荐 22 或 24)。
发布包里已经带了编译好的 dist/,服务器上不需要 TypeScript 或 vitest:
tar xzf pixiv-mcp.tgz && cd pixiv-mcp
npm ci --omit=dev # 只装运行时依赖(约 26 MB)
node dist/bin.js --help开发 / 改代码:
npm ci
npm run build # tsc → dist/,bin 入口为 dist/bin.js
npm test # 会先 build,再跑 vitest(含 stdio 端到端测试)
npm run typecheck想要全局命令 pixiv-mcp 时,在目录里执行 npm link 或 npm i -g .。
低内存启动(2 vCPU / 1 GB 机器)
node --max-old-space-size=96 --max-semi-space-size=1 dist/bin.js serve实测(Linux,Node 24,接本地模拟的 Pixiv):
启动参数 | 空闲 RSS | 跑 20 轮搜索+下载后 RSS(峰值) |
| 77 MB | 105 MB(107) |
| 69 MB | 94 MB(100) |
再加 | 59 MB | 68 MB(70),但速度慢很多,不推荐 |
光是加载官方 MCP SDK 的 stdio 部分(它会带上 zod 协议 schema)就要约 64 MB RSS,裸 Node 约 41 MB,所以用官方 SDK 时 60 MB 以下基本做不到。原图下载是流式写盘的,不会把整张图读进内存。
Related MCP server: ZeroChan MCP
环境变量
变量 | 说明 |
| Pixiv refresh token。配了且没设 |
| 网页登录态,加到网页 AJAX 请求的 Cookie 上 |
|
|
| 数据目录,默认 |
| 图片目录,默认 |
| 每个 session 的冷却,默认 |
| 全局同时下载数,默认 |
| 单张原图上限,默认 |
| 本地图片缓存上限,超出按最久未用淘汰,默认 |
| 单次请求超时,默认 |
| 可选:把没映射的中文词交给 OpenAI 兼容模型翻成 Pixiv 标签 |
| 上一项用到的接口,如 |
| 需要走 HTTP 代理时用(Node ≥ 24 的原生 fetch 支持),图片下载同样走代理 |
LLM 不是必须的。 推荐让调用方 agent 自己把中文描述翻成 Pixiv 常用日文标签再传进来(比如 水手服→セーラー服)。内置的中文角色映射表照样生效,没映射的词按原样当标签用。
怎么拿 refresh token
Pixiv 没有官方开发者入口,refresh token 只能从官方 App 的 OAuth 登录流程里拿:
gppt(最省事,会开一个浏览器让你登录):
pip install gppt,然后运行gppt login-interactive(或gppt login -u 邮箱 -p 密码),输出里的refresh_token就是。pixiv_auth.py(ZipFile 的 gist,“Retrieving Auth Token (with Selenium)”那篇):运行
python pixiv_auth.py login,在浏览器里登录,再按说明从开发者工具的网络面板里复制code,脚本会换出refresh_token。
拿到之后填进 PIXIV_REFRESH_TOKEN。它长期有效,本工具会自动换 access token 并缓存。token 失效时自动退回网页搜索,日志写到 stderr。
MCP 工具
工具 | 作用 |
| 搜索并下载。参数: |
| 按 PID 读元数据,并用同一套规则给出 |
| 按 PID 下载原图( |
返回 JSON 里的字段:localPath / files[].path 是本地绝对路径,caption(🎨 画师:xxx)给 agent 展示用,url 是作品页地址。
过滤规则和 bot 版完全一致:
多标签 AND
互斥组蹭标签、AI(
aiType=2)、动图、黑名单直接丢;请求里出现黑名单词就整次拒绝,而且不扣冷却。短英文关键词(如bl)以及腐、グロ只按整词匹配灰名单默认避开;显式放行的类别作品必须真有
R-18 只认官方
xRestrict1 年半衰期排序,同一 session 不重复出图,看完一轮自动重新循环
搜索按
10000users入り→ … → 纯标签逐档降级429 / 5xx 指数退避重试
各客户端配置
下面示例用相对路径 ./dist/bin.js(先 cd 到项目根目录再启动)。若写成绝对路径,Windows / Linux / macOS 各自换成你的实际路径即可。
Codex CLI:~/.codex/config.toml(Windows:C:\Users\<你>\.codex\config.toml)
[mcp_servers.pixiv]
command = "node"
args = ['--max-old-space-size=96', './dist/bin.js', 'serve']
startup_timeout_sec = 20
tool_timeout_sec = 120
[mcp_servers.pixiv.env]
PIXIV_REFRESH_TOKEN = "你的token"
PIXIV_MCP_HOME = '~/.pixiv-mcp'TOML 里用单引号字符串,Windows 反斜杠就不用转义。
Claude Desktop:%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"pixiv": {
"command": "node",
"args": ["--max-old-space-size=96", "./dist/bin.js", "serve"],
"env": {
"PIXIV_REFRESH_TOKEN": "你的token",
"PIXIV_MCP_HOME": "~/.pixiv-mcp"
}
}
}
}Claude Code
claude mcp add pixiv -s user -e PIXIV_REFRESH_TOKEN=你的token -e "PIXIV_MCP_HOME=~/.pixiv-mcp" -- node --max-old-space-size=96 "./dist/bin.js" serveCursor:~/.cursor/mcp.json(全局)或项目里的 .cursor/mcp.json
内容和 Claude Desktop 那段 mcpServers 一样。
Grok Bot(本地 stdio MCP)
在 Grok Bot 添加本地 MCP 时填:
命令:
node参数:
--max-old-space-size=96、./dist/bin.js、serve环境变量:
PIXIV_REFRESH_TOKEN,以及可选的PIXIV_MCP_HOME
如果要求填 JSON,就用和 Claude Desktop 一样的 mcpServers.pixiv 那段。
不支持 MCP 的 agent:直接调 CLI
node dist/bin.js search 信浓 泳装 2 --json
node dist/bin.js search --tags "オリジナル 水着" --gray oral --session alice
node dist/bin.js detail 12345678 --json
node dist/bin.js download 12345678 --pages all --json退出码:成功为 0;失败、被拦截或冷却中为 1;用法错误为 2。
和 bot 版的差别
数据目录从
~/.dsh-qqbot改为~/.pixiv-mcp(可用PIXIV_MCP_HOME改)LLM 补标签从“拉起本机 agy”改为可选的 OpenAI 兼容接口(默认关闭)
新增
pixiv_illust_detail/pixiv_download(按 PID),规则复用同一套过滤网络失败、连续失败熔断时,结果里带
notice说明原因,不再静默返回空下载改为流式写盘,加了全局并发上限和单图大小上限;本地缓存上限默认从 2 GB 改为 512 MB
不负责发送图片:工具返回本地路径和 caption,由 agent 决定怎么展示。多图间隔 1.5 秒属于 QQ 发图的限制,这里不需要
Available Tools
3 toolspixiv_downloadPixiv 原图下载A
按 PID 下载原图到本地目录(PIXIV_MEDIA_DIR),返回每页的文件绝对路径与作品元数据。不合规(黑名单/未放行的灰名单/AI/动图)的作品拒绝下载。最多 10 页,下载并发受 PIXIV_DOWNLOAD_CONCURRENCY 限制。
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Pixiv 作品 ID | |
| r18 | No | 用户明确要求 R-18 时为 true | |
| pages | No | 页码(从 0 开始),默认 [0];"all" 下载全部页 | |
| allow_gray | No | 显式放行的灰名单类别(默认全部避开)。只有用户明确点名时才传。放行的类别作品必须真的具备;其余灰名单仍拒绝。可选: r18(官方 R-18) / oral(口交) / creampie(中出) / paizuri(乳交) / footjob(足交) / ahegao(阿黑颜) / sex(性交) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Since no annotations are supplied, the description must carry the full behavioral load, and it does disclose the key traits: a local-filesystem write into PIXIV_MEDIA_DIR, refusal rules for disallowed works, a 10-page ceiling, and concurrency governed by PIXIV_DOWNLOAD_CONCURRENCY. It omits overwrite behavior for pre-existing files and any auth/cookie requirement, which matter for a writing tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Four dense sentences lead with the core action and destination, then constraints, then limits, with no filler. Every clause carries operational information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
There is no output schema, but the description states what is returned (per-page absolute paths plus work metadata), which compensates. The remaining gap is file-collision/overwrite and error behavior on refusal for a tool that writes to disk with no annotations to fall back on.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents pid, r18, pages, and allow_gray in detail; the description adds only the page cap, which schema maxItems already conveys. Baseline 3 applies because the description adds little parameter meaning beyond the structured fields.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource (download original images by PID) plus the destination directory and the return payload (absolute per-page paths and work metadata). This clearly separates it from the read-only siblings pixiv_search and pixiv_illust_detail, which cannot write files.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description spells out the conditions under which the tool refuses to act (blacklist, unapproved gray list, AI, animated) and caps the operation at 10 pages, so the agent knows the boundaries before calling. It does not explicitly route the agent to pixiv_search or pixiv_illust_detail to obtain the PID, which is the only missing piece.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pixiv_illust_detailPixiv 作品详情A
按 PID 读取作品元数据(标题、画师、标签、收藏、页数、原图地址、分级),并按同一套黑/灰名单规则给出 compliant 结论。不下载。
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Pixiv 作品 ID | |
| r18 | No | 用户明确要求 R-18 时为 true | |
| allow_gray | No | 显式放行的灰名单类别(默认全部避开)。只有用户明确点名时才传。放行的类别作品必须真的具备;其余灰名单仍拒绝。可选: r18(官方 R-18) / oral(口交) / creampie(中出) / paizuri(乳交) / footjob(足交) / ahegao(阿黑颜) / sex(性交) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It usefully discloses a non-obvious behavior — the tool computes a 'compliant' verdict using black/graylist rules — but '同一套规则' is undefined, and it never says what a non-compliant result looks like (error vs. a compliant:false field), whether Pixiv auth/refresh tokens are required, or whether rate limits apply.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two tight sentences: the read-and-return-fields contract is front-loaded and the non-download constraint closes it. No filler, and the returned-field list is compressed rather than enumerated in prose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, the enumerated return fields are exactly the right compensation, and the compliance-verdict behavior is a valuable addition. What's missing is the failure mode for non-compliant works and any auth prerequisite — notable gaps for a tool whose output is a policy decision, but not fatal.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, including detailed enum semantics for allow_gray and the conditional meaning of r18, so the schema already does the heavy lifting. The description only restates that lookup is keyed on PID; it adds no format or validation detail beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ('按 PID 读取作品元数据') and enumerates exactly what comes back: title, artist, tags, bookmarks, page count, original image URLs, rating. It also explicitly disclaims the download behavior, which cleanly separates it from the pixiv_download sibling.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The only routing signal is the trailing '不下载', which implicitly points download intent at pixiv_download; it never mentions pixiv_search as the way to obtain a PID in the first place. Some when-to-pass guidance lives in the schema (allow_gray: '只有用户明确点名时才传'), but the description body itself leaves usage to inference.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
pixiv_searchPixiv 插画搜索A
按角色名/标签搜索 Pixiv 高质量插画,下载原图到本地并返回文件路径与元数据。多个标签是 AND(全部要在作品标签或标题里命中)。自动过滤:同作品互斥角色蹭标签、AI 生成(aiType=2)、动图、黑名单(BL/猎奇/福瑞/抽象整活等,请求里含黑名单词会被整次拒绝)。灰名单(R-18 及特定玩法)默认避开,只有 r18 / allow_gray 明确放行时才放行且必须真有。R-18 只认 Pixiv 官方 xRestrict。按 1 年半衰期收藏数排序,同一 session 不重复出图;同一 session 有冷却(默认 15 秒)。中文角色名有内置映射;不在映射里的词建议调用方先翻成 Pixiv 常用日文标签再传入(如 水手服→セーラー服)。给用户展示时在每张图下附上 caption(🎨 画师:xxx)。
| Name | Required | Description | Default |
|---|---|---|---|
| r18 | No | 用户明确要求 R-18 时为 true(需要登录凭据) | |
| tags | Yes | 标签数组,或空格分隔字符串。例: ["信浓","泳装"] 或 "信濃(アズールレーン) 水着" | |
| count | No | 张数 1-3,默认 1 | |
| session | No | 会话键:去重历史与冷却按此隔离,默认 "default" | |
| allow_gray | No | 显式放行的灰名单类别(默认全部避开)。只有用户明确点名时才传。放行的类别作品必须真的具备;其余灰名单仍拒绝。可选: r18(官方 R-18) / oral(口交) / creampie(中出) / paizuri(乳交) / footjob(足交) / ahegao(阿黑颜) / sex(性交) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden and does so thoroughly: it discloses blacklist rejection of the entire request, automatic filters (mutual-exclusive character tags, aiType=2, animations), gray-list default avoidance, R-18 limited to official xRestrict, 1.5-year half-life favorite sorting, session-level deduplication, and a 15-second cooldown. It also states that files are written to local disk and metadata is returned, which is exactly the beyond-schema behavior an agent needs.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single dense paragraph, but the core purpose is front-loaded in the first sentence and subsequent clauses are rules rather than filler. The closing caption/display instruction is presentation guidance rather than invocation semantics, which slightly dilutes focus, but nearly every sentence earns its place given the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 5-parameter tool with no output schema and no annotations, the description covers filtering behavior, ordering, session semantics, rate limits, credential requirements for r18, and what is returned (local paths plus metadata, with caption format). An agent has everything needed to call it correctly and set user expectations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: multiple tags are AND-ed against tags or titles, session isolates dedup history and cooldown, and allow_gray categories must genuinely be present or the item is rejected. It also warns that unmapped Chinese names should be converted to Pixiv-style Japanese tags, which the schema does not convey.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The opening sentence states a specific verb + resource + full outcome chain: search Pixiv illustrations by character/tag, download originals locally, return file paths and metadata. The scope (character/tag-driven search plus download) is distinct enough that an agent can tell it is the discovery+fetch tool rather than a detail or raw-download tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives concrete when-to-use rules for the risky options: allow_gray only when the user explicitly names a category, r18 only on explicit request, gray-list items must genuinely be present, and it advises pre-translating tags not in the built-in mapping. It stops short of explicitly contrasting with pixiv_download or pixiv_illust_detail, so sibling routing is left implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
pixiv_download - First observed
pixiv_illust_detail - First observed
pixiv_search
TDQS
Scored across 3 tools
pixiv_detail (metadata only) and pixiv_download (fetch files by PID) are clearly distinct, but pixiv_search already downloads originals and returns metadata, so an agent may not know whether a subsequent pixiv_download call is needed. The descriptions partly resolve this (search = discovery + fetch, download = explicit PID fetch), but the boundary between search and download remains blurred.
All names use a consistent pixiv_ prefix with snake_case and a verb/action orientation (search, download) plus one descriptive noun form (illust_detail). Minor deviation in structure but predictable and readable.
Three tools is on the thin side but each maps to a real step of the workflow: discover, inspect, fetch. No redundant or filler tools, so the small surface is justified for the server's scope.
Search, metadata inspection, and download cover the core image-retrieval lifecycle with shared filtering rules applied consistently. Gaps exist around artist/user-based browsing or paging beyond search results, but agents can work around these by re-searching with tags.
Maintenance
Related MCP Connectors
MCP server exposing the YourImageShare upload API (upload/list/delete) as tools for AI agents.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Browse, search, upload, tag, transfer, and delete images in your Raster libraries over MCP.
Agent-driven search: build, import, tune, search, and score result quality — all over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables browsing, searching, and downloading Pixiv content including illustrations, rankings, recommendations, and user bookmarks. Supports intelligent batch downloads with automatic Ugoira-to-GIF conversion and OAuth 2.0 authentication.5MIT
- AlicenseAqualityDmaintenanceMCP server for the Zerochan anime image board API. Browse the global feed, search by tags, and retrieve full entry metadata — directly from any MCP-compatible AI assistant.3MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search and browse manga, inspect album details, comments and rankings, manage favorites, and download albums, chapters, and covers with progress reporting, cancellation, retry, and batch task control. Also supports post-processing downloads into ZIP, PDF, or long images and dynamic runtime configuration, exposed as MCP tools and knowledge resources over stdio, SSE, and HTTP transports.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search, browse, and download comics via natural language, manage favorites, read comments and rankings, and convert downloaded content into ZIP, PDF, or long images. It also exposes download planning, background task progress, cancellation, retry, login/session handling, and runtime configuration as MCP tools and resources.-