MCP server
Use the RawTree MCP server from AI agents and MCP clients.
MCP server
Use the RawTree MCP server to give AI agents direct access to a RawTree project. Agents can query data, insert events, inspect tables, read RawTree logs, and manage project API keys through a standard MCP client.
What is an MCP server?
MCP is an open protocol for connecting AI applications to external tools and context. A RawTree MCP server exposes RawTree operations as tools that an agent can call from clients such as Claude Code, Codex, Cursor, Claude Desktop, or any MCP-compatible runtime.
What can RawTree's MCP server do?
The RawTree MCP server provides tools for common project workflows:
- Query — run read-only SQL and return rows, column metadata, query statistics, and hints.
- Ingest — insert JSON objects, arrays of JSON objects, or public URL data.
- Transforms — apply RawTree built-in transforms for OTLP traces, OTLP logs, OTLP metrics, CloudWatch Logs, CloudTrail, and Firehose JSON body inserts.
- Tables — list tables, describe columns and storage metadata, and delete tables when using an admin key.
- Logs — inspect RawTree query and insert logs with filters for time range, type, status, origin, table, and hints.
- API keys — list, create, and revoke project API keys when using an admin key.
- Project identity — return the current project and organization for the configured API key.
Prerequisites
Create a RawTree API key from the dashboard or CLI:
rtree key create --name mcp --permission read_writeUse the least permission that can complete the workflow:
| Task | Permission |
|---|---|
| Query data, inspect tables, and read logs | read_only |
| Insert and query data | read_write |
| Insert only | write_only |
| Manage API keys or delete tables | admin |
How to use the MCP server
The server supports two transport modes: stdio for local MCP clients and HTTP for remote or web-based integrations.
Replace rt_xxxxxxxxx with your RawTree API key.
Stdio transport
Use stdio when your MCP client launches the server as a local process.
Quick setup
npx add-mcp @rawtree/mcp --name rawtree --env "RAWTREE_API_KEY=rt_xxxxxxxxx"Claude Code
claude mcp add rawtree \
-e RAWTREE_API_KEY=rt_xxxxxxxxx \
-- npx -y @rawtree/mcpCodex
codex mcp add rawtree \
--env RAWTREE_API_KEY=rt_xxxxxxxxx \
-- npx -y @rawtree/mcpCursor
Open the command palette and choose "Cursor Settings" > "MCP" > "Add new global MCP server".
{
"mcpServers": {
"rawtree": {
"command": "npx",
"args": ["-y", "@rawtree/mcp"],
"env": {
"RAWTREE_API_KEY": "rt_xxxxxxxxx"
}
}
}
}Claude Desktop
Open Claude Desktop settings > "Developer" tab > "Edit Config".
{
"mcpServers": {
"rawtree": {
"command": "npx",
"args": ["-y", "@rawtree/mcp"],
"env": {
"RAWTREE_API_KEY": "rt_xxxxxxxxx"
}
}
}
}HTTP transport
Use HTTP when you want a long-running MCP endpoint. Each client authenticates by sending its RawTree API key in the Authorization header.
Start the server:
npx -y @rawtree/mcp --http --port 3000The server listens on http://127.0.0.1:3000 and exposes the MCP endpoint at /mcp using Streamable HTTP.
Claude Code
claude mcp add rawtree \
--transport http http://127.0.0.1:3000/mcp \
--header "Authorization: Bearer rt_xxxxxxxxx"Cursor
{
"mcpServers": {
"rawtree": {
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"Authorization": "Bearer rt_xxxxxxxxx"
}
}
}
}You can also set the HTTP port with MCP_PORT:
MCP_PORT=3000 npx -y @rawtree/mcp --httpOptions
| Option | Description |
|---|---|
--api-key <api-key> | RawTree API key for stdio mode. |
--http | Use HTTP transport instead of stdio. |
--port <number> | HTTP port when using --http. Defaults to 3000 or MCP_PORT. |
Environment variables:
| Variable | Description |
|---|---|
RAWTREE_API_KEY | RawTree API key. |
MCP_PORT | HTTP port when using --http. |
Public configuration is limited to RawTree API keys and the MCP HTTP port.
Tools
Data
check-health— Check that the RawTree API endpoint is reachable.run-query— Run read-only SQL and return RawTree's JSON query response.insert-json— Insert one JSON object or an array of JSON objects into a table.insert-from-url— Ingest data from a public URL and return RawTree's NDJSON progress stream.
Tables
list-tables— List tables in the configured project.describe-table— Inspect table columns, row count, byte count, project, and organization.delete-table— Delete a table after explicit confirmation. Requiresadminpermission.
Logs
list-logs— Read RawTree insert and query logs. Defaults to the last hour when no time window is provided.
Example log filter:
{
"statuses": ["error"],
"types": ["insert"],
"tables": ["events"],
"origins": ["api"],
"hints": "any",
"limit": 50
}API keys
list-api-keys— List API keys for the configured project. Requiresadminpermission.create-api-key— Create a key withadmin,read_write,write_only, orread_onlypermission.delete-api-key— Revoke a key after explicit confirmation.
Project
get_project— Return the current project as{ "name": "...", "organization": { "name": "..." } }.
Local development
Clone the server and build it:
git clone https://github.com/rawtreedb/rawtree-mcp.git
cd rawtree-mcp
pnpm install
pnpm buildUse the local build from an MCP client:
claude mcp add rawtree \
-e RAWTREE_API_KEY=rt_xxxxxxxxx \
-- node /absolute/path/to/rawtree-mcp/dist/index.jsFor HTTP mode:
node /absolute/path/to/rawtree-mcp/dist/index.js --http --port 3000Then configure your client with http://127.0.0.1:3000/mcp and an Authorization: Bearer rt_xxxxxxxxx header.
Testing with MCP Inspector
Build the project first:
pnpm buildStdio
Set your API key:
export RAWTREE_API_KEY=rt_xxxxxxxxxStart the inspector:
pnpm inspectorIn the Inspector UI:
- Choose stdio.
- Command:
node. - Args:
dist/index.js. - Env:
RAWTREE_API_KEY=rt_xxxxxxxxx. - Connect, then use "List tools" to verify the server.
HTTP
Start the HTTP server:
node dist/index.js --http --port 3000Start the inspector in another terminal:
pnpm inspectorIn the Inspector UI:
- Choose Streamable HTTP.
- URL:
http://127.0.0.1:3000/mcp. - Add
Authorization: Bearer rt_xxxxxxxxxas a custom header. - Connect, then use "List tools" to verify the server.