Skip to main content
Glama

bangumi-mcp

中文说明 | English


中文说明

功能完整、面向 LLM 脱水优化的 Bangumi (bgm.tv) API v0 MCP Server + 轻量 CLI。

  • 免 Token 开箱即用:搜索、条目详情、关联人物/角色/条目、章节列表、每日放送日历、用户公开收藏全量拉取、批量推荐去重核验、目录读取全部免鉴权直跑。

  • 可选个人读写:配好 BANGUMI_ACCESS_TOKEN 即可直接维护个人收藏、评分/标签/短评、单集与批量追番进度、角色/人物收藏、目录增删改;不配 Token 时优雅提示,不影响任何公开只读能力。

  • 为 LLM 上下文省 Token:自动脱水压缩冗余图片字典、评分直方图与过长简介,保留核心结构化字段与 https://bgm.tv/... 直达链接。

  • 内置批量去重核验(check_user_collections):传入一组番名或 subject_id(支持整数或 id:10380),先独立解析作品身份再对照用户收藏库标出「看过 / 在看 / 想看 / 搁置 / 抛弃 / 未收藏 / 核验失败」,避免第一季误判第二季或把纯数字番名(如 86)误当 ID。

  • 安全边界清晰:MCP 侧全量同步严格只读(不写本机文件,导出请用 bangumi-cli sync -o);非幂等写请求不自动重放;streamable-http 模式默认禁用个人 Token(仅允许本机 loopback 显式加 --allow-token-over-http 开启)。

快速接入(一行 uvx / 本地配置)

公开只读无需 env;需要个人读写时按需加上 BANGUMI_ACCESS_TOKEN(申请地址:https://next.bgm.tv/demo/access-token)。

Claude Code

# 免安装直接运行(推荐)
claude mcp add bangumi -- uvx --from git+https://github.com/whycantiusemyname/bangumi-mcp bangumi-mcp

# 带默认用户名与个人 Token(可选)
claude mcp add bangumi \
  -e BANGUMI_DEFAULT_USERNAME=your_username \
  -e BANGUMI_ACCESS_TOKEN=your_token \
  -- uvx --from git+https://github.com/whycantiusemyname/bangumi-mcp bangumi-mcp

Codex CLI (~/.codex/config.toml)

[mcp_servers.bangumi]
command = "uvx"
args = ["--from", "git+https://github.com/whycantiusemyname/bangumi-mcp", "bangumi-mcp"]

[mcp_servers.bangumi.env]
BANGUMI_DEFAULT_USERNAME = "your_username"
# BANGUMI_ACCESS_TOKEN = "your_token"  # 可选,写操作时填写

Antigravity / Cursor / Claude Desktop(通用 MCP JSON)

{
  "mcpServers": {
    "bangumi": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/whycantiusemyname/bangumi-mcp",
        "bangumi-mcp"
      ],
      "env": {
        "BANGUMI_DEFAULT_USERNAME": "your_username"
      }
    }
  }
}

本地开发目录接入

{
  "mcpServers": {
    "bangumi": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/bangumi-mcp", "bangumi-mcp"],
      "env": {
        "BANGUMI_DEFAULT_USERNAME": "your_username"
      }
    }
  }
}

Streamable HTTP 模式

# 默认以公开只读模式运行(不暴露环境中的 BANGUMI_ACCESS_TOKEN)
uvx --from git+https://github.com/whycantiusemyname/bangumi-mcp \
  bangumi-mcp --transport streamable-http --host 127.0.0.1 --port 8765 --path /mcp

# 若确需在本机 loopback HTTP 上启用个人 Token 读写,显式传入 --allow-token-over-http(禁止非本机地址)
bangumi-mcp --transport streamable-http --host 127.0.0.1 --port 8765 --allow-token-over-http

环境变量

变量名

必填

默认值

说明

BANGUMI_ACCESS_TOKEN

否

无

