Skip to main content
Glama

query_memories_with_sql

Read-onlyIdempotent

Run a read-only SQL query against the memory database.

Use this when the user wants exact counts, aggregates, or table-level facts
that a semantic search cannot give. Do not use it to change data: SELECT and
WITH statements only.

Read-only. Access control is applied by the server, so rows outside the
caller's permissions never appear. A LIMIT and a statement timeout are
applied automatically.

Args:
    sql: A SELECT or WITH statement. `describe_memory_schema` returns the
        table and column names to write it against.
    max_rows: Automatic LIMIT cap, preserved when the query already sets
        one. Default 10000.
    timeout_ms: Postgres statement timeout in milliseconds. Default 5000.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesA SELECT or WITH statement. `describe_memory_schema` returns the table and column names to write it against.
max_rowsNoAutomatic LIMIT cap, preserved when the query already sets one. Default 10000.
timeout_msNoPostgres statement timeout in milliseconds. Default 5000.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the safety profile is covered. The description adds valuable behavioral context beyond annotations: access control is applied server-side so restricted rows never appear, and a LIMIT plus statement timeout are automatically applied. This gives the agent important expectations about execution behavior.

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

Conciseness5/5

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

The description is well-structured and front-loaded: the core purpose is in the first sentence, usage guidance follows, and parameter details are cleanly listed. Every sentence earns its place, and the format is scannable for an agent.

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?

The description is complete for a read-only query tool. It covers when to use it, what it cannot do, safety behavior, access control, automatic limits, and how to discover the schema. The output schema exists, so return values need no explanation. Nothing an agent needs to call it correctly is missing.

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 the schema already documents all three parameters. The description repeats the parameter details but adds the context that describe_memory_schema provides the table/column names to write the query against. This is useful but not a major addition beyond the schema, so baseline 3 is appropriate.

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?

The description states a specific verb ('Run a read-only SQL query') and resource ('the memory database'), and explicitly distinguishes itself from semantic search by noting it is for exact counts, aggregates, or table-level facts. This clearly differentiates it from siblings like search_memory and find_memories_by_entity.

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?

The description explicitly says when to use it ('when the user wants exact counts, aggregates, or table-level facts that a semantic search cannot give') and when not to use it ('Do not use it to change data'). It also references describe_memory_schema as the way to get table/column names, providing clear guidance for correct invocation.

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.