@xzxzzx/bilibili-mcp 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,18 +4,25 @@
4
4
  [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/@xzxzzx/bilibili-mcp.svg)](https://www.npmjs.com/package/@xzxzzx/bilibili-mcp)
6
6
 
7
- 用claude code(glm4.7模型)做的总结B站视频的MCP(经过antigravity里的claude,gemini模型修改bug)(提取字幕与评论)
7
+ ## ✨ **为你的 AI 助手装上 B 站的眼睛**:一键提取视频字幕与热门评论,助力高效信息总结 🚀
8
+ ## ✨ **Equip your AI assistant with "Bilibili Eyes"**: One-click extraction of video subtitles and popular comments for efficient information summarization 🚀
9
+ ### 🌐 **[English Documentation](https://github.com/365903728-oss/bilibili-mcp/blob/master/README_EN.md)** (English version here)
8
10
 
9
11
  > [!TIP]
10
12
  > ⚠️ **提示**:使用前请务必配置您的 B 站 Cookie,否则将无法提取视频字幕与评论。详见 [**⚙️ 凭证配置**](#️-凭证配置)(凭证只会保存在本地,不会上传到任何地方)。
13
+ >
14
+ > ⚠️ **Notice**: Please make sure to configure your Bilibili Cookies before use, otherwise video subtitles and comments cannot be extracted. See [**⚙️ Credential Configuration**](#️-credential-configuration) (Cookies are only stored locally and will not be uploaded anywhere).
15
+
11
16
 
12
- View this document in [English](./README_EN.md).
13
17
 
14
18
  ---
15
19
 
16
20
  ## 📑 目录
17
21
 
18
22
  - [Bilibili MCP Tool](#bilibili-mcp-tool)
23
+ - [✨ **为你的 AI 助手装上 B 站的眼睛**:一键提取视频字幕与热门评论,助力高效信息总结 🚀](#-为你的-ai-助手装上-b-站的眼睛一键提取视频字幕与热门评论助力高效信息总结-)
24
+ - [✨ **Equip your AI assistant with "Bilibili Eyes"**: One-click extraction of video subtitles and popular comments for efficient information summarization 🚀](#-equip-your-ai-assistant-with-bilibili-eyes-one-click-extraction-of-video-subtitles-and-popular-comments-for-efficient-information-summarization-)
25
+ - [🌐 **English Documentation** (English version here)](#-english-documentation-english-version-here)
19
26
  - [📑 目录](#-目录)
20
27
  - [⚡ 快速预检](#-快速预检)
21
28
  - [🌟 功能特性](#-功能特性)
@@ -28,7 +35,8 @@ View this document in [English](./README_EN.md).
28
35
  - [方法一:通过 CLI 命令快速安装(推荐)](#方法一通过-cli-命令快速安装推荐)
29
36
  - [方法二:通过配置文件手动添加(高级)](#方法二通过配置文件手动添加高级)
30
37
  - [Claude Desktop (桌面客户端)](#claude-desktop-桌面客户端)
31
- - [方法三:通过 npm 全局安装](#方法三通过-npm-全局安装)
38
+ - [方法一:通过配置文件手动添加](#方法一通过配置文件手动添加)
39
+ - [方法二:通过 npm 全局安装](#方法二通过-npm-全局安装)
32
40
  - [🏗️ Trae (字节跳动官方 IDE)](#️-trae-字节跳动官方-ide)
33
41
  - [🌊 Windsurf (Codeium 官方 IDE)](#-windsurf-codeium-官方-ide)
34
42
  - [⚡ Zed](#-zed)
@@ -47,6 +55,8 @@ View this document in [English](./README_EN.md).
47
55
  - [🛠️ 开发指南](#️-开发指南)
48
56
  - [⚖️ 安全性与免责声明](#️-安全性与免责声明)
49
57
  - [许可证](#许可证)
58
+ - [🛠️ 开发过程](#️-开发过程)
59
+ - [💬 反馈与建议](#-反馈与建议)
50
60
 
51
61
  ---
52
62
 
@@ -134,6 +144,8 @@ claude mcp add bilibili-mcp --command "npx" --args "-y" --args "@xzxzzx/bilibili
134
144
 
135
145
  Claude Desktop 支持通过全局配置文件接入 MCP 服务器:
136
146
 
147
+ #### 方法一:通过配置文件手动添加
148
+
137
149
  1. 打开 Claude Desktop 配置文件:
138
150
  - Windows 路径:`%APPDATA%\Claude\claude_desktop_config.json`
139
151
  - macOS 路径:`~/Library/Application Support/Claude/claude_desktop_config.json`
@@ -145,14 +157,19 @@ Claude Desktop 支持通过全局配置文件接入 MCP 服务器:
145
157
  "mcpServers": {
146
158
  "bilibili-mcp": {
147
159
  "command": "npx",
148
- "args": ["-y", "@xzxzzx/bilibili-mcp"]
160
+ "args": ["-y", "@xzxzzx/bilibili-mcp"],
161
+ "env": {
162
+ "BILIBILI_SESSDATA": "你的_SESSDATA",
163
+ "BILIBILI_BILI_JCT": "你的_bili_jct",
164
+ "BILIBILI_DEDEUSERID": "你的_DedeUserID"
165
+ }
149
166
  }
150
167
  }
151
168
  }
152
169
  ```
153
170
  3. 保存文件并从侧边栏重启或重新开启对话。
154
171
 
155
- #### 方法三:通过 npm 全局安装
172
+ #### 方法二:通过 npm 全局安装
156
173
 
157
174
  安装后可直接使用命令行工具管理配置:
158
175
 
@@ -426,4 +443,25 @@ npm run watch
426
443
 
427
444
  ### 许可证
428
445
 
429
- 基于 **GNU General Public License v3.0** 开源。
446
+ 基于 **GNU General Public License v3.0** 开源。
447
+
448
+ ---
449
+
450
+ ## 🛠️ 开发过程
451
+
452
+ 本项目是一个典型的 AI 协同开发的结晶,完整经历了从原型到完善的过程:
453
+
454
+ 1. **初版生成**:由 **Claude Code** (搭载 **GLM-4.7** 模型) 快速搭建核心架构与基础逻辑。
455
+ 2. **调试与优化**:在 **Antigravity** 环境下,利用 **Claude** 和 **Gemini** 模型进行深度的 Bug 修复与功能增强,确保了字幕提取与评论分析的稳定性。
456
+
457
+ ---
458
+
459
+ ## 💬 反馈与建议
460
+
461
+ 如果您在使用过程中遇到任何问题,或者有好的功能建议,欢迎通过以下方式联系:
462
+
463
+ - **提交 Issue**:[GitHub Issues](https://github.com/365903728-oss/bilibili-mcp/issues) —— **推荐方式**,我会定期查看并回复。
464
+ - **项目讨论**:在 [GitHub Discussions](https://github.com/365903728-oss/bilibili-mcp/discussions)(如果已开启)中交流。
465
+
466
+ 感谢您的支持!
467
+
package/README_EN.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/@xzxzzx/bilibili-mcp.svg)](https://www.npmjs.com/package/@xzxzzx/bilibili-mcp)
6
6
 
7
- A Bilibili video auxiliary MCP tool built based on mainstream AI development tools like Claude Code, Cursor, Trae, and Google Antigravity. It aims to quickly extract core video information, highlights, and popular comments through Large Language Model capabilities, helping you process audio and video content efficiently.
7
+ ## ✨ **Equip your AI assistant with "Bilibili Eyes"**: One-click extraction of video subtitles and popular comments for efficient information summarization 🚀
8
8
 
9
9
  > [!TIP]
10
10
  > ⚠️ **Quick Start**: Please make sure to configure your Bilibili Cookies before use, otherwise video subtitles and comments cannot be extracted. See [**⚙️ Credential Configuration**](#⚙️-credential-configuration)(Cookies are only stored locally and will not be uploaded anywhere).
@@ -28,7 +28,8 @@ View this document in [简体中文](./README.md).
28
28
  - [Method 1: Fast Installation via CLI (Recommended)](#method-1-fast-installation-via-cli-recommended)
29
29
  - [Method 2: Manual Addition via Config File](#method-2-manual-addition-via-config-file)
30
30
  - [Claude Desktop](#claude-desktop)
31
- - [Method 3: Global npm Installation](#method-3-global-npm-installation)
31
+ - [Method 1: Manual Addition via Config File](#method-1-manual-addition-via-config-file)
32
+ - [Method 2: Global npm Installation](#method-2-global-npm-installation)
32
33
  - [🏗️ Trae (Official IDE by ByteDance)](#️-trae-official-ide-by-bytedance)
33
34
  - [🌊 Windsurf (Official IDE by Codeium)](#-windsurf-official-ide-by-codeium)
34
35
  - [⚡ Zed](#-zed)
@@ -134,6 +135,8 @@ Restart Claude Code after completion.
134
135
 
135
136
  Claude Desktop supports MCP servers via a global configuration file:
136
137
 
138
+ #### Method 1: Manual Addition via Config File
139
+
137
140
  1. Open the Claude Desktop configuration file:
138
141
  - Windows Path: `%APPDATA%\Claude\claude_desktop_config.json`
139
142
  - macOS Path: `~/Library/Application Support/Claude/claude_desktop_config.json`
@@ -145,14 +148,19 @@ Claude Desktop supports MCP servers via a global configuration file:
145
148
  "mcpServers": {
146
149
  "bilibili-mcp": {
147
150
  "command": "npx",
148
- "args": ["-y", "@xzxzzx/bilibili-mcp"]
151
+ "args": ["-y", "@xzxzzx/bilibili-mcp"],
152
+ "env": {
153
+ "BILIBILI_SESSDATA": "YOUR_SESSDATA",
154
+ "BILIBILI_BILI_JCT": "YOUR_bili_jct",
155
+ "BILIBILI_DEDEUSERID": "YOUR_DedeUserID"
156
+ }
149
157
  }
150
158
  }
151
159
  }
152
160
  ```
153
161
  3. Save the file and restart Claude Desktop or start a new conversation to load the tools.
154
162
 
155
- #### Method 3: Global npm Installation
163
+ #### Method 2: Global npm Installation
156
164
 
157
165
  Manage configuration via the CLI tool after installation:
158
166
 
@@ -399,9 +407,29 @@ npm run watch
399
407
  ## ⚖️ Safety and Disclaimer
400
408
 
401
409
  - **Trademark**: Bilibili is a registered trademark of Bilibili Inc. This is a third-party open-source tool.
402
- - **Spirit**: For personal learning and research only. Commercial exploitation or large-scale scraping is prohibited.
403
410
  - **Liability**: Requests originate locally. Developers are not responsible for account restrictions.
404
411
  - **Privacy**: No back-end uploading; credentials stored locally.
405
412
 
406
413
  ### License
407
- Open-sourced under **GNU General Public License v3.0**.
414
+ Open-sourced under **GNU General Public License v3.0**.
415
+
416
+ ---
417
+
418
+ ## 🛠️ Development Process
419
+
420
+ This project is a crystal of AI-collaborative development, spanning from prototype to refinement:
421
+
422
+ 1. **Initial Generation**: Core architecture and base logic were rapidly built by **Claude Code** (powered by **GLM-4.7** model).
423
+ 2. **Debugging & Optimization**: Bugs were fixed and features enhanced using **Claude** and **Gemini** models within the **Antigravity** environment, ensuring stable subtitle extraction and comment analysis.
424
+ 3. **Multi-IDE Compatibility**: Through iterative updates, it now seamlessly supports Cursor, Trae, Windsurf, Zed, and mainstream AI CLI tools.
425
+
426
+ ---
427
+
428
+ ## 💬 Feedback & Suggestions
429
+
430
+ If you encounter any issues or have feature suggestions, feel free to reach out:
431
+
432
+ - **Submit an Issue**: [GitHub Issues](https://github.com/365903728-oss/bilibili-mcp/issues) — **Recommended**, I check and respond regularly.
433
+ - **Discussions**: Join our [GitHub Discussions](https://github.com/365903728-oss/bilibili-mcp/discussions) (if enabled) for general chat.
434
+
435
+ Thank you for your support!
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export {};
1
+ import { server } from "./server.js";
2
+ export default server;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiBrC,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -1,24 +1,34 @@
1
1
  // MCP 服务器入口
2
- import { config } from 'dotenv';
3
- import { fileURLToPath } from 'url';
4
- import { dirname, resolve } from 'path';
2
+ import { config } from "dotenv";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname, resolve } from "path";
5
+ import { server } from "./server.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
7
  // 获取当前文件的目录
6
8
  const __filename = fileURLToPath(import.meta.url);
7
9
  const __dirname = dirname(__filename);
8
- // 使用绝对路径加载.env文件
9
- const envPath = resolve(__dirname, '../.env');
10
- config({ path: envPath });
11
- import { server } from "./server.js";
12
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
13
- // 启动服务器
10
+ // 尝试加载.env文件
11
+ const envPath = resolve(__dirname, "../.env");
12
+ try {
13
+ config({ path: envPath });
14
+ }
15
+ catch (e) {
16
+ // .env is optional
17
+ }
18
+ // 供 Smithery 沙盒反射使用的纯净实例导出
19
+ // 绝不能在这里执行任何副作用
20
+ export default server;
21
+ // 启动服务器的入口点
14
22
  async function main() {
15
- console.error("本工具仅供技术研究使用,请确保您的访问行为符合平台规范");
16
23
  const transport = new StdioServerTransport();
17
24
  await server.connect(transport);
18
25
  console.error("Bilibili MCP server running on stdio");
19
26
  }
20
- main().catch((error) => {
21
- console.error("Fatal error in main():", error);
22
- process.exit(1);
23
- });
27
+ // 检查是否作为主模块运行
28
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
29
+ main().catch((error) => {
30
+ console.error("Fatal error:", error);
31
+ process.exit(1);
32
+ });
33
+ }
24
34
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExC,YAAY;AACZ,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,iBAAiB;AACjB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAC9C,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,QAAQ;AACR,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;AACxD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,YAAY;AACZ,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,aAAa;AACb,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAC9C,IAAI,CAAC;IACH,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAC5B,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,mBAAmB;AACrB,CAAC;AAED,2BAA2B;AAC3B,gBAAgB;AAChB,eAAe,MAAM,CAAC;AAEtB,YAAY;AACZ,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;AACxD,CAAC;AAED,cAAc;AACd,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ declare const server: McpServer;
3
+ export default server;
4
+ //# sourceMappingURL=smithery-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithery-test.d.ts","sourceRoot":"","sources":["../src/smithery-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,QAAA,MAAM,MAAM,WAGV,CAAC;AAUH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ const server = new McpServer({
4
+ name: "test",
5
+ version: "1"
6
+ });
7
+ server.tool("dummy_tool", { input: z.string() }, async ({ input }) => ({
8
+ content: [{ type: "text", text: `Dummy ${input}` }]
9
+ }));
10
+ export default server;
11
+ //# sourceMappingURL=smithery-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithery-test.js","sourceRoot":"","sources":["../src/smithery-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,GAAG;CACb,CAAC,CAAC;AAEH,MAAM,CAAC,IAAI,CACT,YAAY,EACZ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EACrB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,EAAE,EAAE,CAAC;CACpD,CAAC,CACH,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@xzxzzx/bilibili-mcp",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Bilibili MCP tool for video and comment summarization",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "src/index.ts",
7
+ "module": "./src/index.ts",
7
8
  "bin": {
8
9
  "bilibili-mcp": "dist/cli.js"
9
10
  },
@@ -11,6 +12,8 @@
11
12
  "build": "tsc",
12
13
  "watch": "tsc --watch",
13
14
  "start": "node dist/index.js",
15
+ "dev": "smithery dev",
16
+ "build:smithery": "smithery build",
14
17
  "prepublishOnly": "npm run build",
15
18
  "test": "echo \"Error: no test specified\" && exit 1",
16
19
  "test:env": "node -e \"console.log('检查环境变量...'); console.log('BILIBILI_SESSDATA:', process.env.BILIBILI_SESSDATA ? '✅ 已配置' : '❌ 未配置'); console.log('BILIBILI_BILI_JCT:', process.env.BILIBILI_BILI_JCT ? '✅ 已配置' : '❌ 未配置'); console.log('BILIBILI_DEDEUSERID:', process.env.BILIBILI_DEDEUSERID ? '✅ 已配置' : '❌ 未配置');\"",
@@ -58,7 +61,7 @@
58
61
  "node": ">=18.0.0"
59
62
  },
60
63
  "dependencies": {
61
- "@modelcontextprotocol/sdk": "^1.0.4",
64
+ "@modelcontextprotocol/sdk": "^1.27.1",
62
65
  "commander": "^14.0.3",
63
66
  "dotenv": "^17.2.4",
64
67
  "quick-lru": "^7.3.0"
@@ -68,7 +71,9 @@
68
71
  "@semantic-release/git": "^10.0.1",
69
72
  "@semantic-release/github": "^11.0.1",
70
73
  "@semantic-release/npm": "^12.0.1",
74
+ "@smithery/cli": "^4.5.0",
71
75
  "@types/node": "^22.19.8",
76
+ "esbuild": "^0.24.2",
72
77
  "semantic-release": "^25.0.3",
73
78
  "typescript": "^5.7.2"
74
79
  }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ // MCP 服务器入口
2
+ import { config } from "dotenv";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname, resolve } from "path";
5
+ import { server } from "./server.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+
8
+ // 获取当前文件的目录
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
11
+
12
+ // 尝试加载.env文件
13
+ const envPath = resolve(__dirname, "../.env");
14
+ try {
15
+ config({ path: envPath });
16
+ } catch (e) {
17
+ // .env is optional
18
+ }
19
+
20
+ // 供 Smithery 沙盒反射使用的纯净实例导出
21
+ // 绝不能在这里执行任何副作用
22
+ export default server;
23
+
24
+ // 启动服务器的入口点
25
+ async function main() {
26
+ const transport = new StdioServerTransport();
27
+ await server.connect(transport);
28
+ console.error("Bilibili MCP server running on stdio");
29
+ }
30
+
31
+ // 检查是否作为主模块运行
32
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
33
+ main().catch((error) => {
34
+ console.error("Fatal error:", error);
35
+ process.exit(1);
36
+ });
37
+ }