Skip to main content
Glama
RawTree MCP Server

RawTree MCP Server

Official
by rawtreedb

Run Query

run-query
Destructive

Execute one supported SQL statement through RawTree’s Query API to run reads or authorized writes, including data changes, table configuration, and access-control management.

Instructions

Execute one SQL statement through RawTree's Query API. Supports reads and the writes below; this tool can change data, table configuration, and access controls. Use the existing connection with sufficient permission; supported writes do not require a browser login or a different execution surface.

Supported statements and permissions:

  • SELECT, WITH, EXPLAIN, DESCRIBE: read_only, read_write, or admin API key, or a signed-in session. Database-role keys support reads subject to their database grants; they cannot execute the write families below. write_only keys can only TRUNCATE through this endpoint.

  • INSERT INTO [(columns)] SELECT ... (including a WITH source): read_write/admin or a signed-in session. The target must already exist in the selected user database. VALUES, FORMAT, and url()/urlCluster() sources are unsupported; use insert-json or insert-from-url for ingestion.

  • INSERT INTO FUNCTION s3(...) SELECT ... (including a WITH source): read_write/admin or a signed-in session, with a selected user database. Exports query results to S3; only the unqualified s3 function is supported as a function destination. No VALUES, FORMAT, or url()/urlCluster() sources, including nested function arguments.

  • TRUNCATE TABLE [IF EXISTS] [database.] [SYNC]: write_only/read_write/admin or a signed-in session with write permission. One table in the selected user database; removes all rows but preserves table configuration. Always waits for replicas; no ON CLUSTER or partition clauses.

  • SELECT ... CACHE INTO [database.]view [EVERY|AFTER interval] [TTL interval [FROM LAST READ]]: admin API key or a signed-in session (table-create permission). Cache destinations must be in the selected user database; intervals use numeric literal/unit pairs. No url()/urlCluster() sources.

  • CREATE TABLE [IF NOT EXISTS] ENGINE = ReplicatedRawMergeTree [ORDER BY ] [TTL [DELETE [WHERE ]]] [SETTINGS name = value, ...]: admin API key or a signed-in session, in the selected user database. Optional ON CLUSTER 'default'; no column definitions, engine arguments, other engines, or AS SELECT. TTL supports row deletion only; TTL and settings reject subqueries.

  • ALTER TABLE MODIFY ORDER BY ; MODIFY TTL [DELETE [WHERE ]]; MODIFY SETTING name = value, ...; RESET SETTING name, ...; ADD/MATERIALIZE/CLEAR/DROP PROJECTION; ADD/MATERIALIZE/CLEAR/DROP INDEX (including text indexes): admin API key or a signed-in session. One operation per statement, on a table in the selected user database; no ON CLUSTER or IN PARTITION. TTL supports row deletion only; TTL and settings reject subqueries. Settings use engine-supported names. ADD accepts IF NOT EXISTS; MATERIALIZE/CLEAR/DROP accept IF EXISTS. ADD INDEX requires an expression and TYPE, optionally positive integer GRANULARITY; AFTER is unsupported. Use storage paths such as __raw_data.field in index/projection definitions, with casts as needed.

  • KILL MUTATION WHERE table = '' [AND mutation_id = '']: admin API key or a signed-in session. The backend applies the selected user database automatically. Only these equality filters are supported; use doubled quotes, not backslash escapes, in string values.

  • CREATE ROLE , DROP ROLE [IF EXISTS] , GRANT SELECT/INSERT [(columns)] ON . TO : admin API key or organization administrator session. Grants can combine SELECT and INSERT and use database.* or .; the target must be an existing role, not a user. No role inheritance, delegation options, or REVOKE.

  • CREATE [OR REPLACE] WORKLOAD/RESOURCE, CREATE WORKLOAD/RESOURCE IF NOT EXISTS, DROP WORKLOAD/RESOURCE [IF EXISTS]: admin API key or organization administrator session. Workloads support IN and literal SETTINGS; resources support MASTER/WORKER THREAD and READ/WRITE DISK or ANY DISK operations.

  • CREATE SETTINGS PROFILE [OR REPLACE | IF NOT EXISTS], DROP SETTINGS PROFILE [IF EXISTS]: admin API key or organization administrator session. Only workload = '' and use_concurrency_control = 0/1, optionally READONLY/CONST, assigned TO 1–32 distinct existing roles.

  • CREATE ROW POLICY [OR REPLACE | IF NOT EXISTS], DROP ROW POLICY [IF EXISTS]: admin API key or organization administrator session. One table in the selected user database; SELECT USING a scalar filter, optional AS PERMISSIVE/RESTRICTIVE, TO 1–32 distinct existing roles. No subqueries, user targets, or wildcard targets.

  • CREATE NAMED COLLECTION [IF NOT EXISTS] AS key = literal, ...: admin API key or organization administrator session. Unique keys with string/numeric/boolean values and optional OVERRIDABLE/NOT OVERRIDABLE; no ALTER or DROP.

  • CREATE HANDLER [IF NOT EXISTS] URL '/path' [METHODS (GET)] AS SELECT ..., ALTER HANDLER URL '/path' [METHODS (GET)] AS SELECT ..., DROP HANDLER [IF EXISTS] : admin API key or organization administrator session, with a selected cluster and database. Exact paths and read-only SELECT queries only; no URL REGEXP, other methods, or url()/urlCluster() sources. SQL executes as submitted; optional ON CLUSTER 'default' follows the name and is never added automatically. Handler parameters cannot use Platform database or execution setting names.

