TicketAI

TicketAI

Enables AI assistants to analyze IT support tickets, categorize urgency, suggest responses, and retrieve statistics via MCP tools.

Category
访问服务器

README

TicketAI

A small AI-powered triage tool for IT support tickets. You give it a subject and description, and it uses the Claude API to work out what category the issue falls into, how urgent it is, a one-line summary, a suggested first response, and which team should pick it up.

I built this to get real, hands-on experience with the Claude API and with MCP (Model Context Protocol), rather than just reading about them. It's small on purpose — the goal was to go end to end on something real: prompt design, API integration, persistence, a REST interface, and an MCP interface that lets an AI assistant call the same logic as a tool.

What it does

Send it a ticket like:

Subject: Can't connect to VPN Description: VPN client fails to connect since this morning, blocking remote work.

And it comes back with:

{
  "category": "Network",
  "urgency": "High",
  "summary": "User unable to establish VPN connection, blocking remote work.",
  "suggested_response": "Thanks for flagging this — we're looking into your VPN connection now and will update you shortly.",
  "suggested_assignee_group": "Network Ops"
}

That result gets saved, so you can also ask for stats like "how many Network tickets came in, and what's the average urgency."

Two ways to use it

There are two interfaces on top of the same core logic:

  1. A REST API (FastAPI) — the kind of thing you'd wire into a ticket intake form or another system.
  2. An MCP server — this is the part I was most interested in. It exposes the exact same triage logic as tools that an AI assistant (Claude Desktop, Claude Code) can call directly during a conversation. So instead of copy-pasting a ticket into a chat window, you can just say "analyze this ticket" and the assistant calls the tool itself.

Both talk to the same SQLite database, so a ticket analyzed through the API shows up in the MCP stats tool too, and vice versa.

How it's put together

                    ┌───────────────────┐
                    │   Your input       │
                    │ (ticket subject +  │
                    │   description)     │
                    └─────────┬─────────┘
                              │
              ┌───────────────┴────────────────┐
              │                                 │
              ▼                                 ▼
   ┌─────────────────────┐         ┌──────────────────────┐
   │   FastAPI service     │         │    MCP server          │
   │   app/main.py          │         │  mcp_server/server.py  │
   │                       │         │                        │
   │ POST /tickets/analyze │         │  analyze_ticket_tool   │
   │ GET  /tickets/stats   │         │  get_ticket_tool       │
   │ GET  /healthz         │         │  get_category_stats    │
   └───────────┬───────────┘         └───────────┬────────────┘
               │                                  │
               └────────────────┬─────────────────┘
                                 ▼
                    ┌─────────────────────────┐
                    │  app/claude_client.py     │
                    │  - builds the prompt      │
                    │  - calls the Claude API   │
                    │  - parses + validates the │
                    │    JSON it returns        │
                    └────────────┬───────────────┘
                                 ▼
                    ┌─────────────────────────┐
                    │    app/storage.py         │
                    │  SQLite: tickets table    │
                    └─────────────────────────┘

The FastAPI app and the MCP server are both thin wrappers. Neither one contains any triage logic itself — they just call into app/claude_client.py and app/storage.py, which is where the actual work happens. I did it this way so the two interfaces can never drift out of sync with each other, and so I could test the triage logic once instead of twice.

Getting it running

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # then paste in your own ANTHROPIC_API_KEY

Running the REST API

export ANTHROPIC_API_KEY=sk-ant-...
uvicorn app.main:app --reload

Then, in another terminal:

curl -X POST http://localhost:8000/tickets/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Cannot connect to VPN",
    "description": "VPN client fails to connect since this morning, blocking remote work.",
    "requester": "jane@example.com"
  }'

curl http://localhost:8000/tickets/stats

FastAPI also gives you interactive docs for free at http://localhost:8000/docs, which is a fast way to poke at the endpoints without curl.

Running the MCP server

export ANTHROPIC_API_KEY=sk-ant-...
python -m mcp_server.server

To actually connect it to Claude Desktop, add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "ticketai": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "cwd": "/absolute/path/to/ticketai",
      "env": { "ANTHROPIC_API_KEY": "sk-ant-..." }
    }
  }
}

Restart Claude Desktop, and you should be able to ask it things like "use ticketai to analyze this ticket: [paste text]" or "what does the ticketai category breakdown look like right now."

Running the tests

The Claude API call is mocked throughout the test suite, so you can run everything without an API key or network access:

pytest -v

24 tests, covering the storage layer, the Claude client's JSON parsing and error handling, all three REST endpoints (including the error paths), and all three MCP tools.

Decisions I made, and why

Structured output via prompting, not the tool-use API. I told Claude in the system prompt exactly which JSON keys to return and gave it a closed list of allowed values for category, urgency, and assignee group. I considered using the Anthropic API's formal tool-use/function-calling feature instead, but for something this size, a well-constrained prompt plus a parser was simpler to reason about and debug.

One shared core, two thin interfaces. claude_client.py and storage.py don't know FastAPI or MCP exist. That was a deliberate choice so I could test the actual triage logic in isolation, and so adding a third interface later (a Slack bot, say) wouldn't mean duplicating anything.

SQLite, not a real database server. For a project this size, running Postgres would be pure overhead. SQLite gives both interfaces a shared, persistent store with zero setup.

What I'd change if this went further than a portfolio project

I want to be upfront about the corners I cut, since none of them are things I'd leave alone in production:

  • The MCP server only runs over stdio, which means it's local-only. A team-wide deployment would need the HTTP/SSE transport instead.
  • There's no auth on any of it. Anyone who can run the process can call the tools and rack up API cost. Fine for a demo on my own machine, not fine for anything shared.
  • The category/urgency/assignee-group taxonomy is one I made up, not one pulled from a real ITSM tool. In a real deployment I'd want it mapped to whatever categories the actual ticketing system uses.
  • No schema migrations. init_db() just does CREATE TABLE IF NOT EXISTS, so if I ever changed the schema, an existing tickets.db would need to be manually handled. I've used Alembic for exactly this in a previous role — just didn't feel worth pulling in for a single-table project.

Repo history

This was built branch-by-branch rather than as one commit dump — feature/claude-clientfeature/storagefeature/fastapi-servicefeature/mcp-serverfeature/testsfeature/docs, each merged into main once it worked. If you look at the git log you'll see that shape.

推荐服务器

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

官方
精选