Bitrix24 CRM协议服务器

为Bitrix24 CRM提供的生产就绪模型上下文协议(MCP)服务器,支持HTTP/SSE传输,兼容Open WebUI。

  • by Ibrahim-dvp
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Ibrahim-dvp/Bitrix-MCP

使用说明

Bitrix24 MCP服务器

用于Bitrix24 CRM的生产就绪模型上下文协议(MCP)服务器,具有HTTP/SSE传输 打开WebUI 兼容性。

特性

  • ✅ 32个MCP工具 完成CRM操作
  • ✅ HTTP/SSE传输 (兼容开放式WebUI)
  • ✅ TypeScript 用于类型安全
  • ✅ 铁路部署 准备
  • ✅ REST API 与Express
  • ✅ 错误处理 详细的回复
  • ✅ 速率限制 用于Bitrix24 API
  • ✅ 自定义字段映射 (意大利税收制度支持)

可用工具

公司(6种工具)

  • bitrix_company_list -列出公司
  • bitrix_company_get -按ID获取公司
  • bitrix_company_search -按名称搜索
  • bitrix_company_create -创建公司
  • bitrix_company_update -更新公司
  • bitrix_company_delete -删除公司

联系人(6个工具)

  • bitrix_contact_list/get/search/create/update/delete

线索(6个工具)

  • bitrix_lead_list/get/search/create/update/delete

优惠(6工具)

  • bitrix_deal_list/get/search/create/update/delete

发票(7个工具)

  • bitrix_invoice_list/get/search/create/update/delete
  • bitrix_invoice_add_products -添加产品行

现场发现(1个工具)

  • bitrix_fields_get -获取实体字段架构

快速开始

1.安装

npm install

2.配置

创建 .env 文件(或复制自 .env.example):

BITRIX_BASE_URL=https://your-domain.bitrix24.com/rest/USER_ID
BITRIX_TOKEN=your_webhook_token
PORT=3000
NODE_ENV=production
ALLOWED_ORIGINS=*

3.发展

npm run dev

4.建造

npm run build

5.生产

npm start

6.测试API连通性

npm test

API终点

端点 方法 描述
/ 获取 API文档
/health GET 健康检查
/mcp/tools GET 列出所有可用工具
/mcp/tools/:toolName POST 执行工具
/mcp/sse GET SSE流用于Open WebUI

使用示例

列出工具

curl http://localhost:3000/mcp/tools

搜索公司

curl -X POST http://localhost:3000/mcp/tools/bitrix_company_search \
  -H "Content-Type: application/json" \
  -d '{"query": "Acme"}'

创建发票

curl -X POST http://localhost:3000/mcp/tools/bitrix_invoice_create \
  -H "Content-Type: application/json" \
  -d '{
    "title": "FT-2025-001",
    "companyId": 123,
    "opportunity": 1000,
    "products": [
      {"productName": "Service", "quantity": 1, "price": 1000}
    ]
  }'

打开WebUI集成

添加到打开WebUI工具配置:

{
  "name": "Bitrix24 CRM",
  "url": "https://your-railway-url.up.railway.app",
  "type": "mcp",
  "endpoints": {
    "tools": "/mcp/tools",
    "execute": "/mcp/tools",
    "sse": "/mcp/sse"
  }
}

铁路部署

选项1:从GitHub部署

  1. 将代码推送到GitHub
  2. 首选 Railway.app
  3. 点击“新建项目”→ “从GitHub部署”
  4. 选择您的存储库
  5. 添加环境变量:
    • BITRIX_BASE_URL
    • BITRIX_TOKEN
    • PORT (铁路提供此项服务)
  6. 部署!

选项2:铁路CLI

# Install Railway CLI
npm install -g @railway/cli

# Login
railway login

# Initialize project
railway init

# Add environment variables
railway variables set BITRIX_BASE_URL=https://...
railway variables set BITRIX_TOKEN=...

# Deploy
railway up

您的服务器将在以下位置可用: https://[your-project].up.railway.app

项目结构

bitrix-mcp-server-railway/
├── src/
│   ├── config/           # Configuration management
│   │   └── index.ts      # Config & constants
│   ├── lib/              # Core libraries
│   │   └── bitrix-api.ts # Bitrix24 API client
│   ├── tools/            # MCP tools
│   │   ├── company.ts    # Company CRUD
│   │   ├── contact.ts    # Contact CRUD
│   │   ├── lead.ts       # Lead CRUD
│   │   ├── deal.ts       # Deal CRUD
│   │   ├── invoice.ts    # Invoice CRUD
│   │   ├── fields.ts     # Field discovery
│   │   └── index.ts      # Tool exports
│   ├── types/            # TypeScript types
│   │   └── index.ts      # Type definitions
│   ├── server.ts         # HTTP/SSE server
│   ├── index.ts          # Entry point
│   └── test.ts           # Connectivity test
├── dist/                 # Compiled JavaScript
├── .env                  # Environment variables
├── .gitignore           # Git ignore rules
├── tsconfig.json        # TypeScript config
├── package.json         # Dependencies
├── Procfile             # Railway process config
├── railway.json         # Railway deployment config
└── README.md            # This file

自定义字段

此服务器包括意大利税务系统字段的映射:

  • vat_number → UF_CRM_1708520927917 (第四部分)
  • tax_code → UF_CRM_1708520972166 (税务编码)
  • pec → UF_CRM_1708521855072 (PEC电子邮件)
  • sdi_code → UF_CRM_1708523044307 (SDI代码)

错误处理

所有回复均遵循以下格式:

成功:

{
  "success": true,
  "data": {},
  "message": "Operation successful"
}

错误:

{
  "success": false,
  "error": "Error message",
  "details": {}
}

发展

TypeScript编译

npm run build

观看模式

npm run dev

类型检查

tsc --noEmit

环境变量

变量 描述 必填 默认
BITRIX_BASE_URL Bitrix24 webhook URL 是 -
BITRIX_TOKEN Webhook令牌 是 -
PORT 服务器端口 否 3000
NODE_ENV 环境 否 开发
ALLOWED_ORIGINS CORS来源 否 *

许可证

麻省理工学院

支持

对于问题和功能请求,请在GitHub存储库中创建问题。