Skip to main content
Glama

save_user_query

Save the queries an exploration already planned, so the request can be replayed instantly — exactly, or re-asked for other entities.

THE POINT: `explore_data_catalogue` is a full validate -> plan -> run pipeline that
re-authors the SQL from scratch on every call (~1-5 min, 20/hour). For a question
the user will ask AGAIN — a recurring check, a dashboard they watch, "my usual
semis screen" — save the tokens that exploration just produced. `run_saved_query`
then re-runs exactly those queries against live data in seconds, with no planning
step and no async job to poll. The backend ALSO authors a PLACEHOLDER twin of each
saved query (its ticker, CIK list, date, interval, and count lifted into typed
slots) plus a `metadata` slot schema naming them, so the same request can later be
re-asked for a different company, filer, or window:
`run_saved_query(query_placeholder, values={"symbol": "KSS"})`.

WHEN TO CALL: once an exploration is done and shown, offer it — say the request can
be re-run exactly or with different values — and save when the user says yes or
clearly implies they will want it again. Do NOT save every exploration by reflex,
and do not save a one-off.

Each query token is opaque ciphertext the server minted around the planned SQL.
NEVER write, guess, or edit one — a token this backend did not mint cannot be
decrypted and fails with 403 at replay time, long after the exploration is gone.

Owner-scoped: the row belongs to the calling user and is invisible to everyone
else. There is NO upsert (unlike `schedule_task`): saving the same request twice
creates a SECOND row. Check `list_saved_queries` first and `delete_saved_query` the
stale one rather than piling up near-duplicates.

Returns {"msg": "Successfully saved query: <user_request>", "id": <row id>,
"placeholder_status": "PENDING" | "NOT_DISPATCHED", "placeholder_id_to_poll"}. `id` is the delete key.
PENDING means the placeholder twins AND the row's `metadata` (its slot schema,
summary, and datasets) are being authored — roughly 10 s to 5 minutes, depending on
the size of the queries. Until they land, `query_placeholder` and `metadata` are
null in `list_saved_queries`, and an exact replay via `queries` works meanwhile.
NOT_DISPATCHED means no twins will be authored for this row: it can be replayed
exactly but not re-aimed.

Requires auth (your MCP client attaches the OAuth bearer automatically).
Rate-limited 100/min.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
query_tokensYesThe `query_token` of each exploration `results` entry, passed through EXACTLY as returned (a signed URL is unwrapped). Skip entries with no token. Never write SQL.
user_requestYesThe request being saved, in the user's own words — the row's only human-readable label, so make it specific ("weekly EPS-revision check on my semis basket").

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesSaved row id — the delete_saved_query key.
msgYes
placeholder_statusNoPENDING (twins + metadata being authored) or NOT_DISPATCHED.
placeholder_id_to_pollNoTask id of the placeholder-authoring job.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the annotations: owner-scoping, absence of upsert (duplicate saves create a second row), opaque-ciphertext tokens that fail with 403 if not server-minted, auth requirement, and a 100/min rate limit. It also explains the async placeholder authoring and the PENDING vs NOT_DISPATCHED states, which materially shapes call timing.

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?

Well front-loaded and organized with THE POINT / WHEN TO CALL headers, and nearly every sentence carries information. It is long, but the async-state and token-safety detail justify most of the length; a few clauses could still be tightened.

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?

Covers the full lifecycle an agent needs: what to save, when, what the backend does next, what the placeholder enables, duplicate handling, and the failure/async states. Nothing necessary for a correct call or a correct follow-up decision is missing.

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 the baseline is 3, but the description adds real meaning: tokens are opaque server-minted ciphertext that must pass through exactly and never be written or guessed, and user_request is the row's only human-readable label so it should be specific.

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 (save) and resource (the queries an exploration planned) plus the outcome (exact or re-aimed replay). It clearly distinguishes itself from explore_data_catalogue, run_saved_query, schedule_task, and list_saved_queries by name.

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?

An explicit WHEN TO CALL block says to offer it once an exploration is done and shown, save on confirmation, and explicitly says NOT to save every exploration or one-offs. It also routes to alternatives (list_saved_queries before saving, delete_saved_query for stale rows).

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources