Skip to main content
Glama

Create DataLens saved SQL query

datalens_sqlqueries_create

Save a SQL query in a DataLens workbook and return it for reuse. Requires an enabled SQL editor; disabled editors return 403 SQL_EDITOR_NOT_ALLOWED.

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.

Input Schema

TableJSON 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.
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. Addedv0.122.1

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already declare readOnly=false, destructive=false, idempotent=false and openWorld=true. The description adds genuinely new behavioral context beyond those: the endpoint is experimental and unmeasured, and a specific failure mode with its error code. It could still say more about side effects on the workbook, but this is useful disclosure.

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 and followed by the caveat. The second sentence carries real signal (experimental status, 403 condition) rather than filler, though the "written from its document: not measured" phrasing is a bit meta.

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

Completeness4/5

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

With annotations covering the safety profile, a 100%-documented schema and no output schema, the description supplies the missing operational context (experimental status, auth/permission failure mode) and notes that the created query is returned. It is adequately complete for an agent to call it correctly.

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 is already documented in the schema and the baseline is 3. The description only indirectly touches workbook_id ("in a workbook") and adds nothing about query, params, connection_id or description, so it neither compensates nor detracts.

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?

The description gives a specific verb and resource ("Save a SQL query in a workbook") plus the return behavior, which cleanly separates it from datalens_sqlqueries_update, _run, _get and _delete. It stops short of explicitly naming a sibling it should not be confused with, so it is clear but not fully differentiated.

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?

It surfaces a real precondition — the tool fails with 403 SQL_EDITOR_NOT_ALLOWED when the organization's SQL editor is disabled — which implies when the tool is available. However it never states when to choose this over datalens_sqlqueries_update or datalens_sqlqueries_run, so usage is only implied.

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