support-ticket-mcp
Enables natural language querying and semantic search over a bilingual customer support ticket dataset using SQL and embeddings.
README
Customer Support Ticket MCP Server
An MCP server that lets you ask natural-language questions about the Tobi-Bueck/customer-support-tickets dataset (bilingual EN/DE support tickets) and get accurate answers — through Claude Code or Codex, locally.
How it works (thin server, host does the reasoning)
The dataset is a mix of categorical fields (type, queue, priority, language, tags) and free text (subject, body, answer). Those need different tools:
| Question type | Example | Tool |
|---|---|---|
| Counts / aggregates | "How many tickets per queue?" | query_tickets (SQL → DuckDB) |
| Group-bys / breakdowns | "Breakdown by priority and language?" | query_tickets |
| Most common tags | "What are the top ticket tags?" | query_tickets (UNION tag_1..tag_8) |
| Themes / paraphrase | "What are customers saying about billing?" | search_tickets (embeddings) |
| See the data shape | (first call, always) | get_schema |
The MCP host (Claude Code / Codex) is the chat interface and the LLM. It reads the schema, writes the SQL itself, and picks which tool to call. This server stays a thin, safe data layer — so the SQL tools need no API key.
You ─▶ Claude Code (writes SQL, routes) ─stdio─▶ this server ─▶ DuckDB + vector index
Tools
get_schema()— columns, types, sample values for categoricals, null counts, usage notes. Call first.query_tickets(sql)— runs a read-onlySELECTon theticketstable (columns: subject, body, answer, type, queue, priority, language, version, tag_1..tag_8, tags_all). Guards: single statement, SELECT/WITH only, no DDL/DML, SQL results capped at 500 rows, errors returned to the model for self-correction.search_tickets(query, k=5)— semantic search over subject+body via OpenAI embeddings (EN/DE). Returns up tokresults (capped at 20), filtered by a relevance floor so off-topic queries return nothing. NeedsOPENAI_API_KEY.
Requirements
- Python 3.10+
- Packages in
requirements.txt(mcp[cli],duckdb,pandas,numpy,openai,python-dotenv)
Setup
git clone <your-repo-url>
cd support-ticket-mcp
# create a virtualenv (optional but recommended)
python -m venv .venv
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\Activate.ps1 # Windows PowerShell
# .venv\Scripts\activate.bat # Windows cmd
pip install -r requirements.txt
# 1) Download the dataset -> data/tickets.csv
python download_data.py
# 2) Only needed for semantic search: add your OpenAI key
cp .env.example .env # Windows: copy .env.example .env — then edit it
# 3) (recommended) prebuild the embedding index so the first search is instant
# — otherwise it builds lazily on the first search_tickets call:
python -m support_mcp.build_index
Environment variables
| Variable | Required | Purpose |
|---|---|---|
OPENAI_API_KEY |
only for search_tickets |
embeddings for semantic search |
OPENAI_EMBED_MODEL |
no | embedding model, defaults to text-embedding-3-small |
SEARCH_MIN_SIMILARITY |
no | relevance floor for search (0–1), defaults to 0.30 |
TICKETS_CSV |
no | point the server at a custom CSV path |
(The download source is set in download_data.py; override it with a
DATASET_URL environment variable when running that script if needed.)
Run it standalone (sanity check)
python support_mcp/server.py # starts on stdio; Ctrl-C to stop
Optionally inspect the tools without an LLM using the MCP Inspector (an official local debug UI for MCP servers):
npx @modelcontextprotocol/inspector python support_mcp/server.py
Connect to Claude Code
From the project directory, register the server (this is the form that works —
note the -- before the command):
claude mcp add support-tickets -- python support_mcp/server.py
Then launch the interface and start asking:
claude
If the server can't find its packages, your virtualenv may not be active when
Claude Code launches it — point the command at the venv's Python directly, e.g.
.../.venv/bin/python support_mcp/server.py (or ...\.venv\Scripts\python.exe on Windows).
Connect to Codex
The server is host-agnostic. It was developed and tested with Claude Code; to use
it from Codex, add it to ~/.codex/config.toml with its standard MCP config and
run codex from the project directory:
[mcp_servers.support-tickets]
command = "python"
args = ["support_mcp/server.py"]
cwd = "/absolute/path/to/support-ticket-mcp"
env = { OPENAI_API_KEY = "sk-..." }
Example questions to try
- "How many tickets are there per queue?"
- "What's the breakdown by priority?"
- "Show the split between English and German tickets."
- "What are the 10 most common tags?"
- "How many tickets are type Incident with high priority?"
- "Find tickets about login or VPN problems." (uses search_tickets)
Notes / data quirks handled on load
priorityis normalized to lowercase (low/medium/high) for predictable filters.- The dataset is bilingual (en/de) —
languagelets you filter or split by it. body= the customer's message text,answer= the reply/response to the ticket.- Tags span
tag_1..tag_8(often NULL); atags_allcolumn joins them for easyLIKEfilters.
Safety & observability
- Engine-level sandbox: DuckDB runs with
enable_external_access=false, so queries cannot read files or the network. - Query guards: single statement, SELECT/WITH only, DDL/DML blocked (string literals stripped before scanning, so text like
'%set up%'is fine), 500-row cap. - Audit log + stderr logging: every executed query is appended as a JSON line to
data/query_audit.log(timestamp, SQL, outcome, row count); tool calls are also logged to stderr, which the host displays.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。