Token导航 LogoToken导航TokenDH.com
Mongodb Novel Server logo
AI代理stdio官方级别未说明来源级核验

Mongodb Novel Server

MCP Server

高性能MCP服务器,为大型语言模型提供与MongoDB的高效知识交互接口,适用于小上下文窗口的领域知识检索与管理。

工具数

7

提示词数

0

GitHub Stars

1

资源数

0
数据分析RustAI代理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

SFBB

提供方

SFBB

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

MCP MongoDB服务器

高性能 模型上下文协议(MCP) 服务器,在大型语言模型(LLM)和MongoDB之间提供高效的知识接口。该服务器针对小型上下文窗口(3k个令牌)进行了优化,使LLM能够检索存储在MongoDB集合中的特定于域的知识并与之交互。

🚀 特性

  • 双服务器架构:

- 基于SSE的MCP服务器,用于高效的LLM通信 - 用于数据库管理的RESTful CRUD API

  • 代币效率:响应格式化为在小上下文窗口内实现最大信息密度
  • MongoDB集成:与具有优化查询机制的现有MongoDB集合配合使用
  • 数据模型 对于多个特定于域的实体:

- 小说 - 章节 - 角色 - 问答知识库

  • Python Scraper集成:作为子模块,用于从各种来源填充数据库

🔧 建筑

                    ┌───────────────────┐
                    │                   │
                    │     Language      │
                    │      Models       │
                    │                   │
                    └─────────┬─────────┘
                              │
                              │ MCP (JSON-RPC 2.0)
                              ▼
┌─────────────────────────────────────────────────────┐
│                                                     │
│  ┌─────────────────┐           ┌─────────────────┐  │
│  │                 │           │                 │  │
│  │   SSE Server    │◄────────►│   MCP Handler   │  │
│  │  (Port 3000)    │           │                 │  │
│  └─────────────────┘           └────────┬────────┘  │
│                                         │           │
│                                         ▼           │
│                                ┌────────────────┐   │
│  ┌─────────────────┐           │                │   │
│  │                 │           │  DB Services   │   │
│  │   CRUD API      │◄────────►│                │   │
│  │  (Port 3001)    │           └────────────────┘   │
│  └─────────────────┘                   │           │
│                                         │           │
└─────────────────────────────────────────┼───────────┘
                                          │
                                          ▼
                                 ┌─────────────────┐
                                 │                 │
                                 │    MongoDB      │
                                 │                 │
                                 └─────────────────┘

🏁 入门指南

先决条件

  • Rust(最新稳定的工具链)
  • MongoDB实例
  • Python 3.7+(用于数据抓取器)

安装

  1. 使用子模块克隆存储库:
   git clone --recursive https://github.com/SFBB/mcp-mongodb-novel-server.git
   cd mcp-mongodb-novel-server
  1. 配置环境:

创建一个 .env 项目根目录中的文件:

   MONGODB_URI=mongodb://localhost:27017
   DATABASE_NAME=your_database
   PORT=3000  # Base port (MCP SSE server)
               # CRUD API will use PORT+1 (3001)
  1. 构建并运行:
   cargo build --release
   cargo run --release

成功启动后,您将看到:

  • MCP SSE端点位于http://127.0.0.1:3000/sse
  • MCP POST端点位于http://127.0.0.1:3000/message
  • CRUD API端点位于http://127.0.0.1:3001/api/...

用法

您首先需要运行此服务器。然后基于JSON-RPC或SSE配置您的客户端。

这是VSCode副驾驶客户端的示例设置。

"mcp-mongodb-novel-server": {
    "type": "sse",
    "url": "http://localhost:3000/sse"
}  

🔌 服务器端点

1.MCP服务器(SSE协议)

MCP服务器提供两个端点:

  • SSE 终端: http://localhost:3000/sse

- 用于建立SSE连接以接收事件

  • POST端点: http://localhost:3000/message

- 用于发送JSON-RPC 2.0格式的命令

MCP请求示例(使用POST /message):

{
  "jsonrpc": "2.0",
  "id": "request-1",
  "method": "query_character",
  "params": {
    "character_id": "5f8e4c3b2a1d"
  }
}

2.CRUD API(REST)

CRUD API为管理数据库内容提供了RESTful端点:

  • 小说: /api/novels
  • 章节: /api/chapters
  • 角色: /api/characters
  • 问答: /api/qa

标准REST操作(GET, POST, PATCH, DELETE)支持。

📊 数据模型

小说

{
  "_id": "ObjectId",
  "title": "String",
  "author": "String",
  "summary": "String",
  "year": "Number",
  "tags": ["String"]
}

章节

{
  "_id": "ObjectId",
  "novel_id": "ObjectId",
  "title": "String",
  "chapter_number": "Number",
  "summary": "String",
  "content": "String",
  "word_count": "Number"
}

角色

{
  "_id": "ObjectId",
  "novel_id": "ObjectId",
  "name": "String",
  "description": "String",
  "traits": ["String"],
  "relationships": [
    {
      "character_id": "ObjectId",
      "type": "String"
    }
  ]
}

问答

{
  "_id": "ObjectId",
  "question": "String",
  "answer": "String",
  "tags": ["String"],
  "novel_id": "ObjectId"
}

🤖 MCP方法

服务器支持以下MCP方法进行LLM交互:

查询方法

方法说明参数
query_character获取角色详细信息{"character_id": "string"}
query_novel获取新元数据{"novel_id": "string"}
query_chapter获取章节信息{"chapter_id": "string"}{"chapter_number": number}{"chapter_title": "string"}
query_qa_regex按正则表达式查找问答条目{"regex_pattern": "string"}
query_chapter_regex按正则表达式查找章节{"regex_pattern": "string"}
query_character_regex通过正则表达式查找字符{"regex_pattern": "string"}

更新方法

方法说明参数
update_chapter_summary更新章节摘要{"auth_token": "string", "chapter_id": "string", "summary": "string"}

📥 数据总体

该项目包括Python抓取器作为子模块,以帮助填充MongoDB:

字符刮刀

cd character-scraper
pip install -r requirements.txt
python src/scraper.py --config config/settings.json

新型刮刀库

cd scraper_library
pip install -r requirements.txt
python -m src.scrapers.scrape_syosetu --url 

可用的刮板包括:

  • scrape_syosetu.py (Syosetu小说)
  • scrape_69shu.py (蜀小说69篇)
  • scrape_ximalaya.py (喜马拉雅有声读物)
  • scrape_qa.py (问答内容)
  • scrape_x_timeline.py (推特/X时间线)
  • 还有更多。..

🛠️ 发展

更新子模块

# Update all submodules to their latest version
git submodule update --remote --merge

# Navigate to a specific submodule and pull changes
cd scraper_library
git pull origin main
cd ..
git add scraper_library
git commit -m "Update scraper_library"

运行测试

cargo test

代码的风格

本项目遵循Rust的标准代码风格指南:

# Check code formatting
cargo fmt -- --check

# Run linting
cargo clippy

性能调整

对于高流量部署,请考虑:

  1. 用于文本搜索和关系的MongoDB索引
  2. 为CPU受限的操作增加Tokio工作线程
  3. 配置MongoDB连接池

📄 许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

目录标签

目录标签

数据分析RustAI代理MongoDB接口本地部署知识检索LLM集成双服务器架构数据模型

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

7

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP