Skip to content

feat: tickets tools — list, get, stats - #149

Open
ar2rsawseen wants to merge 3 commits into
mainfrom
feat/tickets-rag-search
Open

feat: tickets tools — list, get, stats#149
ar2rsawseen wants to merge 3 commits into
mainfrom
feat/tickets-rag-search

Conversation

@ar2rsawseen

@ar2rsawseen ar2rsawseen commented Jul 24, 2026

Copy link
Copy Markdown
Member

What

Adds the support-tickets tool set to the MCP server: a new plugin-gated tickets category (requiresPlugin: 'tickets', not available by default), all read-only, so MCP clients (Cee, Claude, etc.) can answer structured support questions.

  • tickets_list — full GET /v2/tickets filter surface: status/category, assignee, unassigned, team, tag, channel, priority, exact requester (email/uid/device), requester_name substring (e.g. "BMW"), audience segments ({"custom.organization": "BMW"}), subject/number search, updated_since, sort + paging. Assignee and team ids are resolved to display names via /v2/members and /v2/tickets/teams, so "who is answering BMW's latest ticket" returns a person, not an ObjectId. requester_name is also re-applied client-side so older servers that ignore the parameter don't silently return unfiltered results.
  • tickets_get — one ticket by its globally unique number: detail, tags, SLA breach state, CSAT, and optionally the conversation transcript.
  • tickets_stats/v2/tickets/stats: volume + daily series, backlog, first-response/resolution p50/p90, SLA attainment, agent leaderboard, busiest hours, CSAT.

The requester_name server-side filter ships in countly-platform#874.

Note: an earlier revision of this PR also added tickets_rag_search (semantic search over vectorized ticket transcripts). Ticket vectorization has since moved out of the tickets plugin into a dedicated plugin, so that tool was removed here and will be re-added by whichever plugin ends up owning vectorization.

Validation

  • Suite: 886 passing (7 tickets tool tests: filter/param mapping, assignee-name resolution, client-side requester_name fallback, segments serialization, transcript formatting, empty/missing/error paths).
  • All three tools verified live against a dev Countly: tickets_list {requester_name: "jane", sort: "created_at", direction: "desc", limit: 1} → "assignee: Arturs Sosins"; tickets_get renders the conversation; tickets_stats returns the metrics blob.

🤖 Generated with Claude Code

Adds the first tickets-plugin tool: tickets_rag_search calls the
tickets plugin's GET /v2/tickets/rag/search endpoint to retrieve
PII-redacted, permission-scoped transcript snippets for a natural-
language query, so MCP clients can ground answers in how similar
customer issues were resolved.

- optional app_id/app_name scoping (cross-app when omitted), limit
- gated as a new 'tickets' category (requiresPlugin: tickets, not
  available by default), read-only
- unit tests for param mapping, scoping, empty results, API errors;
  also verified live against a dev server with RAG enabled

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…tats

Complements tickets_rag_search with the structured query side, so MCP
clients can answer questions like "who is answering BMW's latest
ticket" (requester_name/segments filter + sort + limit=1):

- tickets_list: full /v2/tickets filter surface (status, assignee,
  team, tag, channel, priority, requester, requester_name substring,
  audience segments, subject/number search, updated_since, sort,
  paging). Assignee and team ids are resolved to names via /v2/members
  and /v2/tickets/teams. requester_name is re-applied client-side so
  older servers without the filter don't silently return everything.
- tickets_get: one ticket by (globally unique) number — detail, SLA,
  CSAT, and optionally the conversation transcript.
- tickets_stats: /v2/tickets/stats performance metrics (volume,
  backlog, FRT/resolution percentiles, SLA attainment, agent
  leaderboard, CSAT).

All read-only in the plugin-gated tickets category. 893 tests passing;
verified live against a dev server (names resolve, transcript renders).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ar2rsawseen ar2rsawseen changed the title feat: tickets_rag_search — semantic search over support tickets feat: tickets tools — list/get/stats + RAG semantic search Jul 24, 2026
Comment thread src/tools/tickets.ts
Comment on lines +12 to +13
return String(text || '')
.replace(/&amp;/g, '&')
…d plugin

Ticket vectorization is no longer owned by the tickets plugin, so the
RAG search tool goes with it. The structured tools (tickets_list,
tickets_get, tickets_stats) are unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ar2rsawseen ar2rsawseen changed the title feat: tickets tools — list/get/stats + RAG semantic search feat: tickets tools — list, get, stats Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants