# Data Access (MCP)

{% hint style="warning" %}
**Deprecated.** Data-MCP is being replaced by platform functions (`fn_query`), which provide the same query capabilities with tighter integration into the agent reasoning pipeline. New integrations should use platform functions instead. Data-MCP remains available during the transition.
{% endhint %}

Data-MCP is an MCP (Model Context Protocol) server that provides SQL query access to your workspace's data tables. It works with any MCP-compatible client.

{% hint style="info" %}
**Background reading** - For context on how workspace data is structured, see the [World Model conceptual docs](https://docs.amigo.ai/data/world-model).
{% endhint %}

## Authentication

Data-MCP uses standard Platform API key authentication. Every request requires:

| Header           | Value                   |
| ---------------- | ----------------------- |
| `Authorization`  | `Bearer <YOUR_API_KEY>` |
| `X-Workspace-Id` | Your workspace ID       |

See [Authentication & API Keys](https://docs.amigo.ai/developer-guide/platform-api/platform-api/authentication) for key lifecycle and rotation details.

## Available Tools

The MCP server exposes seven tools for exploring and querying workspace data.

### `sql_query`

Execute read-only `SELECT` queries against workspace tables. Results are limited to 1,000 rows with a 30-second timeout.

### `describe_query`

Returns the schema of a query result without executing it. Useful for understanding what columns a query will return before running it.

### `tables`

List available tables in the workspace schema. Supports an optional name filter to narrow results.

### `table_schema`

Returns column names and data types for a specific table.

### `sample_data`

Preview the first N rows of a table. Helpful for understanding data shape before writing queries.

### `table_detail`

Extended table metadata including properties, statistics, and partitioning information.

### `profile_column`

Statistical profile of a specific column - returns min, max, null count, distinct count, and value distribution.

## Connection

Data-MCP uses the **MCP Streamable HTTP** transport. The endpoint is stateless - no session affinity is required, and it works behind standard load balancers.

| Property      | Value                                  |
| ------------- | -------------------------------------- |
| **Endpoint**  | `https://api.platform.amigo.ai/v1/mcp` |
| **Transport** | Streamable HTTP                        |
| **Protocol**  | JSON-RPC 2.0                           |

Regional endpoints are also available - queries execute within the same region as the workspace data. See [Regions & Endpoints](https://docs.amigo.ai/developer-guide/getting-started/regions-and-endpoints#platform-api-regional-endpoints) for the full list of regional base URLs.

## Example

List available tables using a JSON-RPC request:

```bash
curl -X POST https://api.platform.amigo.ai/v1/mcp \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Workspace-Id: YOUR_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "tables",
      "arguments": {}
    },
    "id": 1
  }'
```

## Workspace Isolation

Queries are scoped to the authenticated workspace. There is no way to query another workspace's data, even with a valid API key for a different workspace. The `X-Workspace-Id` header and API key must belong to the same workspace.
