> For the complete documentation index, see [llms.txt](https://chaincontext.gitbook.io/help-center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaincontext.gitbook.io/help-center/running/connecting-ai-clients.md).

# Connecting AI Clients

Once your MCP server is deployed, connect it to any MCP-compatible AI client.

Your server URL is:

```
https://{your-slug}.chaincontext.dev/mcp
```

## Client setup

{% tabs %}
{% tab title="Claude Desktop" %}
Edit `claude_desktop_config.json`:

* **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
* **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "my-server": {
      "url": "https://my-server.chaincontext.dev/mcp"
    }
  }
}
```

For **private** servers, add the API key:

```json
{
  "mcpServers": {
    "my-server": {
      "url": "https://my-server.chaincontext.dev/mcp",
      "headers": {
        "Authorization": "Bearer sk_your_api_key"
      }
    }
  }
}
```

Restart Claude Desktop after editing the config.
{% endtab %}

{% tab title="Cursor" %}
Edit `.cursor/mcp.json` in your project root (or global config):

```json
{
  "mcpServers": {
    "my-server": {
      "url": "https://my-server.chaincontext.dev/mcp"
    }
  }
}
```

Cursor auto-detects config changes — no restart needed.
{% endtab %}

{% tab title="Windsurf" %}
Edit `~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "my-server": {
      "url": "https://my-server.chaincontext.dev/mcp"
    }
  }
}
```

{% endtab %}

{% tab title="Claude.ai" %}
Claude.ai supports remote MCP servers natively.

1. Go to Claude.ai → **Settings** → **Integrations** → **MCP Servers**
2. Add your server URL: `https://my-server.chaincontext.dev/mcp`
   {% endtab %}
   {% endtabs %}

## Custom integrations

Use any MCP client SDK to connect programmatically:

```typescript
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
import { Client } from '@modelcontextprotocol/sdk/client/index.js'

const transport = new StreamableHTTPClientTransport(
  new URL('https://my-server.chaincontext.dev/mcp')
)

const client = new Client({ name: 'my-app', version: '1.0.0' })
await client.connect(transport)

// List available tools
const { tools } = await client.listTools()

// Call a tool
const result = await client.callTool({
  name: 'get-token-balance',
  arguments: { tokenAddress: '0x...', walletAddress: '0x...' }
})
```

## Transports

ChainContext supports two MCP transports:

| Transport           | Endpoint    | Best for                                    |
| ------------------- | ----------- | ------------------------------------------- |
| **Streamable HTTP** | `POST /mcp` | Claude Desktop, Cursor, most modern clients |
| **SSE**             | `GET /sse`  | Older clients, browser-based integrations   |

For SSE, the server sends an `endpoint` event with the message URL. The client then POSTs requests to that URL.

## Private server authentication

If your server is set to **Private** access mode:

1. Generate an API key in Dashboard → Project Settings → **API Keys**
2. Copy the key (shown only once)
3. Include it in your client config as an `Authorization: Bearer` header

{% hint style="warning" %}
The key is hashed (SHA-256) before storage — the raw key is shown **only once** at creation time. Store it securely.
{% endhint %}

## Troubleshooting

<details>

<summary>"Connection refused" or timeout</summary>

* Verify the project is deployed (status = **Live**)
* Check the URL matches your project slug exactly
* Try the health endpoint: `https://my-server.chaincontext.dev/health`

</details>

<details>

<summary>"Unauthorized" (401)</summary>

* Your server is in **Private** mode — add an API key header
* Verify the API key hasn't been revoked in the dashboard

</details>

<details>

<summary>Tools not showing up</summary>

* Make sure tools are **enabled** (toggle in the Tools tab)
* Re-deploy after adding new tools — changes aren't live until deployed

</details>
