# MCP server

Every workspace has a [Model Context Protocol](https://modelcontextprotocol.io) server. Connect Claude, or any MCP client, and it can work your tickets the way a teammate would: read the queue, look into a ticket, leave a note, write a draft reply, and send one when you ask it to.

Whatever it does, it does **as the person who connected it**, with that person's role. Notes and replies carry their name, and a read-only seat gets a read-only connection.

## The address

```
https://YOUR-WORKSPACE.lagottolabs.ai/mcp
```

Put your workspace's subdomain where it says `YOUR-WORKSPACE`. The server speaks Streamable HTTP: JSON-RPC in a `POST`, JSON back. It keeps no session, so there is nothing to keep alive and no event stream to open (`GET` answers `405`).

## Claude

On claude.ai or in the Claude apps, open **Settings → Connectors → Add custom connector** and paste the address. Claude sends you to your workspace to sign in, shows you what it is asking for, and you press **Allow**. There is no key to copy.

The connection then appears under **Connected apps** on your profile in the workspace, where you can revoke it at any time.

## Claude Code

Either let it sign you in through the browser:

```
claude mcp add --transport http lagotto https://YOUR-WORKSPACE.lagottolabs.ai/mcp
```

and run `/mcp` inside Claude Code to finish signing in. Or hand it an [API key](https://www.lagottolabs.ai/docs/api.md#authentication), which suits a script or a machine with no browser:

```
claude mcp add --transport http lagotto https://YOUR-WORKSPACE.lagottolabs.ai/mcp \
  --header "Authorization: Bearer lg_…"
```

## Signing in

The server takes a bearer token, and there are two kinds.

### An API key

The same keys the [REST API](https://www.lagottolabs.ai/docs/api.md) uses, made by an administrator under **Settings → API keys**. A key acts as the person it was made for. A read key can use the tools that read and is refused by the ones that write.

```
curl https://YOUR-WORKSPACE.lagottolabs.ai/mcp \\
  -H "Authorization: Bearer $API_TOKEN" \\
  -H "Content-Type: application/json" \\
  -H "Accept: application/json, text/event-stream" \\
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

### OAuth 2.1

What Claude's connectors use, and what any MCP client that follows the specification will do by itself. A request with no token gets a `401` whose `WWW-Authenticate` header points at the server's metadata, and everything else is discovered from there:

| What | Where |
| --- | --- |
| Protected resource metadata (RFC 9728) | `/.well-known/oauth-protected-resource` |
| Authorization server metadata (RFC 8414) | `/.well-known/oauth-authorization-server` |
| Dynamic client registration (RFC 7591) | `POST /oauth/register` |
| Authorization, with the consent page | `GET /oauth/authorize` |
| Token | `POST /oauth/token` |
| Revocation (RFC 7009) | `POST /oauth/revoke` |

- Each workspace is its own authorization server. A client registered with one workspace, and a token issued by it, mean nothing to another.
- Clients are public: there is no client secret. **PKCE with `S256` is required.**
- Redirect addresses must be `https`, or `http` on `localhost` or `127.0.0.1`, and must match what was registered exactly.
- The one scope is `mcp`.
- An access token lasts about 1 hour. A refresh token lasts 30 days and is replaced every time it is used; using an old one again ends the connection.
- Removing a person from the workspace ends their connections and keys at once.

## Tools

This list is generated from the server itself.

| Tool | What it does |  |
| --- | --- | --- |
| `list_tickets` | List tickets in the queue, most recently active first. Defaults to open tickets for everyone; spam is never included. | Reads |
| `search_tickets` | Search open and closed tickets by words in the subject or messages, a customer's name or email address, or a ticket number. Best matches first. | Reads |
| `get_ticket` | Read one ticket: the whole thread (each message is from the customer, a reply an agent sent, or an internal note the customer never saw), the unsent draft reply if there is one, fix proposals and pull requests, the customer and the ticket's history. Quoted email threads and signatures are left out of message bodies. | Reads |
| `list_customer_tickets` | List every ticket one customer has opened, newest first, by their email address. | Reads |
| `get_customer_data` | Look up the customer on a ticket in the workspace's own product data: their account, plan, orders and whatever else the workspace shares. Only ever the customer the ticket is from, never somebody on CC. `status` is "found" (records are listed), "not_found" (the lookup worked and there is nothing for their address), "unavailable" (the lookup failed, which is NOT the same as not_found: never report it as the customer having no account) or "not_configured". Only where the workspace has switched on production data. | Reads |
| `add_internal_note` | Add an internal note to a ticket, in your name. Only your team sees it; nothing is sent to the customer. Markdown works. | Writes |
| `set_draft_reply` | Save a draft reply on a ticket, replacing any draft already there. Nothing is sent: the draft waits on the ticket page for a person to read, edit and send. `note` is an optional line for that person (what you checked, what you were unsure of); the customer never sees it. Markdown works. | Writes |
| `send_reply` | EMAILS THE CUSTOMER. Sends `body` as a reply on the ticket, in your name, to the customer and anyone CC'd, exactly as written - it cannot be unsent. Use set_draft_reply instead unless you were asked to send. `close` also closes the ticket. Markdown works. | Emails customers |
| `assign_ticket` | Assign a ticket to a person, or to nobody. `assignee` is "me", a teammate's email address (see list_agents), or "nobody" to unassign. | Writes |
| `close_ticket` | Close a ticket. A reply from the customer reopens it. If the workspace asks for satisfaction ratings, closing an answered ticket emails the customer that request. | Writes |
| `reopen_ticket` | Reopen a closed ticket. | Writes |
| `list_macros` | List the workspace's macros: canned replies the team wrote. With `number`, each is filled in for that ticket (customer name, your name, ticket number). | Reads |
| `search_knowledge_base` | Search the workspace's support documentation. Returns the best matching articles with their text and address. Search before answering a how-to question, and link the article you relied on. Only where the workspace has switched on knowledge base. | Reads |
| `remember` | Save one durable fact that future draft replies will read. kind "customer": something true of this ticket's customer that will matter next time. kind "product": something true of the product for every customer, confirmed, and still true next month. Never guesses, one-off details or personal data beyond what support needs. One fact per call. Only where the workspace has switched on memories. | Writes |
| `list_groups` | List the workspace's groups (the teams tickets are routed to) and who is in each. | Reads |
| `list_agents` | List the people in the workspace: name, email address, role, groups, and whether a ticket can be assigned to them. `you` marks the person this connection acts as. | Reads |

Tickets are addressed by their `number`, the one in the app and in the REST API. A tool answers with JSON text. When it has to say no (no such ticket, a read-only token) the result is marked `isError` and says why in words the model can act on.

## What it can and cannot do

- **`send_reply` emails your customer.** It goes out in your name, to the customer and anyone CC'd, exactly as written, and cannot be unsent. It is marked destructive, so Claude asks before using it unless you have told it not to.
- **`set_draft_reply` sends nothing.** The draft waits in the reply box on the ticket for a person to read, change and send. Ask for drafts and you stay the one who presses Send.
- `close_ticket` emails the customer a satisfaction survey if your workspace sends those.
- Internal notes are never shown to customers.
- Nothing is deleted through this server, and it changes no settings.
- It reaches one workspace: the one in the address.
- Every call is logged with the tool and the person, never the text of a note or a reply.

A sensible first instruction: *“Go through my tickets that need a reply, look into each one, and leave a draft. Don't send anything.”*
