# MCP server

Connect AI assistants (Claude Code, Cursor, VS Code and any client that supports remote MCP) to TryOnCloud. The assistant can read these docs, check your credits and run real try-ons while it builds your integration.

| | |
|---|---|
| URL | `https://www.tryoncloud.com/api/mcp` |
| Transport | Streamable HTTP |
| Auth | `X-API-KEY: tk_dev_v1_...` header (or `Authorization: Bearer tk_dev_v1_...`) |

## Tools

| Tool | What it does | Cost |
|---|---|---|
| `search_docs` | Searches these docs and returns the best-matching pages | Free |
| `read_doc` | Returns one docs page as Markdown | Free |
| `check_credits` | Your remaining try-ons | Free |
| `generate_tryon` | Runs a try-on from a garment URL and a person image URL, returns the image | 1 credit (free with `mock: true`) |

> **Note:** `generate_tryon` through MCP needs purchased credits (or `mock: true`). The free allowance is for direct API calls.

## Connect

### Claude Code

```bash
claude mcp add --transport http tryoncloud https://www.tryoncloud.com/api/mcp \
  --header "X-API-KEY: tk_dev_v1_your_key_here"
```

### Cursor

`~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):

```json
{
  "mcpServers": {
    "tryoncloud": {
      "url": "https://www.tryoncloud.com/api/mcp",
      "headers": { "X-API-KEY": "tk_dev_v1_your_key_here" }
    }
  }
}
```

### VS Code

`.vscode/mcp.json`. VS Code asks for the key once and stores it securely:

```json
{
  "inputs": [
    { "type": "promptString", "id": "tryoncloud-key", "description": "TryOnCloud API key", "password": true }
  ],
  "servers": {
    "tryoncloud": {
      "type": "http",
      "url": "https://www.tryoncloud.com/api/mcp",
      "headers": { "X-API-KEY": "${input:tryoncloud-key}" }
    }
  }
}
```

> **Warning:** Your API key can spend credits. Do not commit a config file that contains it; use the VS Code input prompt or a local, git-ignored file.

## Try it

Once connected, ask your assistant:

- "Search the TryOnCloud docs for how errors are handled."
- "How many TryOnCloud credits do I have left?"
- "Run a TryOnCloud try-on in mock mode with this garment URL and this person URL."
