Skip to main content
Glama

Flecs Query

flecs_query
Read-onlyIdempotent

Find entities in a running FLECS ECS world using FLECS query syntax, returning matches with optional component values, fields, and paging.

Instructions

[READ] Find entities with a query written in the FLECS query language.

Syntax cheat sheet (terms are comma separated and all must match):

  • 'Position, Velocity' entities with both components

  • 'Position, !Velocity' ... without Velocity

  • 'Position, ?Mass' Mass is optional

  • 'Planet || Moon' either tag

  • '(ChildOf, Sun)' children of entity Sun

  • '!(flecs.core.ChildOf, *)' root entities

  • '(Likes, *)' / '(Likes, $x)' wildcard / variable pair target

  • 'Position, Mass(up)' Mass on an ancestor (ChildOf)

  • 'SpaceShip, $this ~= "Uss"' name contains "Uss"

  • 'IsA(_, *)' instances of any prefab Use full paths (e.g. 'transform.Position') when names are ambiguous.

Returns {page, results, type_info?}. Each result has 'parent', 'name' and, depending on options, 'id', 'fields' ({values, ids, sources, is_set} per query term), 'vars' or, with table=true, 'tags'/'pairs'/'components'. page = {offset, limit, returned, may_have_more}; when may_have_more is true, call again with offset += limit. Invalid queries return the FLECS parser error (with position) so the query can be fixed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docNoInclude flecs.doc information (doc names, descriptions).
limitNoMaximum number of items to return.
queryYesQuery in the FLECS query language, e.g. 'Position, Velocity'.
tableNoReturn every tag, pair and component of each matched entity (same format as flecs_get_entity) instead of only the query fields.
fieldsNoInclude per-term field data ('fields') for each result.
offsetNoNumber of items to skip (for paging).
valuesNoInclude component values.
inheritedNoWith table=true: include components inherited from prefabs.
type_infoNoInclude the reflection schema of the returned components.
entity_idsNoInclude numeric entity ids ('id').

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageYes
resultsYes
type_infoNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare the safety profile (readOnly, idempotent, non-destructive), so the bar is lower. The description adds real value beyond them: it documents the failure mode ('Invalid queries return the FLECS parser error with position') and the paging completeness signal ('may_have_more'), which the annotations do not cover.

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?

Purpose is front-loaded, followed by the syntax reference and then the return shape, which is a logical reading order. The cheat-sheet block is long but every example encodes a distinct query-language feature, so it earns its space rather than 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?

For a complex query-language tool with 10 parameters, the description covers syntax, output shape, paging semantics, and error behavior. With an output schema already present it doesn't need to enumerate return values, yet its summary of the result fields is accurate and sufficient for correct invocation.

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 description coverage is 100%, so a baseline of 3 would suffice. The description earns a higher score by providing a full syntax cheat sheet for the core 'query' parameter and by explaining the table=true behavior and its effect on the returned shape, adding semantics beyond the terse schema descriptions.

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 opens with a specific verb and resource ('Find entities with a query written in the FLECS query language'), making the mechanism clear. It is implicitly distinguished from the sibling flecs_run_named_query by taking an inline query, but it never names that sibling to make the contrast explicit.

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 gives concrete operational guidance for paging ('when may_have_more is true, call again with offset += limit'), which is genuinely useful. However, it never states when to prefer this tool over alternatives like flecs_run_named_query or flecs_get_entity, so usage is implied rather than prescribed.

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