# MCP for AI agents

> Give your agents, or your users' AI assistants, the portal data as MCP tools.

Every connection can also be used through the Model Context Protocol, the standard way AI assistants (Claude, ChatGPT, Cursor, VS Code) and agent frameworks call tools. Each portal operation becomes a tool with a typed input schema. Tools only read, unless the caller is allowed to change data (a `read_write` API key, or a link created with `allow_writes`). Everything below can also be done without code from the [console's MCP tab](https://sidelatch.com/account#mcp).

### Two servers

| URL | Who it's for | Auth |
|---|---|---|
| `https://sidelatch.com/mcp/l/<link id>` | One end user and one connection, in their own AI assistant. You create the link and give it to them. | OAuth (the user types the link's access code on our approval page), or the access code as a bearer. |
| `https://sidelatch.com/mcp` | Your own agents, across all your connections. | `Authorization: Bearer <API key>` |

Both speak Streamable HTTP and answer each POST with JSON; there is no SSE stream and no session to keep. Protocol versions 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05.

### Many users: one link each

Each of your users who links a portal login is their own connection, so 15 users are 15 connections. Give each one their own link and their assistant sees only their data:

- **One connection per link.** A link's tools take no `connection_id`, so one user's assistant can't reach another user's connection, even by guessing an id.
- **Several links per connection.** Up to 50, for example one per device or assistant, each with its own label, expiry, operations and write setting, and each revoked on its own.
- **Links survive a re-sign-in.** When a user signs in again after `reconnect_needed`, the connection id stays the same and their link keeps working. Disconnecting the connection revokes its links.
- **Limits are per connection and per link**, so one busy user doesn't use up another's.

Never give an end user your API key or the `https://sidelatch.com/mcp` server: it reaches every connection on your account. Use it for your own backend agents, which work across all your users.

### Set up for an end user

1. **Create a link for the user's connection** [`POST /v1/connections/{id}/mcp-links`](https://sidelatch.com/docs/api#ref-post-v1-connections-conn-id-mcp-links) returns the link's `url` and its `token`, the access code. The token is shown once. Optional: `expires_in_days`, `operations` (only these become tools), `allow_writes` (off by default) and `allow_relink`.

   **Request**

   ```http
   POST /v1/connections/conn_8f2c41d07a9b4e6f/mcp-links
   Authorization: Bearer sl_live_...

   {
     "label": "Dana in Claude",
     "expires_in_days": 90
   }
   ```

   **Response 200**

   ```json
   {
     "id": "mcl_6b1f0e2d9c8a7b6c5d4e",
     "url": "https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e",
     "token": "slmcp_...",
     "allow_writes": false,
     "expires_at": 1803500000.0,
     "active": true
   }
   ```

2. **Give the user the URL and the access code** Show them in your app, or send a message like this one. Send the access code privately: anyone with it and the URL can read that user's data until you revoke the link.

   **Message for the user**

   ```
   You can now use your Demo Carrier data in your AI assistant.

   Server URL:   https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e
   Access code:  slmcp_...

   Claude: Customize > Connectors > Add custom connector, paste the server URL, then paste the access code on the approval page that opens.
   ChatGPT: Settings > Apps > Advanced settings > Developer mode, then Create a connector with the server URL (OAuth) and paste the access code on the approval page.

   The access code works like a password: keep it private.
   ```

3. **The user adds it to their assistant**

   **Claude** (web, desktop, mobile): **Customize → Connectors → Add custom connector**, paste the URL, connect, then paste the access code on the Sidelatch page that opens and approve. On Team and Enterprise plans an owner adds custom connectors under **Organization settings → Connectors**.

   **ChatGPT**: **Settings → Apps → Advanced settings**, turn on **Developer mode**, then **Create** a connector with the URL and OAuth. Paste the access code on the Sidelatch page that opens. In a chat, turn it on from **+ → More → Developer mode**. On Business and Enterprise workspaces an admin has to allow developer mode first, and availability varies by plan.

   **Claude Code, Cursor and VS Code** take the access code as a bearer header:

   **Claude Code (terminal)**

   ```
   claude mcp add --transport http sidelatch https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e --header "Authorization: Bearer slmcp_..."
   ```

   **Cursor: ~/.cursor/mcp.json**

   ```
   {
     "mcpServers": {
       "sidelatch": {
         "url": "https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e",
         "headers": {
           "Authorization": "Bearer slmcp_..."
         }
       }
     }
   }
   ```

   **VS Code: .vscode/mcp.json**

   ```
   {
     "servers": {
       "sidelatch": {
         "type": "http",
         "url": "https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e",
         "headers": {
           "Authorization": "Bearer slmcp_..."
         }
       }
     }
   }
   ```

4. **Revoke it when you need to** [`DELETE /v1/mcp-links/{id}`](https://sidelatch.com/docs/api#ref-delete-v1-mcp-links-link-id) turns the link and every OAuth token issued for it off at once. Disconnecting the connection revokes its links too.

### Set up for your own agents

1. **Make a read-only API key** Agents rarely need to change portal data, and a read-only key makes that impossible: write tools don't even appear. Use a `read_write` key only for agents that should make changes.

   **Request**

   ```http
   POST /v1/api-keys
   Authorization: Bearer sl_live_...

   {
     "scope": "read"
   }
   ```

   **Response 200**

   ```json
   {
     "id": "key_9a8b7c6d5e4f",
     "api_key": "sl_test_...",
     "scope": "read"
   }
   ```

2. **Point your agent at `https://sidelatch.com/mcp`** Tools are `list_connections`, `get_connection_status` and `<portal>__<operation>` (for example `demo_carrier__list_policies`), each taking a `connection_id`. Tools appear for the portals you have connections to.

   **Claude Code (terminal)**

   ```
   claude mcp add --transport http sidelatch https://sidelatch.com/mcp --header "Authorization: Bearer sl_live_..."
   ```

   **Cursor: ~/.cursor/mcp.json**

   ```
   {
     "mcpServers": {
       "sidelatch": {
         "url": "https://sidelatch.com/mcp",
         "headers": {
           "Authorization": "Bearer sl_live_..."
         }
       }
     }
   }
   ```

   **VS Code: .vscode/mcp.json**

   ```
   {
     "servers": {
       "sidelatch": {
         "type": "http",
         "url": "https://sidelatch.com/mcp",
         "headers": {
           "Authorization": "Bearer sl_live_..."
         }
       }
     }
   }
   ```

   **Claude Agent SDK (Python)**

   ```
   from claude_agent_sdk import ClaudeAgentOptions

   options = ClaudeAgentOptions(mcp_servers={
       "sidelatch": {"type": "http", "url": "https://sidelatch.com/mcp",
                     "headers": {"Authorization": "Bearer sl_live_..."}},
   })
   ```

3. **Check it with curl** Any MCP client works the same way: POST JSON-RPC with the header.

   **List the tools**

   ```
   curl -s https://sidelatch.com/mcp \
     -H "Authorization: Bearer sl_live_..." \
     -H "Content-Type: application/json" \
     -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
   ```

### Troubleshooting

| What you see | What to do |
|---|---|
| `401` with `invalid_token` | The access code or key is wrong, revoked or expired, or the code belongs to a different link URL. Create a new link (or key). |
| Approval page says the code doesn't match | The user pasted the code from another link, or the link was revoked. After 10 wrong codes the page waits 15 minutes. |
| `403` origin not allowed | A browser-based client sent an `Origin` header. Add that origin to `allowed_origins` in [settings](https://sidelatch.com/docs/api#ref-patch-v1-settings). |
| Tool error `reconnect_needed` | The user's portal login stopped working. They sign in again at the `relink_url` in the error, or through your app. The connection id stays the same. |
| Tool error `rate_limited` or `portal_busy` | Wait `retry_after` seconds. Repeated identical calls are answered from the cache. |
| A tool you expected is missing | Write tools need a `read_write` key or a link with `allow_writes`; links created with `operations` show only those; the customer server lists only portals you have connections to. |
| No **Developer mode** in ChatGPT, or no custom connectors in Claude | The user's plan or workspace admin settings don't allow custom connectors. They can use Claude Code, Cursor or VS Code with the bearer header instead. |

### What protects the portal

- **Results are cached for a minute.** The same call on the same connection is answered from memory (`cached: true`, with the original `retrieved_at`). Identical calls in flight share one portal call.
- **Rate limits.** Each connection gets 20 portal calls a minute (bursts of 10); each API key or link gets 120 tool calls a minute. Tool calls also share your account's fair share with the REST API: half of each portal's request budget, and 1,000 portal calls per connection a day. Cached answers never count. Over a limit, the tool returns `rate_limited` with `retry_after` seconds.
- **Every portal has a budget.** All our traffic to one portal shares a request budget and a cap on concurrent requests, and a 429 from the portal pauses all of it. A held-back call returns `portal_busy` with `retry_after`. Each linked account always reaches the portal from the same IP address. Portal operators can read about our traffic at [/bots](https://sidelatch.com/bots).
- **No sign-in challenges in chat.** If the portal wants the user to sign in again (a new verification code, a changed password), the tool returns `reconnect_needed` with a one-time `relink_url` to our hosted connect page (unless you minted the link with `allow_relink: false`). You also get the `connection.reconnect_needed` webhook.
- **Portal data is marked untrusted.** Results come under `data` in an envelope with `untrusted: true`, and the server tells the model not to follow instructions found in it, so text planted in a portal record can't steer the agent. Write tools are marked as such, and only appear for callers allowed to make changes.
- **Typed params.** Unknown or malformed arguments are refused before the portal is called.

MCP calls show in [usage](https://sidelatch.com/docs/api#ref-get-v1-usage) as `mcp:<operation>`, with outcomes `ok`, `cached`, `rate_limited` and the errors above.

---

Sidelatch docs: [Docs](https://sidelatch.com/docs.md) · [Quick start](https://sidelatch.com/docs/quickstart.md) · [Concepts](https://sidelatch.com/docs/concepts.md) · [The connect window](https://sidelatch.com/docs/guides/connect-window.md) · [Webhooks](https://sidelatch.com/docs/guides/webhooks.md) · [MCP for AI agents](https://sidelatch.com/docs/guides/mcp.md) · [Writes](https://sidelatch.com/docs/guides/writes.md) · [Build a portal](https://sidelatch.com/docs/guides/build-a-portal.md) · [Events](https://sidelatch.com/docs/events.md) · [Errors](https://sidelatch.com/docs/errors.md) · [API reference](https://sidelatch.com/docs/api.md)
