Skip to main content

CRM MCP Server: expose OTD CRM business queries to AI agents.

Project description

CRM MCP Server

把 OTD CRM 系统的业务查询能力封装成 MCP 工具,供 AI Agent(经飞书/Hermes)调用。 架构范式对齐姊妹项目 ERP-MCP:适配器模式、.env 配置、统一 Markdown 渲染、 统一错误码、+8 时区、溯源字段。

功能

提供 11 个工具 —— 8 个只读查询 + 1 个写操作 + 2 个版本管理:

工具 类型 说明
crm_query_customers 只读 按关键词 / 建档日期查客户档案
crm_query_opportunities 只读 按关键词 / 客户 / 负责人 / 金额 / 阶段查销售商机
crm_query_contracts 只读 按关键词 / 客户 / 负责人 / 是否签约查合同
crm_query_follow_ups 只读 查某关联对象(商机/客户/合同等)的跟进记录
crm_query_contacts 只读 按关键词 / 客户查联系人
crm_query_receivables 只读 按客户 / 合同 / 计划收款日期查应收款(催收用)
crm_query_invoices 只读 按客户 / 合同 / 开票状态查开票情况
crm_query_projects 只读 按关键词 / 客户 / 负责人 / 维保到期查项目
crm_create_follow_up 创建跟进记录(两步确认:先预览,再传 confirm=true 写入)
crm_check_update 只读 对比当前版本与 PyPI 最新版本,提示是否有新版
crm_self_update 升级 crm-mcp 自身(两步确认:先预览,再传 confirm=true 执行)

说明:

  • 查询结果统一渲染为 Markdown 表格,含「内部ID」列 —— 该 ID 可作为 crm_query_follow_upsrelated_id 参数,实现「查商机/客户 → 查其跟进」串联。
  • CRM 只有应收,不含应付;应付请用 ERP 系统查询。
  • crm_create_follow_up 为写操作,首次调用仅返回预览、不写入,须再次调用 并传 confirm=true 才真正创建。

安装

pip install -e ".[dev]"

配置

复制 .env.example.env 并填写 OTD CRM 凭据:

CRM_API_URL=https://app.otd-odincloud.com
CRM_TENANT_ID=        # 填了就跳过租户发现
CRM_USERNAME=your_username
CRM_PASSWORD=your_password
CRM_USER_ID=
CRM_TIMEOUT=30
CRM_VERSION_PIN=        # 填了即锁定版本:crm_check_update 只提示、crm_self_update 拒绝升级
CRM_UPDATE_INSTALLER=   # 升级方式覆盖:uv / pip,留空自动探测

用 uvx 免安装调用

发布到 PyPI 后,MCP 客户端可直接用 uvx 拉起,无需预先安装:

{
  "mcpServers": {
    "crm": {
      "command": "uvx",
      "args": ["crm-mcp"],
      "env": {
        "CRM_USERNAME": "...",
        "CRM_PASSWORD": "...",
        "CRM_TENANT_ID": "..."
      }
    }
  }
}

运行

python -m crm_mcp.server          # stdio 模式
crm-mcp                           # 同上(安装后)

用 MCP Inspector 调试:

npx @modelcontextprotocol/inspector python -m crm_mcp.server

测试

pytest -q

升级

crm-mcp --version 查看当前版本。运行中可让 Agent 自助升级:

  1. crm_check_update —— 对比当前版本与 PyPI 最新版本,返回是否有新版。
  2. crm_self_update —— 两步确认的写操作:首次调用只返回升级命令预览, 传 confirm=true 才真正执行(自动探测 uv tool / pip 安装方式, target_version 可指定版本以回滚)。
  3. 升级后当前进程仍运行旧版,需重启 MCP 客户端使新版生效。

设置 CRM_VERSION_PIN 可锁定版本:crm_check_update 只提示,crm_self_update 拒绝升级。

后端说明

CRM 后端是 ABP 框架(ASP.NET Boilerplate)应用:

  • 多租户,请求带 __tenant
  • 两步认证:租户发现(可选)+ 登录拿 JWT
  • 响应 Content-Type 常为 text/plain,body 可能是双重编码的 JSON 字符串
  • 列表查询统一 POST {pageIndex, pageSize, filter},响应 {totalCount, items}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crm_mcp-0.1.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crm_mcp-0.1.0-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file crm_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: crm_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crm_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8482a45ce0464d1bbf8aa05bd429240f8114cef6b677dbd280db6ee960518fc
MD5 8223e4871a67d677d3c77c800d8cb438
BLAKE2b-256 5ca3fb055e3e59e203c04542e46d4260db3deaa6ba87667202a9f9ae6d04e51f

See more details on using hashes here.

Provenance

The following attestation bundles were made for crm_mcp-0.1.0.tar.gz:

Publisher: release.yml on stevendingliujian-collab/CRM-MCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crm_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crm_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crm_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 017f369f2f285f1a9ab893fe82568235114b5b25d6087f3f1219d8431e0c8b50
MD5 5a6cbd99e7663af4ae6216e9da0f83d1
BLAKE2b-256 78b416d5ff95e0f64f86a78dbf5c6b0445749beee753b41785803eee95004185

See more details on using hashes here.

Provenance

The following attestation bundles were made for crm_mcp-0.1.0-py3-none-any.whl:

Publisher: release.yml on stevendingliujian-collab/CRM-MCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page