Skip to main content
Glama
CRM MCP Server

CRM MCP Server

README.md
# CRM MCP Server

Connect **Claude, ChatGPT, Cursor or any MCP client** to a CRM database, so you can ask questions and get work done in plain English:

> *"Which customers haven't ordered in 60 days and are worth more than $5,000? Add a note to each and create a call task for Friday."*

The assistant finds the customers, reads their history, writes the notes and creates the tasks through this server. Every step is validated, permission-checked and logged.

This is a working reference build: the same pattern connects an AI assistant to HubSpot, Salesforce, Postgres / Supabase or your own REST API.

---

## What it does

| Tool | Type | What it's for |
|---|---|---|
| `search_customers` | read | Find customers by name, company or email; filter by status and segment |
| `get_customer_summary` | read | Profile, lifetime value, recent orders, notes and open tasks for one customer |
| `list_inactive_customers` | read | Customers with no order in N days, most valuable first (churn / win-back list) |
| `sales_report` | read | Revenue, orders, top customers, by product and by segment for the last N days |
| `add_note` | write | Add a note to a customer (never edits or deletes existing notes) |
| `create_followup_task` | write | Create a dated follow-up task |
| `update_customer_status` | write | Move a customer between lead / active / at_risk / churned |

## Built to be safe with real business data

- **Validated input.** Every argument has a type, range and length limit; bad input is rejected before it reaches the database.
- **No raw SQL, no deletes.** The AI can only do what the tools allow. Queries are parameterized, so injection attempts are treated as plain text (there is a test for this).
- **Read-only mode.** `CRM_READ_ONLY=true` removes the write tools entirely, ideal for a first rollout.
- **Write tools are labelled.** MCP annotations mark read vs. write vs. destructive tools, so clients like Claude can ask the user before changing anything.
- **Audit log.** Every call is written to `data/audit.jsonl`: time, tool, arguments, success, duration.
- **API-key auth for the remote server.** `/mcp` requires `Authorization: Bearer <key>` (constant-time check); `/health` stays open for uptime monitors.
- **Tested.** 17 tests run each tool through a real MCP client, in memory and over HTTP.

## Quick start (5 minutes)

```bash
git clone https://github.com/projectsdealnepal/crm-mcp-server.git
cd crm-mcp-server
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
crm-mcp-seed          # loads 60 sample customers, ~380 orders, notes and tasks
pytest -q             # 17 passed
```

### Use it in Claude Desktop

1. Copy `claude_desktop_config.example.json` into Claude Desktop's config
   (Settings → Developer → Edit Config), replacing the `/ABSOLUTE/PATH/TO/` parts.
2. Restart Claude Desktop. The **crm** tools appear in the tools menu.
3. Ask: *"Give me a sales report for the last 30 days."*

The same `command` + `env` block works in Cursor, Claude Code and other MCP clients.

### Run it as a remote server

```bash
export CRM_API_KEY=$(python -c "import secrets; print(secrets.token_urlsafe(32))")
crm-mcp --http                       # serves http://0.0.0.0:8000/mcp
curl localhost:8000/health           # {"status":"ok","read_only":false}
```

Or with Docker:

```bash
docker build -t crm-mcp .
docker run -p 8000:8000 -e CRM_API_KEY=... -v crm-data:/data crm-mcp
```

Deploy the container anywhere that runs Docker (AWS ECS / App Runner, Fly.io, Render, a VPS) behind HTTPS, then add the URL and key as a custom connector in your AI client.

## Try these prompts

- "Which customers haven't ordered in 60 days? Show the most valuable first."
- "Summarize everything about the top customer on that list."
- "Give me a sales report for the last 90 days, by segment."
- "Add a note to customer 12: sent a 20% win-back offer. Then create a call task for next Friday."
- "Mark every churned customer worth more than $10k as at_risk so sales can try to win them back."

## Project layout

```
crm_mcp/
  server.py     tools, validation, annotations, read-only mode
  audit.py      JSONL audit log for every tool call
  db.py         schema + SQLite connection (standard SQL, Postgres-ready)
  seed.py       deterministic demo data
  config.py     settings from environment variables
  __main__.py   stdio or HTTP (API-key auth, /health)
tests/          in-memory and HTTP end-to-end tests
```

## Adapting it to your system

Replace the queries in `server.py` with calls to your CRM's API or your own database, keep the same tool names and validation, and you have an assistant that works on your real data. Typical adaptations: HubSpot / Salesforce / Zoho, Postgres / Supabase, Shopify, an internal REST API, OAuth with per-user permissions.

---

Built by **Anand Gachhadar**, AI agent & LLM engineer (Python, AWS, Claude / OpenAI). Need an MCP server for your own system? Find me on Upwork.

MIT licensed.

TDQS

A3.6/5.0

Scored across 7 tools

Disambiguation5/5

Each tool has a distinct role: search for discovery, summary for full detail, inactive list for churn targeting, and sales_report for aggregate analysis. The mutation tools (add_note, create_followup_task, update_customer_status) are also clearly separated by action and object. There is little risk of an agent misselecting among these seven tools.

Naming Consistency4/5

Most names follow a predictable verb_noun snake_case pattern (search_customers, get_customer_summary, list_inactive_customers, add_note, create_followup_task, update_customer_status). sales_report is the main deviation, using a noun phrase without a verb, though it remains readable and consistent in casing style.

Tool Count5/5

Seven tools is well-scoped for a focused CRM server, with each tool covering a recognizable workflow: lookup, detail, churn detection, reporting, notes, tasks, and status updates. None feel redundant or extraneous.

Completeness3/5

The surface covers read/search, reporting, notes, tasks, and status changes, but notable CRM operations are missing: creating a customer, updating customer profile fields, and managing or closing follow-up tasks. Agents can still handle core workflows but will hit gaps for full customer lifecycle management.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues