MongoDB Memory MCP Server
Provides persistent memory storage for AI agents using MongoDB, enabling CRUD operations, score-weighted full-text search, tag filtering, and project context summarization.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MongoDB Memory MCP Server
A production-grade, collaborative MongoDB Memory Model Context Protocol (MCP) Server built using Node.js (ES Modules), MongoDB 7.0, and the official @modelcontextprotocol/sdk.
Acts as a persistent long-term memory engine for AI agents (Claude Desktop, Cursor, Antigravity, Gemini CLI, or custom AI agents), enabling them to store, search, update, delete, retrieve, and summarize structured project memories across developer workflows.
π Table of Contents
Related MCP server: elephantasm-mcp
β¨ Features
2026-07-28 MCP Specification Compliant: Mandatory
server/discoverRPC, stateless_metaparsing,"resultType": "complete",ttlMs/cacheScopeindicators, Streamable HTTP headers (Mcp-Method,Mcp-Name), and deterministic tool sorting.15 Modular MCP Tools: Standardized CRUD operations, score-weighted full-text search, tag filtering, type filtering, recency listing, project context summarization, and Atlas Vector Search readiness.
6 Dynamic Context Resources (
memory://): Exposes live readable project context URIs (memory://project/{projectId},memory://decision/{projectId},memory://bugs/{projectId}, etc.).6 Reusable AI Prompt Templates: Automated prompt generators for architecture reviews, code reviews, documentation generation, and sprint summaries.
Developer Onboarding REST APIs: Management endpoints for projects (
/api/projects), developers (/api/developers), project-bound API keys (/api/keys), and signed JWT tokens (/api/tokens).Dynamic Scope Isolation: Automatically binds
req.auth.projectIdvia MongoDB API key lookup to enforce tenant memory isolation.Dual Transport Modes: Local desktop IDEs via Stdio (
npm start) and remote network agents via Streamable HTTP (npm run start:http) athttp://localhost:3000/messages.Auto-Generated Postman Collection: Live downloadable Postman collection v2.1.0 available at
GET /postman.json.Case-Insensitive Searching: Case-insensitive regex matching ensuring
TodoNative,todonative, andTODONATIVEmatch 100% reliably.Comprehensive Test Suite: 99 unit & integration tests passing across 21 test suites (
vitest+mongodb-memory-server).
π οΈ Tech Stack
Runtime: Node.js 20+ LTS (ES Modules)
MCP SDK:
@modelcontextprotocol/sdk(v1.5.0+)Database: MongoDB 7.0+ (
mongodbNative Node Driver)Web Server: Express v4.21.2 & Cors v2.8.5
Schema Validation:
zodv3.24.1Security & Auth:
jsonwebtokenv9.0.2Logger:
winstonv3.17.0 (Stderr-safe structured JSON logger)Testing:
vitestv3.0.4 &mongodb-memory-serverv10.1.3Containerization: Docker & Docker Compose
π Folder Structure
mongodb-mcp/
βββ docs/ # Comprehensive documentation suite (11 guides)
βββ src/ # Application source code
β βββ config/ # Environment & config validation
β βββ database/ # MongoDB connection pool & indexing
β βββ mcp/ # MCP 2026-07-28 protocol handlers
β βββ middleware/ # Express auth & protocol middleware
β βββ models/ # Protocol constants & error hierarchy
β βββ prompts/ # MCP Prompt Templates Engine
β βββ repositories/ # MongoDB Data Access Repositories
β βββ resources/ # MCP Dynamic Resources (`memory://`)
β βββ schemas/ # Zod validation schemas
β βββ services/ # Core Business Logic Services
β βββ tools/ # Modular MCP Tools Registry (15 tools)
β βββ transports/ # Transport layer (Express HTTP / SSE)
β βββ utils/ # Logger, errors, Postman generator
β βββ server.js # Main server entrypoint & bootstrap
βββ tests/ # Vitest Test Suite (99 tests)
β βββ unit/ # Unit test files
β βββ integration/ # Integration test files
βββ Dockerfile # Multi-stage production Dockerfile
βββ docker-compose.yml # Docker Compose deployment stack
βββ package.json # Dependencies & npm scripts
βββ README.md # Master GitHub READMEβοΈ Prerequisites
Node.js:
>=20.0.0 LTSnpm:
>=10.0.0MongoDB:
7.0+(Local instance or Docker container)
π₯ Installation
# 1. Clone repository
git clone https://github.com/your-username/mongodb-memory-mcp.git
cd mongodb-memory-mcp
# 2. Install dependencies
npm install
# 3. Create environment configuration
cp .env.example .envπ Environment Variables
Variable | Default Value | Description |
|
| Environment mode ( |
|
| MCP Transport mode ( |
|
| HTTP port when |
|
| MongoDB connection URI |
|
| Logging verbosity ( |
|
| Enable/disable authentication middleware |
|
| Master Admin API key |
|
| Secret for signing JWT tokens (min 32 chars) |
π Running Locally
# Start MongoDB via Docker Compose
docker-compose up -d mongodb
# Launch in Stdio Mode (Default for local desktop IDEs)
npm start
# Launch in HTTP Network Mode (Port 3000)
npm run start:httpπ³ Production Build & Docker
# Build & run entire container stack
docker-compose up -d --build
# View container logs
docker-compose logs -f mcp-serverπ Package Scripts
Script | Command | Purpose |
|
| Launch server in Stdio mode |
|
| Launch server in HTTP network mode |
|
| Execute 99 unit & integration tests |
|
| Execute ESLint code quality checks |
|
| Format codebase with Prettier |
|
| Execute connection diagnostics |
|
| CLI helper to generate API keys & JWTs |
π Client Configuration
Streamable HTTP Mode (Antigravity, Cursor, VS Code, Gemini CLI)
{
"mcpServers": {
"mongodb-memory": {
"url": "http://localhost:3000/messages",
"type": "streamable-http",
"headers": {
"X-API-Key": "mcp-memory-api-key"
}
}
}
}Stdio Subprocess Mode (Claude Desktop)
{
"mcpServers": {
"mongodb-memory": {
"command": "node",
"args": ["/Users/sahil/Projects/mongodb-mcp/src/server.js"],
"env": {
"TRANSPORT": "stdio",
"MONGODB_URI": "mongodb://localhost:27017/agent_memory"
}
}
}
}π API Documentation
Complete API documentation for REST endpoints, MCP tools, resources, and prompt templates is available in docs/API_REFERENCE.md and docs/USER_GUIDE.md.
π‘οΈ Security Policy
Please review our SECURITY.md for vulnerability reporting guidelines.
π€ Contributing
We welcome contributions! Please see CONTRIBUTING.md and our CODE_OF_CONDUCT.md for guidance.
π License
Distributed under the MIT License. See LICENSE for details.
π Acknowledgements
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP memory server. One memory your agents share β across models, devices and apps.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Hosted memory for AI agents over MCP. One memory shared by all your agents.
Long-term memory for AI coding agents: durable project facts, recalled by every MCP client.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that provides persistent project context, workflow management, and knowledge capture for AI coding agents. It enables agents to maintain structured memory across sessions by tracking project profiles, conventions, skills, and technical debt.7-
- AlicenseAqualityCmaintenanceMCP server for long-term agent memory, providing persistent memory, searchable knowledge, and evolving identity for AI agents.53Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides persistent long-term memory for AI agents via local SQLite storage with low token overhead, enabling memory storage, retrieval, and management across sessions.1MIT
- AlicenseAqualityCmaintenanceA production-grade long-term memory MCP server that enables AI agents to persist and recall memories across sessions with importance weighting, confidence calibration, and efficient context window management.918 PyPI1MIT