BiliStalkerMCP
Provides tools for analyzing specific Bilibili users and creators, including retrieving profiles, videos, dynamics, articles, subtitles, and followings.
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., "@BiliStalkerMCPGet the profile and latest videos of Bilibili user 12345678"
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.
BiliStalkerMCP
Bilibili MCP Server for Specific User Analysis
BiliStalkerMCP is a Bilibili MCP server built on Model Context Protocol (MCP), designed for AI agents that need to analyze a specific Bilibili user or creator.
It is optimized for workflows that start from a target uid or username, then retrieve that user's profile, videos, dynamics, articles, subtitles, and followings with structured tools.
If you are searching for a Bilibili MCP server, a Bilibili Model Context Protocol server, or an MCP server for tracking and analyzing a specific Bilibili user, this repository is designed for that use case.
English | δΈζθ―΄ζ
Related MCP server: MediaCrawler MCP Server
π Quick Start
π€ Method 1: Let your AI Agent configure it (Recommended)
Copy and send the following to Claude Code, Codex, or other AI agents:
Check the current client environment's MCP configuration standards, then configure 222wcnm/BiliStalkerMCP as an available MCP server. If needed, ask whether to configure it globally or per-project, and prompt me for required Bilibili environment variables (e.g. SESSDATA).π οΈ Method 2: Manual Configuration (MCP Clients)
Configuration paths and syntax may vary across different clients.
1. Run the PyPI release directly
{
"mcpServers": {
"bilistalker": {
"command": "uvx",
"args": ["bili-stalker-mcp"],
"env": {
"SESSDATA": "required_sessdata",
"BILI_JCT": "optional_jct",
"BUVID3": "optional_buvid3"
}
}
}
}2. Run from cloned source
git clone https://github.com/222wcnm/BiliStalkerMCP.git
cd BiliStalkerMCPThen replace /path/to/BiliStalkerMCP below with your actual absolute path:
{
"mcpServers": {
"bilistalker": {
"command": "uv",
"args": ["run", "--directory", "/path/to/BiliStalkerMCP", "bili-stalker-mcp"],
"env": {
"SESSDATA": "required_sessdata",
"BILI_JCT": "optional_jct",
"BUVID3": "optional_buvid3"
}
}
}
}Prefer
uv run --directory ...for faster local updates when PyPI release propagation is delayed. You can still useuvx bili-stalker-mcpfor quick one-off usage.
Auth: Provide
SESSDATAdirectly, or put it inBILI_COOKIE_FILE. Obtain it from Browser DevTools (F12) > Application > Cookies >.bilibili.com.
Environment Variables
Key | Req | Description |
| Conditional | Bilibili session token; required unless |
| No | CSRF protection token. |
| No | Hardware fingerprint (reduces rate-limiting risk). |
| No | Path to a plain Cookie file. |
| No | Path to the separate refresh-token file; never set the token through an environment variable. |
| No |
|
| No | Refresh-check interval; default: |
| No | Route all upstream requests (bilibili_api and the built-in HTTP clients) through this proxy. Recommended when the system proxy is not picked up automatically or DNS resolution for Bilibili hosts is unstable. If the proxy is unreachable at startup, the server falls back to direct connections and logs a warning. |
| No | Upstream jitter behavior: |
| No | Jitter sleep range; default: |
| No | Total jitter sleep allowed per tool call; default: |
| No | How long a 412/429/403 keeps adaptive jitter engaged; default: |
| No |
|
| No | Output time zone for formatted timestamps (default: |
Optional Safe Cookie Refresh
Automatic refresh is disabled by default. Enable it only when the Cookie file and
refresh-token file are existing, readable, writable regular files. The Cookie file
may contain only ordinary Cookie values (SESSDATA, bili_jct, buvid3,
buvid4, and DedeUserID); the refresh token belongs only in its own file.
{
"BILI_COOKIE_FILE": "/secure/bilibili-cookie.txt",
"BILI_REFRESH_TOKEN_FILE": "/secure/bilibili-refresh-token.txt",
"BILI_ENABLE_COOKIE_REFRESH": "true",
"BILI_COOKIE_REFRESH_CHECK_INTERVAL_SECONDS": "21600"
}When refresh is enabled, do not set SESSDATA, BILI_JCT, or DEDEUSERID in
the environment: those rotating values must come from the Cookie file so a restart
cannot reload stale credentials. BUVID3 and BUVID4 may still be provided through
the environment. Refresh checks are rate-limited, and concurrent MCP calls or server
processes sharing these files use one refresh lock. Pending confirmation is recovered
before another refresh. The .bili-cookie-refresh.lock sidecar may remain on disk
between runs.
For a quicker initial setup, copy the complete Cookie header value from a Bilibili
browser request and ac_time_value from Local Storage, then run:
uv run bili-stalker-cookie-setup --directory D:\BiliStalkerSecretsFor a PyPI-only invocation without cloning this repository:
uvx --from bili-stalker-mcp bili-stalker-cookie-setup --directory D:\BiliStalkerSecretsThe script hides both pasted values, refuses directories inside the repository and
existing credential files, and prints only a non-secret MCP env block. Do not
paste an entire cURL command: paste only the value after its cookie: header.
Local Verification
All verification commands use mocks and do not require Bilibili credentials:
uv run pytest -q tests/test_credentials.py tests/test_cookie_refresh.py tests/test_tool_contract.py
uv run pytest -q
uv run black --check bili_stalker_mcp tests scripts
uv run isort --check-only bili_stalker_mcp tests scripts
uv run flake8 bili_stalker_mcp tests scripts
uv run mypy bili_stalker_mcpAvailable Tools
Tool | Capability | Parameters |
| Lightweight user candidates with numeric UIDs |
|
| One-call overview: profile + recent videos/dynamics/articles fetched concurrently |
|
| Rich profile: level, official title, VIP, live room, ban status, following/follower, total video views/article views/likes (needs |
|
| Lightweight video list |
|
| Keyword search in one user's video list |
|
| Full video detail + optional subtitles |
|
| Structured dynamics with image metadata and cursor pagination |
|
| Lightweight article list |
|
| Full article markdown content |
|
| Subscription list analysis |
|
| Comments for a video, article, or dynamic (including images and note metadata) |
|
| Full sub-replies for a video, article, or dynamic comment |
|
When starting from a username, call search_users once and reuse the returned numeric
UID for subsequent tools. Implicit username resolution accepts exact matches only; it
does not silently select the first similar search result.
Comment pictures contain the original image URLs. Regular long comments retain the
full text returned by Bilibili. Note-style comments may contain only a preview; use
the returned note.cvid with get_article_content to retrieve the full note.
For video comments, pass content_type="video" and a BVID, AV number, or video URL
as content_id. Use a top-level comment's rpid as root_rpid when fetching its
complete reply thread.
Dynamic Filtering (dynamic_type)
ALL(default): Text, Draw, Reposts, and Video dynamics.ALL_RAW: Unfiltered (additionally includes Articles and unknown types).VIDEO,ARTICLE,DRAW,TEXT: Specific category filtering.REVIEW: Recognized five-slot rating cards only. Each result exposesreview.rating(filled stars, 0-5),review.title,review.text, cover and jump URLs, plus the source score description when available. This filter does not independently classify whether the rated title is an anime.
Each dynamic item includes an images list. Every image contains url, width,
and height; invalid URLs are omitted, and unavailable dimensions are null.
image_count always equals the number of returned images. Reposts expose the same
fields under origin.images and origin.image_count. Non-image dynamics return
an empty images list.
Pagination: Responses include next_cursor. Pass this to subsequent requests for seamless scrolling.
Subtitle Modes (get_video_detail)
smart(default whenfetch_subtitles=true): fetch metadata for all pages, download only one best-matched subtitle track text.full: download text for all subtitle tracks (higher cost).minimal: skip subtitle metadata and subtitle text fetching.
subtitle_lang can force a language (for example en-US); auto uses built-in priority fallback.subtitle_max_chars caps returned subtitle text size to avoid token explosion.
Subtitle text is returned once via full_text; tracks carry metadata only
(text is always empty). In full mode with multiple tracks, each segment in
full_text is prefixed with a [language Β· part] label.
Bundled Skill
The repository ships a ready-to-use AI agent skill in skills/bili-content-analysis/:
skills/bili-content-analysis/
βββ SKILL.md # Workflow & output contract
βββ references/
βββ analysis-style.md # Detailed writing style rulesWhat It Does
Guides compatible AI agents (Gemini, Claude, etc.) through a structured 6-step workflow for deep Bilibili content analysis:
Clarify target and scope (uid / bvid / keyword).
Collect evidence β lightweight lists first, heavy detail only for high-value items.
Reconstruct source structure before interpreting (timeline, chapters, speakers).
Analyze β facts, logic chain, assumptions, themes, and shifts.
Retain anchors β uid, bvid, article_id, timestamps, key source snippets.
Handle failures β state blockers explicitly, stop speculation.
Usage
Copy the bili-content-analysis folder into your project's skill directory:
<project>/.agent/skills/bili-content-analysis/The agent will automatically activate the skill when user requests involve Bilibili creator tracking, transcript interpretation, timeline reconstruction, or content analysis.
Development
# Setup
git clone https://github.com/222wcnm/BiliStalkerMCP.git
cd BiliStalkerMCP
uv sync --dev
# Test
uv run pytest -q
# Integration & Performance (Requires Auth)
uv run python scripts/integration_suite.py -u <UID>
uv run python scripts/perf_baseline.py -u <UID> --tools dynamics -n 3Release (Maintainers)
Credentials: The release script uses
UV_PUBLISH_TOKENwhen set; otherwise it reads the matching[pypi]or[testpypi]token from$HOME\.pypirc. Twine is invoked transiently throughuvxonly for package metadata validation and is not a project dependency.
# Build + test + package metadata validation (no upload)
.\scripts\pypi_release.ps1
# Upload to TestPyPI
.\scripts\pypi_release.ps1 -TestPyPI -Upload
# Upload to PyPI
.\scripts\pypi_release.ps1 -UploadDocker
Runs via stdio transport. No ports exposed.
docker build -t bilistalker-mcp .
docker run -e SESSDATA=... bilistalker-mcpTroubleshooting
412 Precondition Failed: Bilibili anti-crawling system triggered. Refresh
SESSDATAor provideBUVID3.Cloud IPs: Highly susceptible to blocking; local execution is recommended.
Long ~20s stalls or DNS timeouts on upstream calls: configure
BILI_PROXY.bilibili_api's curl_cffi client ignores system and environment proxies unless an explicit proxy is set.
Upstream Dependency Note
bilibili-api-python is pinned to ==17.4.2. Its upstream repository has been
permanently shut down following a legal notice from Bilibili, so no further
maintenance or fixes can be expected from that project. Additionally, the
package is licensed GPL-3.0-or-later, which means its source cannot be
vendored or forked into this MIT-licensed repository.
The mitigation path is incremental migration of the remaining SDK-backed
endpoints (user info, video list/details, dynamics, articles) onto this
project's own raw HTTP stack (SharedRawHttpClient), which already serves
comments, followings, and relation stats independently of the SDK. The pin
should be kept exact so installs never pick up an unknown future version.
License
MIT
Disclaimer: For personal research and learning only. Bulk profiling, harassment, or commercial surveillance is prohibited.
This project is built and maintained with the help of AI.
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for Hailuo (MiniMax) AI video generation
An MCP server for deep research or task groups
MCP server for stocksense-ai documentation, generated by doc2mcp.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceAn MCP server that enables users to search Bilibili videos, access trending rankings, and retrieve detailed information about videos, content creators, and anime schedules. It allows AI applications to interact directly with Bilibili content via simple API interfaces.47 npm191MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for crawling social media platforms (e.g., Bilibili) by keywords, video IDs, or creator IDs, with support for MySQL, JSON, and CSV storage.39MIT
- AlicenseBqualityDmaintenanceA MCP server providing 22 tools to interact with Bilibili API, enabling video info, search, user profile, comments, rankings, and messaging with login support for write operations.223GPL 3.0
- AlicenseBqualityAmaintenanceBilibili MCP server enabling video search, comment management, danmaku, user info, dynamics, live streaming analysis, and more via 31 tools.3116 npm3MIT