Skip to main content
Glama

Create DataLens saved SQL query

datalens_sqlqueries_create

Save a named SQL query to a DataLens workbook and return it, with a chosen connection, optional parameters, and description.

Instructions

Save a SQL query in a workbook and return it.

Experimental in the DataLens API and written from its document: not measured. An organization whose SQL editor is off answers 403 SQL_EDITOR_NOT_ALLOWED.

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": {
      "workbook_id": "<workbook_id>",
      "name": "<name>",
      "connection_id": "<connection_id>",
      "query": "<query>"
    },
    "name": "datalens_sqlqueries_create"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesThe query's name in the workbook.
queryYesThe text of the query.
paramsNoThe parameters the text takes: a name, a type and a default each.
dry_runNoSend nothing: answer `{dry_run: true, request}`, the first write the tool would make (null: none).
descriptionNoA description.
workbook_idYesThe workbook to keep it in.
connection_idYesThe connection it runs over: PostgreSQL, ClickHouse, MySQL, Greenplum, Trino.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.142.2
    • addedInput schema / properties / dry_run
      Added value: +{
      +  "default": false,
      +  "description": "Send nothing: answer `{dry_run: true, request}`, the first write the tool would make (null: none).",
      +  "type": "boolean"
      +}
  2. Addedv0.122.1

TDQS

A3.6/5.0
Behavior4/5

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

Goes beyond the annotations meaningfully: it discloses that the endpoint is experimental and 'not measured' in the DataLens API surface, and names a specific failure mode with its error code (403 SQL_EDITOR_NOT_ALLOWED). Annotations already cover the safety profile (readOnly=false, destructive=false, idempotent=false), so this added operational context earns credit.

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?

Two short sentences, front-loaded with the action, followed by the caveat and error condition. Nothing is redundant, though the phrase 'written from its document: not measured' is slightly awkward phrasing that could be tightened.

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

Completeness3/5

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

For a 7-parameter write tool with no output schema, the definition covers the action and one failure mode but says little about the return value beyond 'return it', and does not mention whether the query text is validated or executed on save. Adequate but with clear gaps for an agent deciding how to handle the response.

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

Parameters3/5

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

Schema description coverage is 100%, so every parameter including params, dry_run and connection_id is already documented in the schema. The description adds no syntax, format, or constraint detail beyond what the schema provides, so the baseline 3 applies.

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

Purpose4/5

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

States a specific verb and resource: 'Save a SQL query in a workbook and return it.' The create-versus-update boundary is implied by the name and the workbook_id requirement, but no sibling such as datalens_sqlqueries_update or datalens_sqlqueries_run is named for differentiation.

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

Usage Guidelines3/5

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

Gives one concrete precondition for use: an organization with the SQL editor disabled answers 403 SQL_EDITOR_NOT_ALLOWED. It does not say when to prefer this over datalens_sqlqueries_update (modify an existing query) or datalens_sqlqueries_run (execute), so the when-not guidance is left to inference.

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

Deploy Server

Other Tools