MCP MongoDB Server
@SFBB
A Model Context Protocol (MCP) server that provides an interface between LLMs and MongoDB databases, optimized for small context windows (3k tokens). Specially for novel.
Overview
What is MCP MongoDB Server?
MCP MongoDB Server is a high-performance Model Context Protocol (MCP) server that provides an efficient knowledge interface between Large Language Models (LLMs) and MongoDB. It is optimized for small context windows (3k tokens) and enables LLMs to retrieve and interact with domain-specific knowledge stored in MongoDB collections.
How to use MCP MongoDB Server?
Clone the repository with submodules, configure a .env file with MONGODB_URI, DATABASE_NAME, and PORT, then build and run with cargo build --release and cargo run --release. After startup, configure your MCP client (e.g., VSCode copilot) to connect via SSE at http://localhost:3000/sse.
Key features of MCP MongoDB Server
- Dual‑server architecture: SSE‑based MCP and RESTful CRUD API
- Token‑efficient responses for small LLM context windows
- Integrated MongoDB query mechanisms and data models
- Built‑in models for Novels, Chapters, Characters, and Q&A
- Python scraper submodules for populating databases
Use cases of MCP MongoDB Server
- Query character details from a novel database via LLM
- Retrieve novel metadata and chapter summaries with regex search
- Update chapter summaries using an MCP method with authentication
- Populate MongoDB from Syosetu, 69Shu, Ximalaya, or Twitter/X timelines
FAQ from MCP MongoDB Server
What ports does the server use?
The MCP SSE server runs on port 3000, and the CRUD API runs on port 3001 (PORT+1).
What data models are supported?
The server includes models for Novels, Chapters, Characters, and Q&A knowledge base entries.
How do I update database content?
You can use the RESTful CRUD API endpoints (/api/novels, /api/chapters, /api/characters, /api/qa) or MCP methods like update_chapter_summary (requires an auth token).
What are the runtime dependencies?
You need a Rust toolchain, a running MongoDB instance, and Python 3.7+ if you use the included data scrapers.
How does the server communicate with LLMs?
The server exposes an SSE endpoint (/sse) for streaming events and a POST endpoint (/message) for JSON‑RPC 2.0 commands, both over HTTP.