Skip to main content
Glama
ianderso
by ianderso

query_records

Read-only

Query Gramps collections server-side with columns, filters, sorting, and relationship paths; filter events by type and audit family tree data.

Instructions

Query any collection server-side, with columns, filters and sorting.

More capable than query_objects and the tool to reach for on an audit. It reads indexed columns, reaches arbitrary paths inside the stored object, and follows relationships — so "families where the mother died before the father" or "events whose place is in Ohio" are single queries.

It is the only way to filter events by type. GrampsQL cannot: the word is shadowed, so type = "Birth" silently matches nothing. Pass event_type here instead.

Returns rows plus a total count and a next_after cursor. Private records, living people and families with a living parent come back as redacted stubs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNoCursor from a previous response's next_after, for paging past the first page.
limitNoMaximum rows (1-500).
whereNoConditions combined with AND. Each is {"column": <name or json_path>, "op": <op>, "value": ...}. Operators: eq, ne, lt, lte, gt, gte, like, regex, contains, in. Use "value_column" instead of "value" to compare two columns. A list value is for 'in' only; 'contains' finds one value in a list field. A date's year is dateval[2], 0 when unknown.
selectNoColumns to return. A plain column name, or {"json_path": [...], "as": "label"} to reach into the stored object. A path may cross a relationship: person->birth/death, family->father/mother, event->place. Omit for the default columns.
order_byNoSort keys, each {"column": ..., "direction": "asc" or "desc"}. json_path is not usable here.
event_typeNoEvents only. Filter by type name such as 'Birth' or 'Census'. Translated to the integer the tree stores, which is the only way event type is filterable at all.
where_exprNoAn expression instead of `where`, e.g. "surname == 'Smith'".
object_typeYesCollection to query: person, family, event, place, source, citation, repository, media, note, or tag.
include_privateNoShow living people and private records in full. Only when the user asks for them; they are withheld by default.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.2.0
    • changedInput schema / properties / where / description
      Previous value: -"Conditions combined with AND. Each is {\"column\": <name or json_path>, \"op\": <op>, \"value\": ...}. Operators: eq, ne, lt, lte, gt, gte, like, regex, contains, in. Use \"value_column\" instead of \"value\" to compare two columns."New value: +"Conditions combined with AND. Each is {\"column\": <name or json_path>, \"op\": <op>, \"value\": ...}. Operators: eq, ne, lt, lte, gt, gte, like, regex, contains, in. Use \"value_column\" instead of \"value\" to compare two columns. A list value is for 'in' only; 'contains' finds one value in a list field. A date's year is dateval[2], 0 when unknown."
  2. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Beyond the readOnlyHint/openWorldHint annotations, it discloses return shape (rows plus total count and a next_after cursor) and, critically, a privacy behavior: private records, living people, and families with a living parent come back as redacted stubs. That 'what gets withheld' detail is the sort of context annotations cannot carry and materially changes how results are interpreted.

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?

Front-loaded with the core purpose, then sibling comparison, then the event-type caveat, then return/redaction behavior — a logical descending-priority order. Bold emphasis marks the two decision-critical facts, and no sentence is padding.

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?

With 9 parameters, no output schema, and a read-only profile, the description covers everything an agent needs: capability scope, the filtering caveat, paging via next_after, default redaction, and the include_private override. Nothing required 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.

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; the description still adds value by explaining why event_type exists (event type is otherwise unfilterable) and framing what where/select can reach (arbitrary paths, relationship traversal such as family->father/mother). It stops short of adding format detail beyond the schema for the remaining params.

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 ('Query any collection server-side, with columns, filters and sorting') and immediately distinguishes itself from the sibling query_objects by declaring itself more capable. An agent can tell it apart from query_objects and get_object without opening a schema.

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?

Explicit when-to-use: 'the tool to reach for on an audit,' with the concrete alternative named (query_objects) and a hard routing rule for event filtering ('It is the only way to filter events by type'). It even explains why the alternative fails (GrampsQL shadows 'type'), which is exactly the kind of exclusion guidance that prevents wrong-tool selection.

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