# Getting Started for AI Agents

The Treasure Data documentation and platform are accessible through **Claude Code** and other MCP-compatible AI tools via the Model Context Protocol (MCP). This allows AI assistants to access documentation and interact with your Treasure Data environment directly.

## Benefits

- **Real-time documentation access**: AI assistants receive accurate, contextual help about Treasure Data products and features.
- **Platform interaction**: AI assistants can query databases, manage segments, run workflows, and more.
- **Dynamic API guidance**: AI assistants can extract and explain API reference content based on user needs.


## Ask AI (Documentation Assistant)

The Treasure Data documentation site includes a built-in AI assistant that can answer questions about products, features, and APIs directly from the documentation.

### How to Use

1. Click the **Ask AI** button in the bottom-right corner of any documentation page.
2. Type your question in natural language.
3. The AI assistant searches the documentation and provides relevant answers with source links.


You can also access Ask AI through the **Search** modal in the top navigation bar.

### What You Can Ask

The AI assistant indexes and searches all documentation content:

- **Product guides**: Complete documentation for all Treasure Data products
- **API references**: OpenAPI specifications and endpoint details
- **Integration guides**: Setup instructions for data sources and destinations
- **Best practices**: Implementation patterns and recommendations


### Example Questions


```
How do I set up a Parent Segment?
What integrations are available in Integration Hub?
How does Real-Time ID Stitching work?
What are the differences between Trino and Hive?
How do I create a customer journey?
```

The AI assistant provides answers based on the latest documentation content, with links to the relevant pages for more details.

## MCP Servers

For developers and AI tools, Treasure Data provides two MCP servers for different use cases:

| MCP Server | Purpose | What You Can Do |
|  --- | --- | --- |
| **TD Docs MCP** | Documentation search | Ask questions about Treasure Data products and features |
| **tdx MCP** | Platform interaction | Query databases, manage segments, run workflows, and more |


## TD Docs MCP Server

Use the TD Docs MCP server to explore documentation and discover APIs.

The server is registered at: `https://docs.treasuredata.com/mcp`

### Available Tools

#### Documentation Tools

| Tool | Parameters | Description |
|  --- | --- | --- |
| `list-apis` | `name?: string` | Lists available APIs with their context and purpose. |
| `get-endpoints` | `name: string` | Returns all endpoints and their descriptions for a specific API. |
| `get-endpoint-info` | `name: string`, `path: string`, `method: string` | Returns comprehensive information about a specific endpoint, including parameters, security, and examples. |
| `get-security-schemes` | `name: string` | Gets the security schemes for a specific API. |
| `get-full-api-description` | `name: string` | Returns the complete OpenAPI description. |


#### Search Tools

| Tool | Parameters | Description |
|  --- | --- | --- |
| `search` | `query: string` | Searches documentation and returns relevant content for a query. |


### Use the MCP Server

Users can connect their preferred AI tools that support MCP (for example, Cursor, Claude Code, and VS Code) to the TD Docs MCP server.

1. Copy the MCP server URL: `https://docs.treasuredata.com/mcp`
2. Add it to your tool using the instructions below.


After connecting, the tool can access Treasure Data documentation and API references.

Cursor
#### Connect Cursor to the MCP Server

1. In Cursor, open the command palette.
  - macOS: `Command + Shift + P`
  - Windows/Linux: `Ctrl + Shift + P`
2. Type "Open MCP settings" in the command palette.
3. Select "Add custom MCP".


Cursor opens the `mcp.json` file.

#### Configure the MCP Server

1. In `mcp.json`, add the server configuration:



```json
{
  "mcpServers": {
    "td-docs": {
      "url": "https://docs.treasuredata.com/mcp"
    }
  }
}
```

1. Save the `mcp.json` file.
2. Return to MCP settings and confirm the connection.


After connecting, Cursor displays the list of available tools.

#### Test the Cursor Connection

In Cursor chat (Agent mode), ask a question that triggers an MCP tool:


```
How do I configure Real-Time ID Stitching?
```

Claude Code
#### Connect Claude Code to the MCP Server

1. Run the following command:



```bash
claude mcp add td-docs https://docs.treasuredata.com/mcp --transport http
```

1. In the Claude Code CLI, type `/mcp` to verify the connection.
2. Claude Code lists the available tools with descriptions and parameters.


#### Test the Claude Code Connection

In the Claude Code CLI, ask a question that uses an MCP tool:


```
What are the best practices for creating Parent Segments?
```

VS Code
#### Connect VS Code to the MCP Server

1. In VS Code, open the command palette.
  - macOS: `Command + Shift + P`
  - Windows/Linux: `Ctrl + Shift + P`
2. Type "MCP: Add Server" in the command palette.
3. Select "HTTP" to connect to a remote MCP server.
4. Enter the MCP server URL: `https://docs.treasuredata.com/mcp`
5. Enter a name for the connection (e.g., `td-docs`).


#### Test the VS Code Connection

Open Chat with AI in Agent mode and select the Tools icon.
Confirm that your MCP connection appears with a list of available tools.

Ask the AI to perform a query that uses an MCP tool:


```
Show me the API specification for the Personalization API
```

