# Install canhelpto support in an MCP server

Instructions for a coding agent (Claude Code, Cursor, Codex). A person starts it with one prompt:

> Add canhelpto support to this MCP server, following https://canhelpto.com/install.md

Result: the server gains three tools (`support_ask`, `support_open_ticket`, `support_ticket_status`), every tool error tells the agent where to turn, and a ticket from a user arrives in the vendor's canhelpto inbox with the account, the client and the last tool calls attached.

## 0. Ask the person for the key

The person creates a workspace at https://canhelpto.com/login?utm_source=install and copies the **service key** from Dashboard, Settings, Service key (it starts with `chs_`). Store it as the environment variable `CANHELPTO_API_KEY`. Never commit it and never put it in client-side code.

## 1. Find the server

Locate where the MCP server object is created (`new McpServer(...)` in TypeScript, `FastMCP(...)` / `Server(...)` in Python) and where its tools are registered. Find how the server knows the calling user: an auth middleware, `extra.authInfo`, a session, a token lookup. That lookup becomes the `user` function below. If the server has no notion of a user, ask the person how a caller is identified before going on.

## 2. TypeScript (@modelcontextprotocol/sdk)

```bash
npm install @canhelpto/mcp-support
# if npm does not have it yet: npm install github:mvphubco/canhelpto-mcp-support
```

Right after the server is created and **before** any tool is registered:

```ts
import { withSupport } from "@canhelpto/mcp-support";

withSupport(server, {
  apiKey: process.env.CANHELPTO_API_KEY!,
  product: "<the product's name>",
  user: (extra) => /* the existing user lookup */ ({ id, name, email, plan }),
  rules: [
    // 3 to 10 answers the team already gives, from the docs, FAQ or error messages:
    // { match: ["word", "other word"], answer: "What to do.", nextTool: "a_tool_name" },
  ],
});
```

Tools registered after `withSupport` are recorded (name, time, duration, ok or error; never arguments or results) and their error results get one line: "If this keeps failing, call support_ask; support_open_ticket puts it to the team with this error attached."

## 3. Python or another language

Make the same three tools with three HTTP calls (OpenAPI: https://canhelpto.com/openapi.json):

- `support_open_ticket`: `POST https://canhelpto.com/api/v1/tickets` with headers `X-API-Key: $CANHELPTO_API_KEY`, `X-Service-Mode: true` and body `{summary, message, priority, category, customerName, customerEmail, tags: ["mcp", category], page: "mcp://<product>", metadata: {mcp: {account: {userId, fullName, email}, client: {userAgent}, recentCalls: [{tool, at, ms, ok, error}]}}}`. Put the customer's words first in `message`, then a block that starts with `— Connector context (attached by <product>'s MCP support) —`.
- `support_ticket_status`: `GET https://canhelpto.com/api/v1/tickets/{id}` with `X-API-Key` and **without** `X-Service-Mode` (internal notes stay out). Show the ticket only if `metadata.mcp.account.userId` is the caller's id or `customerEmail` is the caller's email.
- `support_ask`: match the question against the rules in code; no model call; with no match, point to `support_open_ticket`.

Keep the last 12 calls per user in memory and append the support hint to every tool error.

## 4. Prove it

1. Run the project's tests and type-check.
2. Start the server and call `support_open_ticket` once with the subject "canhelpto install test" (from an MCP client or the project's test harness).
3. The tool must answer with a ticket id. Tell the person to open https://canhelpto.com/dashboard: the ticket shows the Connector context panel with the recent calls.
4. Ask the person to close the test ticket.

## 5. Tell the agent when to call

Add one sentence to the server's instructions (the `instructions` of the MCP initialize response): "For problems with <product> itself, call support_ask first; support_open_ticket reaches the team with the failed call attached."

## What the vendor's team does next

Tickets land in the canhelpto inbox (canhelpto.com/dashboard). The team answers there, or from its own Claude: add a custom connector with `https://canhelpto.com/api/mcp` and sign in. The answer reaches the user by email and through `support_ticket_status`.

Package source and tests: https://github.com/mvphubco/canhelpto-mcp-support
