mcp-ticketing-server

mcp-ticketing-server

MCP server for ticketing automation that exposes tools to create, search, and update IT helpdesk tickets, with metrics tracking.

Category
访问服务器

README

MCP Tool Server for Ticketing Automation

A local, fully free demonstration of the Model Context Protocol (MCP) — a Python-based MCP server exposing IT helpdesk ticketing operations as tools, connected to Claude Code as a real agentic client.

What this demonstrates

  • Building an MCP server from scratch using Anthropic's official Python SDK
  • Wrapping domain logic (a ticketing system) as MCP tools with clean schemas
  • Connecting a real AI agent (Claude Code) as an MCP client and observing genuine tool-selection reasoning, not scripted calls
  • Instrumenting tool calls with success/failure and latency metrics
  • Debugging a real Python decorator/introspection bug end-to-end

Architecture

Natural language request
        │
        ▼
   Claude Code (MCP client)
        │  stdio / JSON-RPC
        ▼
   server.py (MCP server, FastMCP)
        │
        ▼
   database.py (SQLite: tickets.db)
        │
        ├── tickets table        (ticket data)
        └── tool_calls_log table (success/failure + latency per call)

Tools exposed

Tool Description
create_ticket_tool(title, description) Creates a new ticket, status defaults to open
search_tickets_tool(keyword, status) Searches tickets by keyword and/or status
update_status_tool(ticket_id, new_status) Updates a ticket's status

Tech stack (100% free, no API costs)

  • Python 3.10 — implementation language
  • Anthropic MCP Python SDK (mcp[cli], pinned to <2.0.0) — open-source protocol implementation
  • SQLite (Python standard library) — local, file-based data store
  • MCP Inspector — official browser-based tool for manual testing/debugging of the server in isolation from any AI client
  • Claude Code — free agentic client (uses existing claude.ai login, not the metered API) that reasons over the exposed tools and decides when to call them

No cloud hosting, no Docker, no paid API keys. Runs entirely on a local machine.

Metrics

Every tool call is wrapped in a track_metrics decorator that records success/failure and latency (ms) into a tool_calls_log table. A separate script, check_metrics.py, aggregates this into a summary report:

Total tool calls: 7
Successful: 7
Success rate: 100.0%
Average latency: 9.68 ms

Per-tool breakdown:
  create_ticket_tool: 3 calls, 100.0% success, 13.03 ms avg latency
  search_tickets_tool: 3 calls, 100.0% success, 3.16 ms avg latency
  update_status_tool: 1 calls, 100.0% success, 19.21 ms avg latency

Note: this measures tool execution latency (time inside the Python function), not full end-to-end request latency through the MCP protocol and model reasoning.

Design decisions worth explaining

  • Business logic separated from protocol layer: database.py (pure functions, tested standalone first) is independent of server.py (the MCP wrapper). Bugs in one layer can't be confused with bugs in the other.
  • SQLite over Postgres/MySQL: zero setup, file-based, appropriate for a single-user demo. A real multi-user production system would need Postgres for concurrent write support.
  • Parameterized SQL queries (? placeholders) used throughout to prevent SQL injection.
  • Operational data (tool_calls_log) kept separate from domain data (tickets) — a real pattern for separating observability data from business data.
  • Explicit, detailed tool docstrings — these are what the AI client actually reads to decide when/how to use each tool; vague docstrings measurably degrade tool-selection accuracy.

A real bug I hit and fixed

Wrapping tools in a metrics-tracking decorator broke the MCP SDK's ability to read each tool's real parameter list — the Inspector started showing generic args/kwargs fields instead of title/description. Cause: a hand-written decorator hides the original function's signature from introspection tools (like the inspect module the MCP SDK uses to build tool schemas), even if you manually copy over __name__ and __doc__. Fixed using Python's standard functools.wraps, which preserves the full signature, not just the name and docstring.

How to run it

# 1. Activate the virtual environment
.\venv\Scripts\Activate.ps1

# 2. (Optional) Test the server in isolation
mcp dev server.py

# 3. Register with Claude Code (one-time)
claude mcp add ticketing-server -- python server.py

# 4. Launch Claude Code from the project folder and just talk to it
claude
> Create a ticket for a broken projector in the main conference room, then search for tickets related to the projector to confirm it was created.

# 5. Check aggregated metrics
python check_metrics.py

What I'd add with more time

  • Deduplication logic for near-identical tickets
  • A fourth tool (e.g. delete_ticket or assign_ticket) to test more complex multi-step agent chains
  • Postgres backend for concurrent access
  • Containerizing the server (Docker) for a more "enterprise deployment" story
  • HTTP/SSE transport instead of stdio, to demonstrate a remote (not just local) MCP server

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选