## tdx MCP Server

The [tdx CLI](/treasure-code/) provides an MCP server that enables AI tools to interact with your Treasure Data environment directly.

### Setup

First, install and authenticate tdx:


```bash
# Install tdx
npm install -g @treasuredata/tdx

# Authenticate
tdx auth setup
```

### Available Tools

| Tool | Parameters | Description |
|  --- | --- | --- |
| `tdx_run` | `args: string[]` | Execute any tdx CLI command. Returns JSON output. |
| `tdx_search` | `query: string`, `category?: string` | Search for relevant tdx commands based on what you want to do. |


**Categories for tdx_search:** Data, CDP, AI, Context, Utilities

### Use the MCP Server

Cursor
#### Connect Cursor to the tdx MCP Server

1. In Cursor, open the command palette (`Command + Shift + P` or `Ctrl + Shift + P`).
2. Type "Open MCP settings" and select "Add custom MCP".


#### Configure the MCP Server

In `mcp.json`, add the tdx server configuration:


```json
{
  "mcpServers": {
    "tdx": {
      "command": "tdx",
      "args": ["mcp"]
    }
  }
}
```

Without global install (using npx):


```json
{
  "mcpServers": {
    "tdx": {
      "command": "npx",
      "args": ["@treasuredata/tdx", "mcp"]
    }
  }
}
```

To use a specific profile:


```json
{
  "mcpServers": {
    "tdx": {
      "command": "tdx",
      "args": ["mcp"],
      "env": {
        "TDX_PROFILE": "my-profile"
      }
    }
  }
}
```

Claude Desktop
#### Connect Claude Desktop to the tdx MCP Server

Open your Claude Desktop configuration file:
Add the tdx server configuration:


```json
{
  "mcpServers": {
    "tdx": {
      "command": "tdx",
      "args": ["mcp"]
    }
  }
}
```

Without global install (using npx):


```json
{
  "mcpServers": {
    "tdx": {
      "command": "npx",
      "args": ["@treasuredata/tdx", "mcp"]
    }
  }
}
```

Windsurf
#### Connect Windsurf to the tdx MCP Server

Open your Windsurf MCP configuration file at `~/.windsurf/mcp.json`.

Add the tdx server configuration:


```json
{
  "mcpServers": {
    "tdx": {
      "command": "tdx",
      "args": ["mcp"]
    }
  }
}
```

Without global install (using npx):


```json
{
  "mcpServers": {
    "tdx": {
      "command": "npx",
      "args": ["@treasuredata/tdx", "mcp"]
    }
  }
}
```

### Example Conversation

Once configured, you can have conversations like:


```
> What databases are available in Treasure Data?

AI uses tdx_run with args: ["databases"]

> Show me the schema for the users table in mydb

AI uses tdx_run with args: ["describe", "mydb.users"]

> Run a query to find the top 10 users by order count

AI uses tdx_run with args: ["query", "SELECT user_id, COUNT(*) as orders
  FROM mydb.orders GROUP BY user_id ORDER BY orders DESC LIMIT 10"]

> Create a segment for users who made a purchase in the last 30 days

AI uses tdx_search to find segment commands, then tdx_run to create the segment
```

## tdx claude: All-in-One Setup

For Treasure Data customers, the easiest way to get started is using `tdx claude`, which provides:

- **TD LLM Proxy integration**: Use your existing [AI Suite credits](https://www.treasuredata.com/terms/ai-suite-credits-definition/)
- **Pre-configured TD Skills**: Enhanced capabilities for SQL, workflows, and CDP operations
- **Documentation search**: Built-in access to TD documentation


### Quick Start


```bash
# Install tdx and Claude Code
npm install -g @treasuredata/tdx
curl -fsSL https://claude.ai/install.sh | bash

# Authenticate with Treasure Data
tdx auth setup

# Launch Claude Code with TD integration
tdx claude
```

### Example Conversations

Once inside Claude Code via `tdx claude`:


```
> How to set up data ingestion to TD from Snowflake?

> Analyze mydb.user_events data

> Write a workflow to periodically import data from S3

> Create a SQL query to find top customers by revenue

> Build a user segment for customers who purchased in the last 30 days
```

## TD Skills for Enhanced AI Assistance

[TD Skills](/treasure-code/guide/td-skills) are pre-built Claude Code plugins that enhance AI assistance for Treasure Data workflows:

| Skill Category | What It Helps With |
|  --- | --- |
| **SQL Skills** | Trino/Hive syntax, TD-specific functions, query optimization |
| **Workflow Skills** | Digdag workflows, scheduling, dbt integration |
| **tdx Skills** | Segments, journeys, activations, AI agents |


All TD Skills are automatically available when using `tdx claude`.

## Learn More

- [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) - Learn more about MCP
- [tdx CLI Documentation](/treasure-code/) - Complete tdx reference
- [tdx MCP Command](/treasure-code/commands/mcp) - Detailed MCP server documentation
- [tdx claude Command](/treasure-code/commands/claude) - Claude Code integration guide
- [TD Skills](/treasure-code/guide/td-skills) - Pre-built AI skills for Treasure Data
- [Product Documentation](/products) - Browse all Treasure Data products