Role, workload/resource, profile, policy, and named-collection management accept optional ON CLUSTER 'default' and preserve the engine's replication semantics; row policies with ON CLUSTER require an explicit matching database.table. These management operations and handlers can affect the cluster beyond the selected database. All write families, including handler DDL, are unavailable in RawTree's internal organization. Mutations outside the listed forms, including UPDATE, standalone DELETE, DROP TABLE, and other ALTER operations, are unsupported; use delete-table for table deletion.

Returns JSON meta, data, rows, statistics, and optional hints. DDL normally returns an empty result; handler DDL returns empty meta/data and rows: 0, with statistics. INSERT SELECT reports statistics.written_rows; KILL MUTATION returns matched mutations. MATERIALIZE/CLEAR run in the background: inspect system.mutations for progress and system.projections or system.data_skipping_indices for definitions. Repeating writes may duplicate data or change state; inspect results before retrying. For exploratory reads, use LIMIT and deterministic ORDER BY.

Detailed syntax and replication limits: https://rawtree.com/docs/reference/api, https://rawtree.com/docs/reference/api/query#sql-defined-http-endpoints, and https://rawtree.com/docs/reference/authentication#existing-database-roles.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sql": "<sql>"
    },
    "name": "run-query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesOne supported SQL statement to execute: a read query or an authorized INSERT SELECT, CREATE TABLE, ALTER TABLE, KILL MUTATION, or management statement listed in the tool description. Writes can change persistent state. Use LIMIT for exploratory reads.
clusterNoName or ID of the cluster to use for this operation.
databaseNoOptional RawTree database override. RawTree uses the default database when omitted.
organizationNoName or ID of the organization containing the target cluster.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.4.10
    • changedInput schema / properties / cluster / description
      Previous value: -"RawTree cluster to use for this operation."New value: +"Name or ID of the cluster to use for this operation."
    • changedInput schema / properties / organization / description
      Previous value: -"RawTree organization containing the target cluster."New value: +"Name or ID of the organization containing the target cluster."
  2. Changed1 schema field changedv0.4.3
    • changedInput schema / properties / sql / description
      Previous value: -"Read-only SQL to execute. Prefer bounded SELECT queries with LIMIT for exploration."New value: +"One supported SQL statement to execute: a read query or an authorized INSERT SELECT, CREATE TABLE, ALTER TABLE, KILL MUTATION, or management statement listed in the tool description. Writes can change persistent state. Use LIMIT for exploratory reads."
  3. Changed4 schema fields changedv0.3.2
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / properties / cluster
      Added value: +{
      +  "description": "RawTree cluster to use for this operation.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / database
      Added value: +{
      +  "description": "Optional RawTree database override. RawTree uses the default database when omitted.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / organization
      Added value: +{
      +  "description": "RawTree organization containing the target cluster.",
      +  "minLength": 1,
      +  "type": "string"
      +}
  4. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already mark the tool as non-read-only, destructive, and non-idempotent; the description adds substantial context beyond that, including permission requirements, side effects, DDL return behavior, background materialization caveats, and retry duplication risks. It does not contradict the annotations and materially improves safe invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core action and risk, then structured into readable statement-family bullets. It is very long, but given the destructive SQL surface area most content is relevant; a few details could have been left to linked documentation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having no output schema, the description explains returned fields, DDL behavior, statistics, and mutation tracking. It covers permissions, supported and unsupported statements, side effects, and retry cautions, which is complete enough for this complex destructive tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so parameter basics are already documented. The description adds meaningful semantics for the sql parameter by defining supported statement families and authorization constraints that affect how the SQL string can be formed, though it says less about cluster, database, and organization parameters beyond selected database/cluster context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: execute one SQL statement through RawTree's Query API, with reads and explicitly listed writes. It distinguishes scope from siblings by naming insert-json and insert-from-url for ingestion and delete-table for table deletion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use and when-not-to-use guidance across statement families, including permissions, unsupported forms, and alternative tools for ingestion and deletion. The guidance is unusually complete for a high-risk SQL execution tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.