# The MCP server

`@lupeno/mcp` lets an AI assistant work with your events through the [Model Context Protocol](https://modelcontextprotocol.io): Claude, ChatGPT, Cursor, VS Code and other MCP clients get tools for your events, orders, tickets, attendees, discount codes and check-ins, plus these guides to read. It is a thin layer over the same public API and the [TypeScript SDK](https://lupeno.com/developers/guides/sdk) — it can do nothing your API key cannot.

It runs on your computer or your own server, with your own key. Lupeno hosts no MCP server.

## Start with a test key

Make a key in Lupeno under **Organization → Integrations → API keys** — a **test** key (`lup_test_…`) first. A test key sees only events in test mode and their test orders, so an assistant can try everything without touching a real order. Give it the narrowest reach that does the job: one event rather than the whole organization, `read` unless it should change things, and no `pii` unless it truly needs buyers' e-mails (without it they come masked).

Then add the server to your client. For Claude Desktop, Claude Code, Cursor and most others the configuration is the same:

```json
{
  "mcpServers": {
    "lupeno": {
      "command": "npx",
      "args": ["-y", "@lupeno/mcp"],
      "env": { "LUPENO_API_KEY": "lup_test_…" }
    }
  }
}
```

With Claude Code from a terminal:

```sh
claude mcp add lupeno --env LUPENO_API_KEY=lup_test_… -- npx -y @lupeno/mcp
```

Node 20.19 or later.

## Settings

| Variable | Meaning |
|---|---|
| `LUPENO_API_KEY` | The key the server acts with. Required. |
| `LUPENO_API_URL` | The API's address; `https://api.lupeno.com` when unset. |
| `LUPENO_MCP_READ_ONLY` | `true`: the server offers no tool that changes anything. |
| `LUPENO_MCP_ALLOW_LIVE_WRITES` | `true`: writes with a live key are carried out. Unset, they are refused before anything is sent. |

## Live keys

With a live key (`lup_live_…`) the assistant reads real orders and real people. Its writes — entering an order, naming a ticket's holder, cancelling, checking in — are **refused** unless you start the server with `LUPENO_MCP_ALLOW_LIVE_WRITES=true`. Turn that on only for a session in which you mean the assistant to change real data, and keep your client asking before each tool call.

Text an assistant reads — an e-mail, a web page, a buyer's note — can carry instructions meant to trick it. A read-only key (or `LUPENO_MCP_READ_ONLY=true`) is the sure way to keep such text from changing anything.

## What it offers

**Tools.** Every tool calls the endpoints listed in the [tool table](https://lupeno.com/developers/AGENTS.md). Reads: `get_organization` (who the key is — call it first), `list_events`, `get_event` (with its ticket tiers), `list_orders`, `get_order`, `list_order_documents`, `list_tickets`, `get_ticket`, `list_attendees`, `list_check_ins`, `list_discount_codes`, `get_discount_code`. Writes: `create_order`, `cancel_order`, `assign_ticket`, `create_discount_code`, `revoke_discount_code`, `check_in_ticket`, `revert_check_in`. Each tool tells the client whether it is read-only, destructive or idempotent, so the client can ask you before the ones that change things.

**Resources.** `lupeno://agents` — the rules for agents ([AGENTS.md](https://lupeno.com/developers/AGENTS.md)); `lupeno://guides/<slug>` — every guide on this site; `lupeno://events/{eventId}` — an event with its ticket tiers.

## How it behaves

- **Pages, not everything.** List tools answer one page and its `nextCursor`; the assistant asks for the next page when it needs one. Nothing reads a whole list by itself.
- **Creates are idempotent.** `create_order` and `create_discount_code` take an `idempotencyKey`. Without one, the server makes one and names it in the answer, so a retry of the same create uses it and nothing is made twice ([Idempotency](https://lupeno.com/developers/guides/idempotency)).
- **Rate limits are reported, not waited out.** A `429` comes back with the seconds `Retry-After` asks for; the server never retries by itself.
- **Errors read like the API's.** A refusal names its status, `code`, title, the fields at fault and the `requestId` ([Errors](https://lupeno.com/developers/guides/errors)). The key never appears in an answer.
- **Some writes mail people.** Entering an order mails its buyer, naming a holder mails the holder — in test mode too, and against the organization's daily reach.
- **No PDFs.** Documents are listed, not downloaded: a PDF prints the buyer unmasked.

## Over HTTP, on your own server

For a team's own deployment the server also speaks Streamable HTTP:

```sh
npx -y @lupeno/mcp --http --port 3333
```

It listens on `127.0.0.1` and takes each request's key from its `Authorization: Bearer lup_…` header — every caller brings their own key, and the server keeps none. To listen on another address, name the hostnames clients use in `LUPENO_MCP_ALLOWED_HOSTS` (comma-separated) and put TLS in front of it.

## AGENTS.md

[`/developers/AGENTS.md`](https://lupeno.com/developers/AGENTS.md) tells coding agents how to work with the Lupeno API — test keys first, an idempotency key on every create, cursor pagination, webhook signatures, rate limits — and which MCP tool calls which endpoint. The SDK and this server carry the same file.
