Treasure Data MCP Server

by treasure-data

Not rated
GitHub

About

Enables AI assistants to securely query and interact with the Treasure Data customer data platform.

Details

Author
treasure-data
Categories
Database, Other

Setup

Install Treasure Data MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/treasure-data/td-mcp-server

Follow the installation instructions in the repository README, then restart your MCP client.

MCP (Model Context Protocol) server for Treasure Data, enabling AI assistants to query and interact with Treasure Data through a secure, controlled interface.

This MCP server is currently in a public preview. We're excited for you to try it out and welcome your feedback to help us improve the service.

Please note:During this preview period, use of the server is free. However, we plan to introduce a usage-based pricing model in the future, which will be based on the number of queries issued. We will provide ample notice and detailed pricing information before any charges are implemented.

Your feedback during this phase is invaluable and will help us shape the future of this tool. Thank you for being an early adopter!

- πŸ” Query databases, tables, and schemas through information_schema
- πŸ“Š Execute SQL queries with automatic result limiting for LLM contexts
- πŸ”’ Security-first design with read-only mode by default
- 🌍 Multi-site support (US, JP, EU, AP regions)
- πŸš€ Zero-install execution via npx
- 🎯 CDP (Customer Data Platform) integration for segment and activation management (Experimental)
- πŸ”„ Workflow monitoring and control - view execution status, logs, and retry failed workflows
- πŸ“ Comprehensive audit logging for all operations

This MCP server requires Node.js version 18.0.0 or higher. If you don't have Node.js installed:

- Choose the LTS (Long Term Support) version
- The installer includesnpmandnpx

node --version # Should show v18.0.0 or higher npx --version # Included with npm 5.2+

- Alternative installation methods:

- macOS:brew install node(using Homebrew)
- Windows: Use the installer from nodejs.org orwinget install OpenJS.NodeJS
- Linux: Use your distribution's package manager orNodeSource repositories

No installation needed! Configure your MCP tool to run@treasuredata/mcp-serverdirectly vianpx:

What is npx?npx is a package runner that comes with npm 5.2+. It downloads and runs packages without installing them globally, ensuring you always use the latest version.

If you prefer a traditional installation:

Add to your MCP client configuration (e.g., Claude Desktop):

{ "mcpServers": { "treasuredata": { "command": "npx", "args": ["@treasuredata/mcp-server"], "env": { "TD_API_KEY": "your_api_key", "TD_SITE": "us01", "TD_ENABLE_UPDATES": "false", "TD_DATABASE": "sample_datasets" } } } }

- TD_API_KEY(required): Your Treasure Data API key
- TD_SITE(optional): Region endpoint -us01(default),jp01,eu01,ap02,ap03,dev
- TD_ENABLE_UPDATES(optional): Enable write operations (execute tool) -false(default),true
- TD_DATABASE(optional): Default database for queries (e.g.,sample_datasets)

Claude Codeprovides built-in support for MCP servers through theclaude mcp addcommand. To use this MCP server with Claude Code:

claude mcp add td -e TD_API_KEY=$TD_API_KEY -- npx @treasuredata/mcp-server

- Adds the server with the name "td"
- Sets the TD_API_KEY environment variable to your API key value
- Configures Claude Code to usenpx @treasuredata/mcp-server(always uses latest version)

You can also specify additional environment variables:

claude mcp add td \ -e TD_API_KEY=$TD_API_KEY \ -e TD_SITE=us01 \ -e TD_DATABASE=sample_datasets \ -- npx @treasuredata/mcp-server

Once configured, Claude Code will automatically have access to all the tools described below for querying and analyzing your Treasure Data.

List all databases in your Treasure Data account.

{ "name": "list_databases", "arguments": {} }

- database(string, optional): Database name. If omitted, uses the current database context (TD_DATABASE or last used database)

{ "name": "list_tables", "arguments": { "database": "sample_datasets" } }
{ "name": "list_tables", "arguments": {} }

Get schema information for a specific table.

- database(string, optional): Database name. If omitted, uses the current database context (TD_DATABASE or last used database)
- table(string, required): Table name

{ "name": "describe_table", "arguments": { "database": "sample_datasets", "table": "www_access" } }
{ "name": "describe_table", "arguments": { "table": "www_access" } }

Execute read-only SQL queries (SELECT, SHOW, DESCRIBE).

