AI Sales MCP Server

AI Sales MCP Server

Enables AI assistants to query ERP sales data, including employees, sales, customers, and top products, through MCP tools.

Category
访问服务器

README

AI Sales MCP Server

Exposes ERP data to Cursor / Claude via MCP.

How it works (3 files)

settings.py   →  reads .env (backend URL, API key, user id)
erp_api.py    →  get_erp_data("/sales") calls Express
server.py     →  @mcp.tool functions + mcp.run()
Cursor / Claude  →  server.py (tool)  →  erp_api.py  →  Express  →  Postgres

Start the whole system

MCP talks to the Express backend. Start backend (and DB) first, then MCP.

1. Backend + database

# From repo root — ensure Postgres is running and DATABASE_URL is set
cd backend
cp ../.env.example ../.env   # or use backend/.env
npm install
npx prisma migrate deploy
npx tsx prisma/seed.ts
npm run dev

Backend: http://localhost:4000

2. MCP server deps + env

cd mcp_server
uv sync
cp .env.example .env

Edit .env (see Environment variables below), then use one of the run modes in the sections that follow.


Environment variables

Copy from .env.example:

BACKEND_URL=http://localhost:4000
INTERNAL_API_KEY=dev-internal-key-change-me
MCP_ACTING_USER_ID=
MCP_TRANSPORT=stdio
Variable Required Where to get the value
BACKEND_URL Yes Express server URL. Local default: http://localhost:4000 (see backend/README.md). Use your deployed API URL for remote backends.
INTERNAL_API_KEY Yes Must match the backend’s INTERNAL_API_KEY. Local default in backend/.env / root .env.example: dev-internal-key-change-me. Sent as X-Internal-Key.
MCP_ACTING_USER_ID Yes ERP user id (cuid) used for RBAC. Get it after seeding: login as admin@acme.com / Password123!, or query Postgres User table (SELECT id, email FROM "User";). Seed logins are in backend/README.md. Sent as X-Acting-User-Id.
MCP_TRANSPORT No Documented default is stdio (Cursor / Claude Desktop). For HTTP remote mode use the fastmcp run --transport http command below.

Example after seeding (id will differ on your machine):

MCP_ACTING_USER_ID=cmrxavwxt008quumiiag90vui   # e.g. admin@acme.com

Inspect / develop with FastMCP

Inspect tools (CLI summary)

cd mcp_server
uv run fastmcp inspect server.py

JSON report:

uv run fastmcp inspect server.py --format mcp
# or write to a file:
uv run fastmcp inspect server.py --format mcp -o inspect.json

MCP Inspector (interactive UI)

Starts the server with the MCP Inspector for trying tools in the browser:

cd mcp_server
uv run fastmcp dev inspector server.py

Optional ports:

uv run fastmcp dev inspector server.py --ui-port 6274 --server-port 6277

Ensure .env is filled and the Express backend is running before calling tools.

Run stdio locally (manual)

uv run python server.py
# or
uv run fastmcp run server.py --transport stdio

Local setup — Claude Desktop

Install this server into Claude Desktop (writes Claude’s MCP config):

cd mcp_server
uv run fastmcp install claude-desktop server.py \
  --name ai-sales-erp \
  --env-file .env

Or pass env vars explicitly:

uv run fastmcp install claude-desktop server.py \
  --name ai-sales-erp \
  --env BACKEND_URL=http://localhost:4000 \
  --env INTERNAL_API_KEY=dev-internal-key-change-me \
  --env MCP_ACTING_USER_ID=YOUR_USER_ID

Then restart Claude Desktop. Claude launches the MCP process via stdio; keep the Express backend running on BACKEND_URL.

Config file (macOS): ~/Library/Application Support/Claude/claude_desktop_config.json


Local setup — Cursor

Option A — FastMCP install

cd mcp_server
uv run fastmcp install cursor server.py \
  --name ai-sales-erp \
  --env-file .env

Option B — Manual mcp.json

{
  "mcpServers": {
    "ai-sales-erp": {
      "command": "/Users/pratik/Work/ai-sales/mcp_server/.venv/bin/python",
      "args": ["server.py"],
      "cwd": "/Users/pratik/Work/ai-sales/mcp_server",
      "env": {
        "BACKEND_URL": "http://localhost:4000",
        "INTERNAL_API_KEY": "dev-internal-key-change-me",
        "MCP_ACTING_USER_ID": "YOUR_USER_ID"
      }
    }
  }
}

Update paths for your machine. Restart Cursor / reload MCP after changes.


Remote setup (HTTP)

Local Claude/Cursor installs use stdio (client spawns server.py). For a remote MCP, run the server as an HTTP process and point clients at its URL.

1. Start MCP over HTTP

cd mcp_server
# Backend must be reachable from this host (set BACKEND_URL in .env)
uv run fastmcp run server.py --transport http --host 0.0.0.0 --port 8000

Default path is /mcp/, so the endpoint is:

http://<host>:8000/mcp/

Use your public hostname / reverse proxy URL in production.

2. Connect Claude Desktop to remote HTTP

Claude Desktop’s config file prefers stdio. Bridge HTTP with mcp-remote:

{
  "mcpServers": {
    "ai-sales-erp": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "http://YOUR_HOST:8000/mcp/"]
    }
  }
}

Or add a custom connector in Claude: Settings → Connectors → Add custom connector → paste https://YOUR_HOST/mcp/ (for internet-reachable servers; OAuth if required).

3. Connect Cursor to remote HTTP

In Cursor MCP settings / mcp.json, use a URL entry (Streamable HTTP):

{
  "mcpServers": {
    "ai-sales-erp": {
      "url": "http://YOUR_HOST:8000/mcp/"
    }
  }
}

If your Cursor build only supports stdio, use the same npx mcp-remote ... bridge as Claude Desktop.

4. Quick check against a remote server

uv run fastmcp list http://YOUR_HOST:8000/mcp/
uv run fastmcp inspect http://YOUR_HOST:8000/mcp/

Tools (all in server.py)

Tool What it does
search_employees Find employees
list_sales List sales with filters
search_customers Find customers
get_dashboard Dashboard metrics
top_customers Top customers by revenue
top_products Top products by revenue

Add a new tool

Open server.py and copy this pattern:

@mcp.tool
async def my_new_tool(name: str) -> str:
    """Short description for the AI."""
    data = await get_erp_data("/some/path", {"search": name})
    return to_json(data)

Restart the MCP client (or reload MCP) so it picks up the new tool.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选