这是一个基于 Model Context Protocol (MCP) 的 B站视频搜索服务器。它提供了简单的 API 接口,方便用户搜索 B站的视频内容,同时还提供了 LangChain 调用示例和测试脚本。
⚠️ 重要提示
若要运行 LangChain 示例,请先配置 LLM 模型,修改
.example.ts
文件。
const llm = new ChatOpenAI({
modelName: "gpt-4o-mini",
temperature: 0,
openAIApiKey: "your_api_key", // 替换为你的模型密钥
configuration: {
baseURL: "https://www.api.com/v1", // 替换为你的 API 地址
},
});
bun 环境:
bun i
bun index.ts
# 测试脚本
bun test.js
# MCP 检查工具
bun run inspector
# 运行 LangChain 示例
bun build:bun
bun example.ts
npm 环境:
npm i
npm run start
# 测试脚本
npm run test
# MCP 检查工具
npm run inspector
# 运行 LangChain 示例
npm run build
node dist/example.js
系统要求:
npm 包: 感谢 HQHC 发布的 npm 包:
{
"mcpServers": {
"bilibili-search": {
"command": "npx",
"args": ["bilibili-mcp"],
"description": "B站视频搜索 MCP 服务,支持在 AI 应用中调用 B站视频内容。"
}
}
}
const llm = new ChatOpenAI({
modelName: "gpt-4o-mini",
temperature: 0,
openAIApiKey: "your_api_key", // 替换为你的模型密钥
configuration: {
baseURL: "https://www.api.com/v1", // 替换为你的 API 地址
},
});
说明: 图1:测试结果
说明: 图2:其他测试结果
文档中未提及许可证信息,若有相关内容可补充至此。
参考了 mcp-langchain-ts-client 的 LangChain 示例代码。