- sql(string, required): SQL query to execute
- limit(number, optional): Max rows (default: 40, max: 10000)

Performance Tip:For tables with atimecolumn, usetd_interval()ortd_time_range()to limit the time range:

- td_interval(time, '-30d/now')- Last 30 days
- td_interval(time, '-7d/now')- Last 7 days
- td_interval(time, '-1d')- Yesterday only
- td_interval(time, '-1h/now')- Last hour
- td_time_range(time, '2024-01-01', '2024-01-31')- Specific date range

{ "name": "query", "arguments": { "sql": "SELECT method, COUNT() as count FROM www_access GROUP BY method", "limit": 10 } }
{ "name": "query", "arguments": { "sql": "SELECT method, COUNT() as count FROM www_access WHERE td_interval(time, '-7d/now') GROUP BY method", "limit": 10 } }

Execute write operations (UPDATE, INSERT, DELETE, etc.) - requiresTD_ENABLE_UPDATES=true.

- sql(string, required): SQL statement to execute

{ "name": "execute", "arguments": { "sql": "INSERT INTO events (timestamp, event_type) VALUES (NOW(), 'test')" } }

Switch the current database context for subsequent queries.

- database(string, required): Database to switch to

{ "name": "use_database", "arguments": { "database": "production_logs" } }

After switching, all queries will use the new database by default unless explicitly specified.

Get the current database context being used for queries.

{ "name": "current_database", "arguments": {} }
{ "currentDatabase": "sample_datasets", "description": "The current database context used for queries" }

CDP Tools (Customer Data Platform) - EXPERIMENTAL

Note:CDP tools are currently experimental and may not cover all use cases. Additional functionality will be added based on user feedback.

The following tools are available for interacting with Treasure Data's Customer Data Platform (CDP):

List all parent segments in your CDP account.

{ "name": "list_parent_segments", "arguments": {} }

Get details of a specific parent segment.

- parent_segment_id(integer, required): The ID of the parent segment

{ "name": "get_parent_segment", "arguments": { "parent_segment_id": 12345 } }

List all segments under a specific parent segment.

- parent_segment_id(integer, required): The ID of the parent segment

{ "name": "list_segments", "arguments": { "parent_segment_id": 12345 } }

List all activations (syndications) for a specific segment.

- parent_segment_id(integer, required): The ID of the parent segment
- segment_id(integer, required): The ID of the segment

{ "name": "list_activations", "arguments": { "parent_segment_id": 12345, "segment_id": 67890 } }

Get detailed information about a specific segment, including its rules and metadata.

- parent_segment_id(integer, required): The parent segment ID
- segment_id(integer, required): The segment ID

{ "name": "get_segment", "arguments": { "parent_segment_id": 287197, "segment_id": 1536120 } }

Get the SQL statement for a parent segment.

- parent_segment_id(integer, required): The parent segment ID

{ "name": "parent_segment_sql", "arguments": { "parent_segment_id": 287197 } }
select a. from "cdp_audience_287197"."customers" a

Get the SQL statement for a segment with filtering conditions applied to the parent segment.

- parent_segment_id(integer, required): The parent segment ID
- segment_id(integer, required): The segment ID

{ "name": "segment_sql", "arguments": { "parent_segment_id": 287197, "segment_id": 1536120 } }
select a. from "cdp_audience_287197"."customers" a where ( (position('Male' in a."gender") > 0) )

Workflow Tools (Experimental) - Monitor and Control Digdag Workflows

Note: These workflow tools are experimental and provide detailed access to workflow sessions, attempts, and tasks. They are subject to change in future releases.

The following tools are available for monitoring and controlling Digdag workflows. These tools integrate with Treasure Data's workflow engine based onDigdag:

- limit(number, optional): Maximum results (default: 100)
- last_id(string, optional): Pagination cursor

{ "name": "list_projects", "arguments": { "limit": 50 } }

List workflows, optionally filtered by project name.

- project_name(string, optional): Project name to filter by
- limit(number, optional): Maximum results (default: 100)
- last_id(string, optional): Pagination cursor

// List all workflows { "name": "list_workflows", "arguments": { "limit": 50 } } // List workflows in a specific project { "name": "list_workflows", "arguments": { "project_name": "my_project", "limit": 50 } }
No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.