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

# MCP Setup Guide

> Complete ChainStream MCP Server setup in 5 minutes

This guide helps you quickly configure ChainStream MCP Server.

***

## Prerequisites

| Requirement         | Details                                 | How to Get                                      |
| ------------------- | --------------------------------------- | ----------------------------------------------- |
| ChainStream Account | Registered account                      | [Sign up](https://www.chainstream.io/dashboard) |
| API Key             | `X-API-KEY` for authentication          | Dashboard → Apps → Create App                   |
| AI Client           | Claude Desktop / Cursor / Custom client | Installed                                       |

***

## MCP Endpoint

ChainStream provides a hosted MCP Server. No local installation required — connect directly via:

```
https://mcp.chainstream.io/mcp
```

***

## Configuration Steps

<Steps>
  <Step title="Get API Key">
    1. Log in to [ChainStream Dashboard](https://www.chainstream.io/dashboard)
    2. Navigate to **Applications**
    3. Click **Create New App** and copy your API Key
  </Step>

  <Step title="Configure AI Client">
    <Tabs>
      <Tab title="Claude Desktop">
        **Config file path**:

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

        **Option A — Cloud endpoint (recommended)**:

        ```json theme={null}
        {
          "mcpServers": {
            "chainstream": {
              "url": "https://mcp.chainstream.io/mcp",
              "headers": {
                "X-API-KEY": "your_api_key"
              }
            }
          }
        }
        ```

        **Option B — Local npm package (stdio)**:

        ```json theme={null}
        {
          "mcpServers": {
            "chainstream": {
              "command": "npx",
              "args": ["@chainstream-io/mcp"],
              "env": {
                "CHAINSTREAM_API_KEY": "your_api_key"
              }
            }
          }
        }
        ```

        <Note>
          If the file doesn't exist, create it manually. If you have other MCP Server configurations, add the `chainstream` config to the existing `mcpServers` object.
        </Note>
      </Tab>

      <Tab title="Cursor IDE">
        **Config file path**: `.cursor/mcp.json` (project-level) or Cursor Settings → Features → MCP Servers

        **Option A — Cloud endpoint**:

        ```json theme={null}
        {
          "mcpServers": {
            "chainstream": {
              "url": "https://mcp.chainstream.io/mcp",
              "headers": {
                "X-API-KEY": "your_api_key"
              }
            }
          }
        }
        ```

        **Option B — Local npm package (stdio)**:

        ```json theme={null}
        {
          "mcpServers": {
            "chainstream": {
              "command": "npx",
              "args": ["@chainstream-io/mcp"],
              "env": {
                "CHAINSTREAM_API_KEY": "your_api_key"
              }
            }
          }
        }
        ```
      </Tab>

      <Tab title="Custom Client">
        Connect to the cloud endpoint via HTTP:

        | Endpoint     | URL                              | Method |
        | ------------ | -------------------------------- | ------ |
        | MCP Endpoint | `https://mcp.chainstream.io/mcp` | POST   |

        **Authentication**: pass API Key via `X-API-KEY` header.

        **Example Code**:

        ```javascript theme={null}
        import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
        import { Client } from '@modelcontextprotocol/sdk/client/index.js';

        const transport = new StreamableHTTPClientTransport(
          new URL('https://mcp.chainstream.io/mcp'),
          {
            requestInit: {
              headers: {
                'X-API-KEY': process.env.CHAINSTREAM_API_KEY
              }
            }
          }
        );

        const client = new Client({
          name: 'my-client',
          version: '1.0.0'
        });

        await client.connect(transport);

        const { tools } = await client.listTools();
        console.log('Available tools:', tools.map(t => t.name));
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Restart Client">
    After configuration, completely quit and restart your AI client for changes to take effect.

    * **Claude Desktop**: Fully quit (not just minimize), then reopen
    * **Cursor**: Restart the IDE
  </Step>
</Steps>

***

## Verify Configuration

### Test Command

Enter the following test question in your AI client:

```
What is the SOL token on Solana? Is it safe?
```

### Expected Result

If configured successfully, the AI should:

1. Call `tokens_search` to find the SOL token
2. Call `tokens_analyze` to get security and holder data
3. Return a natural language summary

<Note>
  If the AI doesn't call the tool or returns an error, refer to [Troubleshooting](#troubleshooting) below.
</Note>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication failed" icon="key">
    **Possible causes**:

    1. **API Key entered incorrectly**
       * Check for extra spaces
       * Confirm complete copy

    2. **API Key revoked or expired**
       * Check key status in Dashboard
       * Create a new key if needed

    3. **Wrong header name**
       * Cloud endpoint: use `X-API-KEY` header
       * npm package: use `CHAINSTREAM_API_KEY` env var

    **Solutions**:

    * Verify key in Dashboard → Applications
    * Test directly: `curl -H "X-API-KEY: your_key" https://api.chainstream.io/v2/blockchain`
  </Accordion>

  <Accordion title="Connection failed" icon="plug-circle-xmark">
    **Possible causes**:

    1. **Network issues**
       * Check network connection
       * Confirm access to `https://mcp.chainstream.io`

    2. **Configuration format error**
       * Check JSON format is correct
       * Confirm URL spelling is correct

    **Solution**:

    ```bash theme={null}
    curl -I https://mcp.chainstream.io/mcp
    ```
  </Accordion>

  <Accordion title="Config file not taking effect" icon="file-circle-xmark">
    **Possible causes**:

    1. **Config file path incorrect**
       * macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
       * Windows: `%APPDATA%\Claude\claude_desktop_config.json`

    2. **JSON format error**
       * Use a JSON validator to check

    3. **Client not restarted**
       * Fully quit and restart

    **Solution**:

    ```bash theme={null}
    cat ~/Library/Application\ Support/Claude/claude_desktop_config.json | python -m json.tool
    ```
  </Accordion>

  <Accordion title="Tool call failed: Quota exceeded" icon="gauge-low">
    **Possible causes**:

    1. Plan quota exhausted
    2. Request rate too high, triggering rate limit

    **Solutions**:

    * Check quota usage in Dashboard
    * Upgrade plan for more quota
  </Accordion>

  <Accordion title="Data return delayed or timeout" icon="clock">
    **Possible causes**:

    1. Network latency
    2. Query data volume too large

    **Solutions**:

    * Check network connection
    * Reduce data volume per query
    * Try again later
  </Accordion>
</AccordionGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Tools Catalog" icon="wrench" href="/en/docs/ai-agents/mcp-server/tools">
    View all available tools and usage examples
  </Card>

  <Card title="AI Agent Tutorial" icon="graduation-cap" href="/en/docs/tutorials/ai-agent-with-mcp">
    Build an AI trading assistant
  </Card>
</CardGroup>
