feat: add mcp-servers/**

This commit is contained in:
Sun-ZhenXing
2025-10-23 09:08:07 +08:00
parent ece59b42bf
commit f603ed5db9
57 changed files with 3061 additions and 95 deletions

View File

@@ -0,0 +1,26 @@
# MCP MongoDB Service version
MCP_MONGODB_VERSION=latest
# MongoDB version
MONGODB_VERSION=7
# MCP MongoDB service port
MCP_MONGODB_PORT_OVERRIDE=8000
# MongoDB port
MONGODB_PORT_OVERRIDE=27017
# MongoDB connection URI
MONGODB_URI=mongodb://mongodb:27017
# MongoDB database name
MONGODB_DATABASE=mcp_db
# MongoDB root username
MONGO_ROOT_USERNAME=admin
# MongoDB root password
MONGO_ROOT_PASSWORD=password
# Timezone
TZ=UTC

View File

@@ -0,0 +1,104 @@
# MongoDB MCP Server
MongoDB MCP Server provides MongoDB database interaction capabilities through the Model Context Protocol, including data querying, insertion, updating, and collection management.
## Features
- 📊 **Database Operations** - CRUD operations support
- 🔍 **Query & Aggregation** - Complex queries and aggregation pipelines
- 📝 **Collection Management** - Create, delete, and modify collections
- 🔐 **Authentication** - Built-in authentication support
- <20> **Monitoring** - Health checks and resource monitoring
- 🌐 **RESTful API** - MCP protocol-based API interface
## Architecture
The service includes two containers:
- **mcp-mongodb**: MCP protocol adapter providing API interface
- **mongodb**: MongoDB database instance
## Environment Variables
| Variable | Default | Description |
| --------------------------- | ------------------------- | --------------------------------------- |
| `MCP_MONGODB_VERSION` | `latest` | MCP MongoDB service version |
| `MONGODB_VERSION` | `7` | MongoDB version |
| `MCP_MONGODB_PORT_OVERRIDE` | `8000` | MCP service port |
| `MONGODB_PORT_OVERRIDE` | `27017` | MongoDB port |
| `MONGODB_URI` | `mongodb://mongodb:27017` | MongoDB connection URI |
| `MONGODB_DATABASE` | `mcp_db` | Database name |
| `MONGO_ROOT_USERNAME` | `admin` | Root username |
| `MONGO_ROOT_PASSWORD` | `password` | Root password (⚠️ change in production!) |
| `TZ` | `UTC` | Timezone |
## Quick Start
### 1. Configure Environment
Create a `.env` file:
```env
MCP_MONGODB_VERSION=latest
MONGODB_VERSION=7
MCP_MONGODB_PORT_OVERRIDE=8000
MONGODB_PORT_OVERRIDE=27017
MONGODB_DATABASE=mcp_db
MONGO_ROOT_USERNAME=admin
MONGO_ROOT_PASSWORD=your_secure_password
TZ=Asia/Shanghai
```
### 2. Start Services
```bash
docker compose up -d
```
### 3. Verify Services
Check MCP service:
```bash
curl http://localhost:8000/health
```
Connect to MongoDB:
```bash
docker compose exec mongodb mongosh -u admin -p your_secure_password
```
## Resource Requirements
- **MCP Service**: 128MB-512MB memory, 0.25-1.0 CPU
- **MongoDB**: 512MB-2GB memory, 0.5-2.0 CPU
## Security Recommendations
1. **Change Default Password**: Always change `MONGO_ROOT_PASSWORD` in production
2. **Network Isolation**: Use internal networks, avoid exposing MongoDB port publicly
3. **Enable Authentication**: Ensure MongoDB authentication is enabled
4. **Regular Backups**: Set up regular data backup schedules
## Data Persistence
- `mongodb_data`: MongoDB data directory
- `mongodb_config`: MongoDB configuration directory
## Common Use Cases
1. **Application Backend** - As database backend for applications
2. **Data Analysis** - Store and query analysis data
3. **Document Storage** - Store and retrieve JSON documents
4. **Session Management** - Store user sessions
## References
- [MongoDB Official Documentation](https://docs.mongodb.com/)
- [MCP Documentation](https://modelcontextprotocol.io/)
- [Docker Hub - mongo](https://hub.docker.com/_/mongo)
## License
MIT License

View File

@@ -0,0 +1,104 @@
# MongoDB MCP Server
MongoDB MCP Server 提供通过模型上下文协议MCP与 MongoDB 数据库交互的能力,包括数据查询、插入、更新和集合管理。
## 功能特性
- 📊 **数据库操作** - 支持 CRUD 操作
- 🔍 **查询和聚合** - 复杂查询和聚合管道
- 📝 **集合管理** - 创建、删除、修改集合
- 🔐 **身份认证** - 内置认证支持
- 📈 **监控** - 健康检查和资源监控
- 🌐 **RESTful API** - 基于 MCP 协议的 API 接口
## 架构
该服务包含两个容器:
- **mcp-mongodb**MCP 协议适配器,提供 API 接口
- **mongodb**MongoDB 数据库实例
## 环境变量
| 变量 | 默认值 | 说明 |
| --------------------------- | ------------------------- | -------------------------------- |
| `MCP_MONGODB_VERSION` | `latest` | MCP MongoDB 服务版本 |
| `MONGODB_VERSION` | `7` | MongoDB 版本 |
| `MCP_MONGODB_PORT_OVERRIDE` | `8000` | MCP 服务端口 |
| `MONGODB_PORT_OVERRIDE` | `27017` | MongoDB 端口 |
| `MONGODB_URI` | `mongodb://mongodb:27017` | MongoDB 连接 URI |
| `MONGODB_DATABASE` | `mcp_db` | 数据库名称 |
| `MONGO_ROOT_USERNAME` | `admin` | 管理员用户名 |
| `MONGO_ROOT_PASSWORD` | `password` | 管理员密码(⚠️ 生产环境请修改!) |
| `TZ` | `UTC` | 时区 |
## 快速开始
### 1. 配置环境
创建 `.env` 文件:
```env
MCP_MONGODB_VERSION=latest
MONGODB_VERSION=7
MCP_MONGODB_PORT_OVERRIDE=8000
MONGODB_PORT_OVERRIDE=27017
MONGODB_DATABASE=mcp_db
MONGO_ROOT_USERNAME=admin
MONGO_ROOT_PASSWORD=your_secure_password
TZ=Asia/Shanghai
```
### 2. 启动服务
```bash
docker compose up -d
```
### 3. 验证服务
检查 MCP 服务:
```bash
curl http://localhost:8000/health
```
连接 MongoDB
```bash
docker compose exec mongodb mongosh -u admin -p your_secure_password
```
## 资源需求
- **MCP 服务**128MB-512MB 内存0.25-1.0 CPU
- **MongoDB**512MB-2GB 内存0.5-2.0 CPU
## 安全建议
1. **修改默认密码**:生产环境务必修改 `MONGO_ROOT_PASSWORD`
2. **网络隔离**:使用内部网络,避免 MongoDB 端口暴露到公网
3. **启用认证**:确保 MongoDB 认证已启用
4. **定期备份**:设置定期数据备份计划
## 数据持久化
- `mongodb_data`MongoDB 数据目录
- `mongodb_config`MongoDB 配置目录
## 常见使用场景
1. **应用后端** - 作为应用程序的数据库后端
2. **数据分析** - 存储和查询分析数据
3. **文档存储** - 存储和检索 JSON 文档
4. **会话管理** - 存储用户会话
## 参考链接
- [MongoDB 官方文档](https://docs.mongodb.com/)
- [MCP 文档](https://modelcontextprotocol.io/)
- [Docker Hub - mongo](https://hub.docker.com/_/mongo)
## 许可证
MIT License

View File

@@ -0,0 +1,70 @@
x-default: &default
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
mcp-mongodb:
<<: *default
image: mcp/mongodb:${MCP_MONGODB_VERSION:-latest}
environment:
- MONGODB_URI=${MONGODB_URI:-mongodb://mongodb:27017}
- MONGODB_DATABASE=${MONGODB_DATABASE:-mcp_db}
- MCP_HOST=0.0.0.0
- TZ=${TZ:-UTC}
ports:
- "${MCP_MONGODB_PORT_OVERRIDE:-8000}:8000"
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1.00'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
mongodb:
<<: *default
image: mongo:${MONGODB_VERSION:-7}
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USERNAME:-admin}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD:-password}
- MONGO_INITDB_DATABASE=${MONGODB_DATABASE:-mcp_db}
- TZ=${TZ:-UTC}
ports:
- "${MONGODB_PORT_OVERRIDE:-27017}:27017"
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '2.00'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
volumes:
mongodb_data:
driver: local
mongodb_config:
driver: local