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

# MCP Server

> Connect AI assistants to Datafold using the Model Context Protocol

## Overview

Datafold provides a public HTTP MCP (Model Context Protocol) server that enables AI assistants to interact with your Datafold data sources, run queries, and manage data diffs.

**Endpoint:** `https://app.datafold.com/mcp/`

## Prerequisites

Before setting up the MCP server, you need a Datafold API key.

<Steps>
  <Step title="Navigate to Settings">
    Open the Datafold app and go to **Settings > Account**
  </Step>

  <Step title="Create API Key">
    Click **Create API Key** and store it securely
  </Step>
</Steps>

<Note>
  If you lose your API key, you'll need to generate a new one. See the [Introduction guide](/api-reference/introduction) for more details.
</Note>

## Authentication

The MCP server uses Bearer token authentication with your Datafold API key:

```
Authorization: Key YOUR_API_KEY
```

Include this header in your MCP client configuration.

***

## Setup by Client

<AccordionGroup>
  <Accordion title="Claude Desktop" icon="robot">
    Claude Desktop supports MCP servers through its developer configuration file.

    **Steps:**

    1. Open Claude Desktop
    2. Go to **Settings > Developer > Edit Config**
    3. Add the following to your list of MCP servers in `claude_desktop_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "command": "mcp-remote",
          "args": [
            "https://app.datafold.com/mcp/",
            "--header",
            "Authorization: Key YOUR_API_KEY"
          ]
        }
      }
    }
    ```

    4. Save the file and restart Claude Desktop

    <Note>
      You need to have `mcp-remote` installed. Install it with `npm install -g mcp-remote` if you haven't already.
    </Note>
  </Accordion>

  <Accordion title="Claude Code" icon="command">
    Claude Code supports MCP through a simple CLI command.

    **Quick Setup:**

    Run the following command in your terminal:

    ```bash theme={null}
    claude mcp add --transport http --scope user \
      datafold https://app.datafold.com/mcp/ \
      --header "Authorization: Key YOUR_API_KEY"
    ```

    **Options:**

    * `--scope user` - Makes the server available across all projects
    * `--header` - Adds authentication header

    **Verify Installation:**

    ```bash theme={null}
    claude mcp list
    ```

    The Datafold MCP server will now be available in all your Claude Code sessions.

    <Note>
      See the [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp) for more configuration options.
    </Note>
  </Accordion>

  <Accordion title="Cursor" icon="code">
    Cursor supports MCP servers through project-specific or global configuration.

    **Project-Specific Setup:**

    Create `.cursor/mcp.json` in your project directory:

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "type": "http",
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key YOUR_API_KEY"
          }
        }
      }
    }
    ```

    Restart Cursor to load the configuration.
  </Accordion>

  <Accordion title="VS Code with Cline" icon="terminal">
    Cline is a VS Code extension that supports MCP servers.

    **Steps:**

    1. Install the Cline extension
    2. Click the **MCP Servers** icon in Cline's navigation
    3. Select **Configure** tab → **Advanced MCP Settings**
    4. Add to `cline_mcp_settings.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "type": "http",
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key YOUR_API_KEY"
          },
          "timeout": 60000
        }
      }
    }
    ```

    5. Toggle the switch to enable the server
    6. Close and reopen VS Code
  </Accordion>

  <Accordion title="Windsurf" icon="wind">
    Windsurf supports environment variable interpolation for secure credential storage.

    **Configuration File:** `~/.codeium/windsurf/mcp_config.json`

    **Basic Configuration:**

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "type": "http",
          "serverUrl": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key YOUR_API_KEY"
          }
        }
      }
    }
    ```

    **Using Environment Variables (Recommended):**

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "type": "http",
          "serverUrl": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key ${env:DATAFOLD_API_KEY}"
          }
        }
      }
    }
    ```

    Set `DATAFOLD_API_KEY` as an environment variable, then restart Windsurf.
  </Accordion>

  <Accordion title="Continue.dev" icon="play">
    Continue.dev supports MCP in agent mode through YAML configuration.

    **Configuration Directory:** `.continue/mcpServers/`

    Create `datafold.yaml`:

    ```yaml theme={null}
    type: streamable-http
    url: https://app.datafold.com/mcp/
    headers:
      Authorization: "Key YOUR_API_KEY"
    ```

    <Note>
      MCP can only be used in agent mode within Continue.dev.
    </Note>
  </Accordion>

  <Accordion title="Zed" icon="pen-nib">
    Zed supports MCP through custom configuration in settings.

    **Steps:**

    1. Open Zed
    2. Go to **Preferences > Settings** (`⌘,` on macOS)
    3. Add a `context_servers` section:

    ```json theme={null}
    {
      "context_servers": {
        "datafold": {
          "settings": {
            "url": "https://app.datafold.com/mcp/",
            "headers": {
              "Authorization": "Key YOUR_API_KEY"
            }
          }
        }
      }
    }
    ```

    4. Check the Agent Panel - the indicator should be green when active
  </Accordion>

  <Accordion title="OpenCode" icon="code">
    OpenCode supports both local and remote MCP servers with automatic OAuth handling.

    **Configuration Files:**

    * Global: `~/.config/opencode/opencode.json`
    * Project: `opencode.json` in project root (overrides global)

    **Remote MCP Configuration:**

    ```json theme={null}
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "datafold": {
          "type": "remote",
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Bearer MY_DATAFOLD_API_KEY"
          },
          "enabled": true
        }
      }
    }
    ```

    **CLI Setup:**
    You can also use the interactive CLI to add the server:

    ```bash theme={null}
    opencode mcp add
    ```

    Then follow the prompts to configure the Datafold remote MCP server.

    <Note>
      See the [OpenCode MCP documentation](https://opencode.ai/docs/mcp-servers/) for advanced configuration.
    </Note>
  </Accordion>

  <Accordion title="Gemini CLI" icon="google">
    Gemini CLI supports MCP servers with built-in OAuth 2.0 authentication.

    **Configuration Files:**

    * Global: `~/.gemini/settings.json`
    * Project: `.gemini/settings.json` in project directory

    **Add via CLI (Recommended):**

    ```bash theme={null}
    gemini mcp add datafold --scope user \
      --transport http \
      --url https://app.datafold.com/mcp/ \
      --header "Authorization: Key YOUR_API_KEY"
    ```

    **Manual Configuration:**

    Edit your settings file:

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "transport": "http",
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key YOUR_API_KEY"
          }
        }
      }
    }
    ```

    <Note>
      See the [Gemini CLI MCP documentation](https://geminicli.com/docs/tools/mcp-server/) for OAuth and advanced features.
    </Note>
  </Accordion>

  <Accordion title="Kiro" icon="brackets-curly">
    Kiro supports both global and project-specific MCP configuration.

    **Global Configuration:**

    Edit `~/.kiro/settings/mcp.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key YOUR_API_KEY"
          }
        }
      }
    }
    ```

    **Project-Specific Configuration:**

    Edit `.kiro/settings/mcp.json` in your project directory with the same format.

    **Using Environment Variables (Recommended):**

    ```json theme={null}
    {
      "mcpServers": {
        "datafold": {
          "url": "https://app.datafold.com/mcp/",
          "headers": {
            "Authorization": "Key ${API_TOKEN}"
          }
        }
      }
    }
    ```

    Changes apply automatically when you save the file.

    <Note>
      See the [Kiro MCP documentation](https://kiro.dev/docs/mcp/configuration/) for advanced options.
    </Note>
  </Accordion>
</AccordionGroup>

***

## Verification

After configuring your MCP client, verify the connection:

1. Check that the server status shows as "active" or "connected"
2. Test with a simple query:
   * "List my Datafold data sources"
   * "Run a query against \[data source name]"

If successful, your AI assistant can now interact with Datafold through MCP.

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection Errors" icon="circle-exclamation">
    **Symptoms:** "Unable to connect to MCP server" or "No valid session ID"

    **Solutions:**

    * Verify your API key is valid
    * Confirm the URL is exactly `https://app.datafold.com/mcp/`
    * Check header format: `Authorization: Key YOUR_API_KEY`
    * Regenerate your API key if issues persist
  </Accordion>

  <Accordion title="Authentication Errors" icon="lock">
    **Symptoms:** "401 Unauthorized" or "403 Forbidden"

    **Solutions:**

    * Generate a new API key if needed
    * Verify the header uses `Key` prefix (not `Bearer`)
    * Check your API key hasn't been revoked
  </Accordion>

  <Accordion title="Server Not Loading" icon="server">
    **Symptoms:** MCP server doesn't appear or shows as inactive

    **Solutions:**

    * Restart your MCP client completely
    * Validate JSON/YAML syntax
    * Check client logs for specific errors
    * Ensure configuration file is in the correct location
  </Accordion>
</AccordionGroup>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Secure Your Keys" icon="shield-check">
    Never commit API keys to version control. Use environment variables or secure secret management.
  </Card>

  <Card title="Use Environment Variables" icon="code">
    Reference API keys through environment variables rather than hardcoding them in configuration files.
  </Card>

  <Card title="Monitor Usage" icon="chart-line">
    Regularly check Datafold audit logs to monitor API usage and detect anomalies.
  </Card>

  <Card title="Rotate Keys" icon="arrows-rotate">
    Periodically rotate your API keys as part of security best practices.
  </Card>
</CardGroup>

***

## Additional Resources

<CardGroup cols={2}>
  <Card title="API Introduction" icon="book" href="/api-reference/introduction">
    Learn more about Datafold's REST API
  </Card>

  <Card title="Model Context Protocol" icon="plug" href="https://modelcontextprotocol.io/">
    Official MCP specification
  </Card>

  <Card title="Data Sources API" icon="database" href="/api-reference/data-sources/list-data-sources">
    Explore data source endpoints
  </Card>

  <Card title="Data Diffs API" icon="code-compare" href="/api-reference/data-diffs/list-data-diffs">
    Learn about data diff operations
  </Card>
</CardGroup>

***

## Support

If you need assistance:

* Check the [Datafold documentation](https://docs.datafold.com)
* Review your MCP client's documentation
* Contact support via Slack, in-app chat, or [support@datafold.com](mailto:support@datafold.com)