Bangumi Personal Access Token,仅个人读写接口需要(非本机 http:// 将被拒绝发送)

BANGUMI_DEFAULT_USERNAME

否

无

默认 Bangumi 用户名,调用用户相关 MCP 工具及 bangumi-cli sync/check/user 时可省略用户名

BANGUMI_USER_AGENT

否

whycantiusemyname/bangumi-mcp/<ver> (...)

符合 Bangumi API 规范的自定义 User-Agent

BANGUMI_BASE_URL

否

https://api.bgm.tv

API 基础地址

BANGUMI_TIMEOUT

否

20.0

HTTP 请求超时(秒)

BANGUMI_MAX_RETRIES

否

4

仅针对只读请求的 429 / 5xx 最大重试次数(指数退避 + Retry-After 秒数/HTTP 日期)

BANGUMI_MAX_RETRY_AFTER

否

30.0

Retry-After 最大等待预算(秒),超出则直接返回限流提示

BANGUMI_CACHE_TTL

否

300.0

用户完整收藏库内存缓存有效期(秒),带并发合并与写后自动失效

MCP 工具清单(共 33 个)

公开只读(20 个,免 Token)

分类

工具名

说明

条目检索与浏览

search_subjects, browse_subjects

高级搜索(类型/标签/meta_tags/发售日/评分/排名/排序)与分类浏览

条目详情与关联

get_subject, get_subject_persons, get_subject_characters, get_subject_relations

条目完整脱水信息、制作人员、登场角色与 CV、关联续作/原作

章节与放送日历

get_episodes, get_episode, get_calendar

章节分页查询、单集详情、每日放送表(支持 today / 周一~周日过滤)

角色与现实人物

search_characters, get_character, search_persons, get_person

角色/声优/导演/制作公司检索、详情与关联条目

用户收藏与去重

get_user, get_user_collections, get_user_subject_collection, sync_user_collections, check_user_collections, get_user_favorites

用户资料、单页/单条目收藏、全 5 类分页同步与完整性统计、批量去重核验、收藏角色与人物

目录读取

get_index

读取公开目录详情及其收录条目

个人鉴权读写(13 个,需 BANGUMI_ACCESS_TOKEN)

分类

工具名

说明

当前用户

get_me

获取当前 Token 对应的登录用户信息

收藏管理

upsert_collection

新增/修改条目收藏状态、评分(0-10)、标签、短评、私密标记与书籍进度

追番进度

get_episode_progress, update_episode_status, batch_update_episodes

读取/单集更新/批量更新章节观看状态(未收藏/想看/看过/抛弃)

角色与人物收藏

set_character_collection, set_person_collection

收藏角色/现实人物(注:上游 bangumi/server 目前暂未开放角色/人物取消收藏 DELETE 路由,collect=false 会明确提示)

目录维护

create_index, update_index, add_index_subject, update_index_subject, remove_index_subject, set_index_collection

创建/编辑目录、增删改目录条目(修改条目需同时传 sort 与 comment)、收藏/取消收藏目录

轻量 CLI (bangumi-cli)

# 全量拉取用户 5 大类收藏并导出 JSON(含统计 + 收藏角色/人物)
bangumi-cli sync <username> --favorites -o collections.json

# 仅拉取动画收藏
bangumi-cli sync <username> --types anime -o anime.json

# 批量推荐去重核验(支持番名与 subject_id 混传,也可配 BANGUMI_DEFAULT_USERNAME 省略 -u 或用 --file)
bangumi-cli check -u <username> "葬送的芙莉莲" "孤独摇滚" id:10380 --types anime

# 快速查新番表 / 搜番 / 查条目
bangumi-cli calendar --weekday today
bangumi-cli search "命运石之门" --types anime --sort rank --limit 5
bangumi-cli subject 10380

Related MCP server: Bilibili API MCP Server

English

A full-featured, LLM-friendly Bangumi (bgm.tv) API v0 MCP Server + lightweight CLI.

Highlights

  • Zero-auth public read-only tools (20 tools): Subject search (POST /v0/search/subjects) & browse, subject details/staff/characters/relations, episodes, weekly broadcast calendar (/calendar), characters & persons search/details, public user profiles/collections/favorites, full 5-category collection sync with completeness tracking, batch recommendation deduplication, and public index reading.

  • Optional personal read/write tools (13 tools): Set BANGUMI_ACCESS_TOKEN to manage your own collections, ratings/tags/comments, single & batch episode watch progress, character/person collecting, and curated indices. Missing token yields a clear AUTH_REQUIRED MCP tool error without affecting read-only tools.

  • Safe by default: MCP sync_user_collections never writes local files (use bangumi-cli sync -o); mutating requests never auto-retry on ambiguous failures; streamable-http disables BANGUMI_ACCESS_TOKEN by default unless explicitly opted in on a loopback address (--allow-token-over-http).

  • Built-in Recommendation Deduplicator (check_user_collections): Separates subject identity resolution from collection lookup, surfaces cross-media ambiguity, guards against cross-season false positives and numeric titles like "86", and reports unknown if fallback search fails.

Quick Setup

# Claude Code
claude mcp add bangumi -- uvx --from git+https://github.com/whycantiusemyname/bangumi-mcp bangumi-mcp

# Local development & tests
git clone https://github.com/whycantiusemyname/bangumi-mcp.git
cd bangumi-mcp
uv sync --extra dev
uv run pytest

License

MIT

Available Tools

33 tools
add_index_subjectB

Add (or overwrite if already present) a subject in a Bangumi Index (POST /v0/indices/{index_id}/subjects). Requires BANGUMI_ACCESS_TOKEN.

Inputs: index_id (required), subject_id (required), sort, comment.

batch_update_episodesA

Batch update watch status for multiple episodes of a subject (PATCH /v0/users/-/collections/{subject_id}/episodes).

Requires BANGUMI_ACCESS_TOKEN. Recalculates subject completion and invalidates collection cache.

Inputs: subject_id (required), episode_ids (required), status.

browse_subjectsC
Read-onlyIdempotent

Browse Bangumi subjects by type, year/month, or rank (GET /v0/subjects).

Inputs: cat, sort, year, limit, +5 more.

check_user_collectionsA
Read-onlyIdempotent

Batch-check candidate titles or subject_ids against a user's Bangumi collections for recommendation deduplication.

Pass integer subject_ids (or 'id:10380'/'#10380') for exact ID lookup, or title strings (e.g. '命运石之门', '86'). Returns collect/doing/wish/on_hold/dropped/uncollected/unknown along with user rating, episode progress, and ambiguity/completeness notes.

Inputs: items (required), refresh, username, subject_types, +1 more.

create_indexC

Create a new Bangumi Index (目录) (POST /v0/indices). Requires BANGUMI_ACCESS_TOKEN.

Inputs: title, description.

get_calendarA
Read-onlyIdempotent

Get Bangumi weekly airing broadcast calendar (GET /calendar).

Args: weekday: Optional filter: 1-7 (Mon-Sun), "monday".."sunday", "周一".."周日", or "today".

Inputs: weekday.

get_characterC
Read-onlyIdempotent

Get character details, optionally with related subjects and voice actors.

Inputs: character_id (required), relation_limit, include_persons, include_subjects.

get_episodeC
Read-onlyIdempotent

Get detailed info for a single episode (GET /v0/episodes/{episode_id}).

Inputs: episode_id (required).

get_episode_progressA
Read-onlyIdempotent

Read the authenticated user's episode watch progress for a subject OR single episode.

Requires BANGUMI_ACCESS_TOKEN. Pass exactly one of subject_id or episode_id.

Inputs: limit, offset, ep_type, episode_id, +1 more.

get_episodesC
Read-onlyIdempotent

List episodes for a subject (GET /v0/episodes).

Inputs: subject_id (required), limit, offset, ep_type.

get_indexB
Read-onlyIdempotent

Get a Bangumi curated Index (目录) and optionally its subjects.

Inputs: index_id (required), limit, offset, subject_type, +1 more.

get_meA
Read-onlyIdempotent

Get the currently authenticated Bangumi user profile (GET /v0/me). Requires BANGUMI_ACCESS_TOKEN.

Inputs: no named parameters.

get_personB
Read-onlyIdempotent

Get person/studio details, optionally with related subjects and voiced characters.

Inputs: person_id (required), relation_limit, include_subjects, include_characters.

get_subjectB
Read-onlyIdempotent

Get compact, structured details for a Bangumi subject (GET /v0/subjects/{subject_id}).

Inputs: subject_id (required).

get_subject_charactersC
Read-onlyIdempotent

Get characters and their voice actors for a subject (GET /v0/subjects/{subject_id}/characters).

Inputs: subject_id (required), limit.

get_subject_personsB
Read-onlyIdempotent

Get staff/creators/studios associated with a subject (GET /v0/subjects/{subject_id}/persons).

Inputs: subject_id (required), limit.

get_subject_relationsB
Read-onlyIdempotent

Get related subjects (sequels, prequels, manga/novel adaptations, spin-offs) (GET /v0/subjects/{subject_id}/subjects).

Inputs: subject_id (required), limit.

get_userB
Read-onlyIdempotent

Get public profile for a Bangumi user (GET /v0/users/{username}).

Inputs: username.

get_user_collectionsC
Read-onlyIdempotent

Query a single page of a user's collections (GET /v0/users/{username}/collections).

Inputs: limit, offset, username, subject_type, +1 more.

get_user_favoritesC
Read-onlyIdempotent

Get a user's favorited characters and/or persons.

Inputs: kind, limit, offset, username.

get_user_subject_collectionB
Read-onlyIdempotent

Get a user's collection record for a single subject (GET /v0/users/{username}/collections/{subject_id}).

Inputs: subject_id (required), username.

remove_index_subjectA
Destructive

Remove a subject from a Bangumi Index (DELETE /v0/indices/{index_id}/subjects/{subject_id}). Requires BANGUMI_ACCESS_TOKEN.

Inputs: index_id (required), subject_id (required).

search_charactersC
Read-onlyIdempotent

Search Bangumi characters (POST /v0/search/characters).

Inputs: keyword (required), nsfw, limit, offset.

search_personsC
Read-onlyIdempotent

Search real-world persons/studios (voice actors, directors, mangaka, etc.) (POST /v0/search/persons).

Inputs: keyword (required), limit, career, offset.

search_subjectsA
Read-onlyIdempotent

Search Bangumi subjects (POST /v0/search/subjects).

Args: keyword: Search query (Japanese, Chinese, or English title/keyword). subject_types: Optional filter list, e.g. ["anime"], ["book", "game"], or ints [1,2,3,4,6]. sort: Sort order: "match" (default), "heat", "rank", or "score". tags: User tags filter (AND logic), e.g. ["科幻", "原创"]. meta_tags: Public wiki meta tags (AND logic; prefix "-" to exclude, e.g. ["-科幻"]). air_date: Date range constraints (YYYY-MM-DD), e.g. [">=2024-01-01", "<2025-01-01"]. rating: Score constraints, e.g. [">=8.0", "<9.5"]. rating_count: Vote count constraints, e.g. [">=500"]. rank: Rank constraints, e.g. [">=1", "<=200"]. nsfw: Optional NSFW filter (ignored by Bangumi when unauthenticated). limit: Results per page (1-50, default 15). offset: Pagination offset (default 0).

Inputs: keyword (required), nsfw, rank, sort, +8 more.

set_character_collectionA

Collect (favorite) a character for the authenticated user (POST /v0/characters/{character_id}/collect).

Requires BANGUMI_ACCESS_TOKEN. Note: uncollecting (collect=False) is currently disabled in upstream bangumi/server and returns UNSUPPORTED_UPSTREAM.

Inputs: character_id (required), collect.

set_index_collectionB

Collect (bookmark) or uncollect a Bangumi Index for the authenticated user. Requires BANGUMI_ACCESS_TOKEN.

Inputs: index_id (required), collect.

set_person_collectionA

Collect (favorite) a person/studio for the authenticated user (POST /v0/persons/{person_id}/collect).

Requires BANGUMI_ACCESS_TOKEN. Note: uncollecting (collect=False) is currently disabled in upstream bangumi/server and returns UNSUPPORTED_UPSTREAM.

Inputs: person_id (required), collect.

sync_user_collectionsB
Read-onlyIdempotent

Fetch all paginated collections across all 5 subject types (book/anime/music/game/real) with status statistics.

Read-only in MCP (no local filesystem writes; use bangumi-cli sync -o FILE for local JSON export).

Inputs: refresh, username, include_items, subject_types, +2 more.

update_episode_statusA

Update watch status for a single episode (PUT /v0/users/-/collections/-/episodes/{episode_id}).

Requires BANGUMI_ACCESS_TOKEN. Invalidates cached collection progress.

Inputs: episode_id (required), status.

update_indexA

Edit a Bangumi Index's title and/or description (PUT /v0/indices/{index_id}). Requires BANGUMI_ACCESS_TOKEN.

Inputs: index_id (required), title, description.

update_index_subjectA

Overwrite a subject's sort order and comment inside an Index (PUT /v0/indices/{index_id}/subjects/{subject_id}).

Requires BANGUMI_ACCESS_TOKEN. Upstream writes BOTH sort and comment on every PUT (and inserts the subject into the index if not already present), so always pass both desired values.

Inputs: index_id (required), subject_id (required), sort, comment.

upsert_collectionB

Add or update the authenticated user's collection for a subject (POST/PATCH /v0/users/-/collections/{subject_id}).

Requires BANGUMI_ACCESS_TOKEN. Does not auto-retry on network timeout.

Inputs: subject_id (required), rate, tags, comment, +5 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 33 tools

    Disambiguation3/5

    Several tools share 'collection' terminology (set_index_collection, upsert_collection, get_user_collections, sync_user_collections, check_user_collections, set_character_collection, set_person_collection), and add_index_subject overlaps with update_index_subject since both can insert/overwrite a subject in an index. Descriptions clarify the distinctions, but an agent must read carefully to avoid misselection.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (e.g., search_subjects, get_subject, update_episode_status, create_index, remove_index_subject). The few slight variations like get_me or batch_update_episodes still fit the same convention.

    Tool Count3/5

    33 tools is heavy for a single MCP server, though the Bangumi API is broad and each domain (subjects, characters, persons, users, collections, indices, episodes) requires multiple operations. There is some redundancy, such as add_index_subject vs update_index_subject, which pushes the count toward the high side.

    Completeness3/5

    The surface covers most core workflows: search/browse subjects, get details, manage users and collections, update episode progress, and create/edit indices. However, there is no delete_index tool and no explicit way to uncollect a subject, leaving notable gaps in the index and collection lifecycles.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Provides MCP access to the BangumiTV API, allowing users to retrieve and interact with anime, manga, music, and game information through natural language queries.
      17
      27
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables interaction with Bilibili (哔哩哔哩) through its API, supporting video search and recommendations, user search, dynamic feeds, video collections, and danmaku retrieval through natural language.
      5
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables users to search for anime information via the Bangumi API and discover corresponding real-world pilgrimage locations through the Anitabi API. It provides tools for retrieving anime metadata and detailed geographic coordinates for 'seichi junrei' locations.
      3
      AGPL 3.0