A small made-up product, "Acme Orders", with Standard Support added. About 1,200 lines of TypeScript with no framework, meant to be read and copied from.
| File | What's in it |
|---|---|
store.ts |
Feedback, tickets and the rules: ownership, limits, idempotency, scrubbing, the watch data |
schemas.ts |
What each operation takes, once, for the MCP tools and the HTTP endpoints alike |
tools.ts |
The two MCP tools (support, support_send) and the wording agents read |
help.ts |
A stand-in for answering a question from your documentation |
server.ts |
/mcp, the same operations as HTTP endpoints, the watch URL, the team's endpoints |
watch.sh |
The background watcher an agent runs to hear about a reply |
support.test.ts |
Tests that use the server as an agent, a watcher and the team would |
measure.ts |
Prints the size of each support tool's definition: npm run measure |
wording.test.ts |
Fails when the skill's wording and this server's tool descriptions drift apart |
It needs Node 24, which runs TypeScript files directly, so there is no build step.
npm install
npm start # http://localhost:8787/mcp
npm test
npm run typecheckSign-in is a fixed table of demo tokens: demo-token-alice and demo-token-bob for customers, demo-team-key for
the team. Everything is kept in memory.
Connect an MCP client to http://localhost:8787/mcp with the header Authorization: Bearer demo-token-alice, and
ask the agent to look up order 999. The lookup fails with a request ID and a line pointing at support with action help,
whose answer says that order numbers start at 1000, so this one isn't a bug. Ask for order 1002 and it fails the
same way, the documentation says that's a problem on Acme's side, and the agent offers to open a ticket.
Or use the HTTP endpoints:
# The customer's agent opens a ticket
curl -s localhost:8787/support/tickets \
-H 'Authorization: Bearer demo-token-alice' -H 'Content-Type: application/json' \
-d '{"kind":"bug","title":"lookup_order fails for order 999","description":"It says the order could not be loaded.","request_ids":["req_123"]}'
# ...and waits for a reply in the background
./watch.sh http://localhost:8787/support/watch/w_...
# The team replies
curl -s localhost:8787/team/tickets/tkt_.../replies \
-H 'Authorization: Bearer demo-team-key' -H 'Content-Type: application/json' \
-d '{"body":"Fixed, please try again.","status":"resolved","resolution":"fixed"}'watch.sh polls once a minute, so it prints within a minute of the reply.
- Real sign-in. Replace
accountFromTokeninserver.tswith your own. - A database.
SupportStorekeeps Maps in memory. - Email to the user when the team replies. Send it from wherever
teamReplyis called. - Long polling on the watch URL. This server answers at once and says
"long_poll": false. Only add it on a server built to hold many idle connections. - A support inbox. The
/teamendpoints stand in for your admin page or helpdesk:GET /team/feedback,POST /team/feedback/{id}/promote(turns feedback into a ticket),GET /team/ticketsandPOST /team/tickets/{id}/replies.