解析MCP服务器🗄️
通过 艾略特Guillaumin
](https://hub.docker.com/r/purpleshow/parse-mcp-server) ](https://hub.docker.com/r/purpleshow/parse-mcp-server) ](https://github.com/R3D347HR4Y/parse-mcp/blob/main/LICENSE) ](https://nodejs.org)
特性
- 🔍 数据库探索 -发现模式、类和关系
- 📊 查询 -完全解析查询支持过滤器、排序、分页
- 🔗 关系 -查询和管理指针和关系字段
- ✏️ CRUD操作 -创建、读取、更新、删除对象(带有安全提示)
- 📦 批量操作 -批量创建、更新和删除
- ☁️ 云功能 -执行解析云代码
- 📈 聚合 -MongoDB风格的聚合管道
- 🔐 角色和用户 -查询用户和角色
- 🛡️ 安全第一 -内置提示,在修改前请求许可
快速开始
先决条件
- Node.js 18+(或Docker)
- 具有有效凭据的解析服务器实例
安装
# Clone the repository
git clone https://github.com/R3D347HR4Y/parse-mcp.git
cd parse-mcp
# Install dependencies
npm install
# Build
npm run build或者使用Docker(推荐):
docker pull purpleshow/parse-mcp-server:latest环境变量
解析服务器配置
| 变量 | 必填 | 描述 |
|---|---|---|
PARSE_SERVER_URL | ✅ | 解析服务器URL(例如。, https://parseapi.back4app.com) |
PARSE_APP_ID | ✅ | 您的解析应用程序ID |
PARSE_MASTER_KEY | ⚠️ | 管理操作的主密钥(模式访问、配置) |
PARSE_JS_KEY | ❌ | JavaScript键(可选) |
PARSE_REST_KEY | ❌ | REST API密钥(可选) |
MCP传输配置
| 变量 | 默认值 | 描述 |
|---|---|---|
MCP_TRANSPORT | http | 运输方式: http 或 stdio |
MCP_PORT | 3000 | HTTP服务器端口(仅用于HTTP传输) |
MCP_HOST | 0.0.0.0 | HTTP服务器主机(仅用于HTTP传输) |
⚠️ 重要提示: 主密钥授予对数据库的完全访问权限。仅在必要时使用,切勿公开。
设置指南
HTTP模式(默认-建议用于远程/Docker)
默认情况下,服务器作为HTTP服务器运行,这使得远程部署或在容器中部署变得容易。
# Start the HTTP server (default port 3000)
PARSE_SERVER_URL="https://your-server.com/parse" \
PARSE_APP_ID="your-app-id" \
PARSE_MASTER_KEY="your-master-key" \
npm start
# Or specify a custom port
MCP_PORT=8080 npm start服务器公开:
POST /mcp-MCP可流式HTTP端点GET /mcp-服务器发送事件的SSE流DELETE /mcp-会话终止GET /health-健康检查端点
光标IDE(标准输入模式)
对于本地Cursor IDE集成,请使用stdio模式。添加到光标设置(.cursor/mcp.json):
{
"mcpServers": {
"parse": {
"command": "node",
"args": ["/path/to/parse-mcp-server/dist/index.js"],
"env": {
"MCP_TRANSPORT": "stdio",
"PARSE_SERVER_URL": "https://your-parse-server.com/parse",
"PARSE_APP_ID": "your-app-id",
"PARSE_MASTER_KEY": "your-master-key"
}
}
}
}克劳德桌面(stdio模式)
添加到您的Claude桌面配置(claude_desktop_config.json):
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\ 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"parse": {
"command": "node",
"args": ["/path/to/parse-mcp-server/dist/index.js"],
"env": {
"MCP_TRANSPORT": "stdio",
"PARSE_SERVER_URL": "https://your-parse-server.com/parse",
"PARSE_APP_ID": "your-app-id",
"PARSE_MASTER_KEY": "your-master-key"
}
}
}
}直接运行
# HTTP mode (default) - starts an HTTP server
PARSE_SERVER_URL="https://your-parse-server.com/parse" \
PARSE_APP_ID="your-app-id" \
PARSE_MASTER_KEY="your-master-key" \
node dist/index.js
# stdio mode - for local IDE integration
MCP_TRANSPORT=stdio \
PARSE_SERVER_URL="https://your-parse-server.com/parse" \
PARSE_APP_ID="your-app-id" \
PARSE_MASTER_KEY="your-master-key" \
node dist/index.jsDocker部署
使用Docker Hub中的预构建映像:
# Pull the image
docker pull purpleshow/parse-mcp-server:latest
# Run in HTTP mode (default) - exposes port 3000
docker run -d \
-p 3000:3000 \
-e PARSE_SERVER_URL="https://your-parse-server.com/parse" \
-e PARSE_APP_ID="your-app-id" \
-e PARSE_MASTER_KEY="your-master-key" \
purpleshow/parse-mcp-server:latest
# The MCP server is now available at http://localhost:3000/mcp
# Health check: http://localhost:3000/health或者从源代码构建:
docker build -t parse-mcp-server .在stdio模式下使用Docker(适用于Cursor/Claude)
通过stdio进行本地IDE集成:
{
"mcpServers": {
"parse": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MCP_TRANSPORT=stdio",
"-e",
"PARSE_SERVER_URL=https://your-parse-server.com/parse",
"-e",
"PARSE_APP_ID=your-app-id",
"-e",
"PARSE_MASTER_KEY=your-master-key",
"purpleshow/parse-mcp-server:latest"
]
}
}
}Back4App设置
对于 Back4App 托管解析服务器:
{
"mcpServers": {
"parse": {
"command": "node",
"args": ["/path/to/parse-mcp-server/dist/index.js"],
"env": {
"PARSE_SERVER_URL": "https://parseapi.back4app.com",
"PARSE_APP_ID": "your-back4app-app-id",
"PARSE_MASTER_KEY": "your-back4app-master-key",
"PARSE_JS_KEY": "your-back4app-js-key"
}
}
}
}在Back4App控制面板中查找您的密钥→ 应用设置→ 安全和钥匙。
可用工具
连接与健康
| 工具 | 说明 |
|---|---|
check_connection | 验证解析服务器连接和运行状况 |
模式探索
| 工具 | 说明 |
|---|---|
get_all_schemas | 获取所有类的模式(需要主密钥) |
get_class_schema | 获取特定类的架构 |
数据探索
| 工具 | 说明 |
|---|---|
get_sample_objects | 从类中获取示例对象以理解数据结构 |
query_class | 使用过滤器、排序、分页查询对象 |
count_objects | 统计与查询匹配的对象 |
get_object_by_id | 按ID获取特定对象 |
关系
| 工具 | 说明 |
|---|---|
query_relation | 在关系字段中查询对象 |
add_to_relation | 向关系中添加对象⚠️ |
remove_from_relation | 从关系中删除对象⚠️ |
CRUD操作
| 工具 | 说明 |
|---|---|
create_object | 创建新对象⚠️ |
update_object | 更新现有对象⚠️ |
delete_object | 删除对象⚠️ 🔴 |
批量操作
| 工具 | 说明 |
|---|---|
batch_create | 创建多个对象⚠️ |
batch_update | 更新多个对象⚠️ |
batch_delete | 删除多个对象⚠️ 🔴 |
用户和角色
| 工具 | 说明 |
|---|---|
query_users | 查询_User类 |
get_roles | 获取所有已定义的角色 |
get_role_users | 让用户担任特定角色 |
云代码
| 工具 | 说明 |
|---|---|
run_cloud_function | 执行云代码功能⚠️ |
聚合
| 工具 | 说明 |
|---|---|
aggregate_class | 运行聚合管道(需要主密钥) |
故障排除
| 工具 | 说明 |
|---|---|
validate_pointer | 检查指针是否引用有效对象 |
find_orphaned_pointers | 在类中查找损坏的指针引用 |
get_class_statistics | 获取某个类的统计信息 |
配置
| 工具 | 说明 |
|---|---|
get_config | 获取解析配置值 |
update_config | 更新分析配置值⚠️ |
传说:
- ⚠️ = 修改数据(请求权限)
- 🔴 = 破坏性操作(格外小心)
使用示例
探索数据库
You: "What classes exist in this Parse database and what data do they contain?"
AI: Let me check the connection and explore the schema...
[Uses check_connection, get_all_schemas, get_sample_objects for each class]查询数据
You: "Find all users who signed up in the last 7 days and have verified their email"
AI: I'll query the _User class with those filters...
[Uses query_class with date and emailVerified constraints]故障排除
You: "Some of our Order objects seem to have broken user references"
AI: I'll scan the Order class for orphaned user pointers...
[Uses find_orphaned_pointers on the "user" field]安全数据修改
You: "Update all products in category 'Electronics' to have a 10% discount"
AI: I found 47 products in the Electronics category. Here are some examples:
[Shows sample products]
Do you want me to proceed with updating all 47 products to add a 10% discount?
You: "Yes, go ahead"
AI: Updating products...
[Uses batch_update with user permission]推荐工作流程
当使用不熟悉的数据库时,人工智能应该遵循以下工作流程:
- 检查连接 →
check_connection - 获取架构概述 →
get_all_schemas - 关键类示例 →
get_sample_objects对于每个相关类别 - 了解统计 →
get_class_statistics对于重要课程 - 根据需要查询 →
query_class使用适当的过滤器 - 请求许可 → 在执行任何写入操作之前
人工智能有内置的提示,引导它完成这一工作流程,并提醒它在修改数据之前始终征求许可。
查询句法
这 query_class 该工具支持解析查询语法。以下是示例:
基本平等
{ "status": "active" }比较运算符
{
"score": { "$gt": 100 },
"age": { "$gte": 18, "$lte": 65 }
}阵列操作
{
"tags": { "$in": ["featured", "sale"] },
"category": { "$nin": ["deprecated", "hidden"] }
}逻辑运算符
{
"$or": [{ "status": "active" }, { "featured": true }]
}指针匹配
{
"author": {
"__type": "Pointer",
"className": "_User",
"objectId": "abc123"
}
}正则表达式
{
"email": { "$regex": "@company\\.com$", "$options": "i" }
}现场存在
{
"profilePicture": { "$exists": true }
}聚合管道
这 aggregate_class 该工具支持MongoDB风格的聚合:
[
{ "$match": { "status": "completed" } },
{
"$group": {
"_id": "$category",
"total": { "$sum": "$amount" },
"count": { "$sum": 1 },
"avgAmount": { "$avg": "$amount" }
}
},
{ "$sort": { "total": -1 } },
{ "$limit": 10 }
]安全考虑
- 主密钥保护:主密钥绕过所有安全措施。仅在必要时使用。
- 环境变量:永远不要将凭据提交到版本控制。
- 权限提示:指示AI在修改数据之前始终进行询问。
- 审计跟踪:考虑使用日志工具以实现合规性。
- 最小特权:如果可能,请使用权限有限的密钥。
故障排除
“解析服务器未初始化”
检查一下 PARSE_SERVER_URL 和 PARSE_APP_ID 设置正确。
“需要主密钥”
架构和配置操作需要主密钥。添加 PARSE_MASTER_KEY 您的环境。
“找不到对象”
objectId不存在,或者您没有访问它的权限。如果合适,请尝试使用主密钥。
连接错误
- 验证解析服务器URL是否正确且可访问
- 检查您的网络/防火墙是否允许连接
- 确保钥匙有效
发展
# Install dependencies
npm install
# Run in development mode (with hot reload)
npm run dev
# Build for production
npm run build
# Run built version
npm start贡献
许可证
链接
- GitHub:
- Docker Hub:
