> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meterlane.app/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP over SSE: Your Gateway Routes as AI Agent Tools

> Expose your Meterlane gateway routes as MCP tools over SSE so Claude and other AI assistants can call them directly — payments happen transparently.

The Model Context Protocol (MCP) lets AI assistants like Claude discover and call external tools through a standard interface. Meterlane implements MCP over Server-Sent Events (SSE), which means you can point any MCP-compatible client at your gateway and your routes automatically appear as callable tools. When the AI calls one of those tools, the gateway handles x402 payment verification transparently — the assistant never needs to know anything about USDC or signed authorizations.

## How it works

When your MCP client connects to `/mcp/sse`, the gateway authenticates your API key, then opens a persistent SSE stream. Over that stream it advertises each of your active routes as an MCP tool — the tool name comes from the route path, and the description comes from the `description` field you set on the route. When the AI assistant invokes a tool, the gateway:

1. Constructs the corresponding `https://gateway.meterlane.app/gateway/{orgSlug}/{routePath}` request.
2. Signs and attaches the x402 payment using your organization's payer wallet.
3. Proxies the request to your upstream and returns the result to the assistant.

The AI never sees payment headers or blockchain details. It just calls a tool and gets a response.

## Endpoint

```http theme={null}
GET https://gateway.meterlane.app/mcp/sse
Authorization: Bearer bp_live_…
```

The connection stays open for the duration of the session. Your MCP client should reconnect automatically on disconnect.

<Note>
  The `/mcp/sse` endpoint requires a valid Bearer API key. An invalid or missing key returns a `401` immediately, before the SSE stream opens.
</Note>

## Configuring Claude Desktop

Claude Desktop supports MCP servers via a JSON configuration file. Add the Meterlane gateway as an MCP server so Claude can call your routes as tools in any conversation.

<Steps>
  <Step title="Find your Claude Desktop config">
    Open `claude_desktop_config.json`. On macOS it lives at `~/Library/Application Support/Claude/claude_desktop_config.json`. On Windows, it is at `%APPDATA%\Claude\claude_desktop_config.json`.
  </Step>

  <Step title="Add the Meterlane MCP server">
    Add an entry under `mcpServers`. Replace `bp_live_…` with your real API key from the Meterlane dashboard:

    ```json theme={null}
    {
      "mcpServers": {
        "meterlane": {
          "url": "https://gateway.meterlane.app/mcp/sse",
          "headers": {
            "Authorization": "Bearer bp_live_…"
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Restart Claude Desktop">
    Save the file and restart Claude Desktop. Open a new conversation and ask Claude what tools are available — your gateway routes should appear in the list.
  </Step>
</Steps>

## Configuring other MCP clients

Any MCP client that supports SSE transports with custom headers can connect to the Meterlane gateway. Use the following values:

```json theme={null}
{
  "transport": "sse",
  "url": "https://gateway.meterlane.app/mcp/sse",
  "headers": {
    "Authorization": "Bearer bp_live_…"
  }
}
```

Refer to your client's documentation for the exact config schema — the values above map to the standard MCP SSE transport fields.

## Payment transparency

When an MCP tool call triggers a paid gateway route, payment happens automatically using your organization's on-chain payer wallet. The AI assistant receives the upstream response as the tool result. No additional confirmation steps are required.

<Warning>
  Each tool invocation that maps to a paid route consumes real USDC from your payer wallet. Make sure your wallet is funded before enabling MCP access for production workloads. Monitor usage from the **Dashboard → Payments** view.
</Warning>

## Making routes better MCP tools

The quality of your route's `description` field directly affects how well AI assistants understand when and how to call it. Write descriptions as plain English instructions:

| Route path   | Weak description | Better description                                                                                                            |
| ------------ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `/summarize` | `Summarize text` | `Summarize a document or article. Pass the full text as a 'text' query parameter. Returns a concise summary in plain prose.`  |
| `/weather`   | `Get weather`    | `Return current weather for a city. Pass city name as 'city' query parameter. Returns temperature, conditions, and humidity.` |

Update descriptions at any time via `PATCH /api/routes/{id}` — changes take effect on the next MCP client reconnect.
