MCP Perfex CRM 是一个高性能的模型上下文协议(MCP)服务器,提供对Perfex CRM的MySQL数据库的直接和优化访问。该项目提供了比传统REST API更高的性能,同时注重代码质量、安全性和可维护性。
npm install -g mcp-perfex-crm
# 克隆仓库
git clone https://github.com/YOUR_USERNAME/mcp-perfex-crm
cd mcp-perfex-crm
# 安装依赖
npm install
# 配置环境
cp .env.example .env
# 使用您的MySQL设置编辑.env
# 编译项目
npm run build
# 运行测试
npm test
# .env
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=perfex_readonly
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=perfex_crm
# 生产日志优化
LOG_LEVEL=error
NODE_ENV=production
ENABLE_AUDIT_LOG=false
MCP Perfex CRM 完全兼容N8N进行工作流自动化:
# 作为N8N工具安装
npm install -g mcp-perfex-crm
# 或在N8N Docker中使用
FROM n8nio/n8n:latest
RUN npm install -g mcp-perfex-crm
N8N工作流示例:
{
"nodes": [
{
"parameters": {
"command": "mcp-perfex-crm",
"options": {
"env": {
"MYSQL_HOST": "your-db-host",
"MYSQL_USER": "readonly_user",
"MYSQL_PASSWORD": "secure_password",
"MYSQL_DATABASE": "perfex_crm"
}
}
},
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [250, 300],
"id": "perfex-crm-tool"
}
]
}
{
"mcpServers": {
"mcp-perfex-crm": {
"command": "mcp-perfex-crm",
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "perfex_readonly",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "perfex_crm"
}
}
}
}
对于本地安装:
{
"mcpServers": {
"mcp-perfex-crm": {
"command": "node",
"args": ["/path/to/mcp-perfex-crm/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "perfex_readonly",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "perfex_crm"
}
}
}
}
// 通过MCP
const result = await use_mcp_tool({
server_name: "mcp-perfex-crm",
tool_name: "get_customers",
arguments: {
limit: 10,
active: true
}
});
const result = await use_mcp_tool({
server_name: "mcp-perfex-crm",
tool_name: "create_project",
arguments: {
name: "新网站",
client_id: 123,
start_date: "2025-02-01",
billing_type: "固定费率",
project_cost: 5000
}
});
# 开发模式带热重载
npm run dev
# 运行linter
npm run lint
# 格式化代码
npm run format
# 运行带有覆盖率的测试
npm run test:coverage
# 生产构建
npm run build
欢迎贡献!请:
git checkout -b feature/AmazingFeature)git commit -m '添加一些AmazingFeature')git push origin feature/AmazingFeature)本项目采用MIT许可证 - 详情见LICENSE文件。
Emanuel Almeida
| 操作 | REST API | MCP直接 | 改进 |
|---|---|---|---|
| 获取客户(100) | 2.3秒 | 0.23秒 | 快10倍 |
| 创建项目 | 1.8秒 | 0.18秒 | 快10倍 |
| 复杂查询 | 5.2秒 | 0.52秒 | 快10倍 |
mcp-perfex-crm/
├── src/
│ ├── modules/ # 业务逻辑模块
│ ├── tools/ # MCP工具实现
│ ├── types/ # TypeScript定义
│ ├── utils/ # 工具函数
│ └── connections/ # 数据库连接
├── tests/ # 测试套件
├── docs/ # 文档
└── examples/ # 使用示例
⭐ 如果这个项目帮助了您,请考虑给它一个星!
🚀 准备加速您的Perfex CRM集成?现在开始吧!