Skip to main content
Glama

Openfda Dataframe Query

openfda_dataframe_query
Read-onlyIdempotent

Run a read-only SQL SELECT against a DataCanvas table staged by an openFDA search tool (call one with stage=true; its response carries canvas_id + canvas_table). Enables GROUP BY, COUNT/SUM/AVG, time-series, and joins across the staged result set without re-paging the API. Call openfda_dataframe_describe first to get the exact table and column names. Results are capped at the canvas row limit — when truncated is true, page the rest with ORDER BY plus LIMIT/OFFSET. Scalar fields are stored as text (CAST for numeric math); nested objects/arrays are JSON columns — read them with DuckDB json functions, e.g. json_extract_string(openfda, '$.brand_name[0]'). Only SELECT is allowed — DDL, DML, COPY, and file-reading functions are blocked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL SELECT against the staged table. Use the table name from openfda_dataframe_describe. Example: "SELECT classification, COUNT(*) AS n FROM spilled_ab12cd34 GROUP BY classification ORDER BY n DESC".
canvas_idYesCanvas ID from an openFDA search tool response (the canvas_id field, present when the search ran with stage=true).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
rowsNoRows returned by the query (capped at the canvas row limit).
errorNoPresent when the call failed. Absent on success.
canvas_idNoCanvas ID that was queried — reuse for follow-up queries.
row_countNoNumber of rows in this response. Equals the canvas row limit when truncated is true.
truncatedNoTrue when the result hit the canvas row limit and rows beyond it were dropped. Page the rest with ORDER BY plus LIMIT/OFFSET.

TDQS

A4.3/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true, and the description is consistent with and enriches them. It discloses the security boundary ('DDL, DML, COPY, and file-reading functions are blocked'), the row-cap behavior with the truncated flag, and crucially the storage semantics ('Scalar fields are stored as text (CAST for numeric math); nested objects/arrays are JSON columns') with a concrete json_extract_string example. This is exactly the behavioral context annotations cannot express, and it contradicts nothing.

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?

A single dense paragraph that front-loads the core purpose before layering preconditions, limits, type semantics, and restrictions. Every sentence carries distinct information (sequencing, truncation paging, CAST, JSON functions, blocked statements) with no filler. Slightly long, but the density is justified for a tool with this much operational nuance.

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?

An output schema exists, so return-value documentation isn't the description's burden. Given the tool's complexity, it covers the essential operational surface: how to reach the right table, how to handle truncation, how to deal with column typing, and the safety boundary. It omits nothing needed to make a correct first call; a worked end-to-end query paired with the describe output is the only optional addition.

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% — both canvas_id and query carry full descriptions with a worked SQL example. The description adds marginal value (the table name comes from openfda_dataframe_describe; canvas_id derives from a stage=true search), which aligns with the schema but does not materially extend it. Baseline 3 is appropriate when the schema already documents both parameters thoroughly.

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: 'Run a read-only SQL SELECT against a DataCanvas table staged by an openFDA search tool'. It clearly distinguishes itself from sibling search tools by explaining it operates on already-staged results rather than paging the API, and it names its companion openfda_dataframe_describe. An agent can tell exactly what this tool does and how it relates to the other openfda_* siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit sequencing is given: call a search tool with stage=true to obtain canvas_id/canvas_table, and 'Call openfda_dataframe_describe first to get the exact table and column names'. Truncation handling is prescribed ('page the rest with ORDER BY plus LIMIT/OFFSET'). It does not enumerate which sibling tools NOT to use (e.g., openfda_count_values for simple aggregations), so it stops just short of fully routing alternatives, but the preconditions are clear and actionable.

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.

TDQS

A4/5.0
Disambiguation5/5

Each tool targets a distinct FDA endpoint or analytic function. Search tools are separated by domain (adverse events, animal events, recalls, tobacco, etc.), and utility tools (count_values, describe_fields, dataframe_describe/query, drug_profile) serve unique purposes without overlap. An agent can clearly identify which tool to call for a given task.

Naming Consistency5/5

All tools follow a consistent openfda_<action>_<object> pattern in snake_case. Search tools use search_<domain>, while utility tools use clear verbs like get, lookup, count, describe, and query. The only slight deviation is drug_profile (a noun phrase), but it remains intuitive and fits the naming style.

Tool Count5/5

With 14 tools, the server is well-scoped for its purpose of providing access to multiple openFDA endpoints. Each tool covers a distinct resource or analytic capability, and none feel redundant. The count sits comfortably within the ideal range for a domain-specific server.

Completeness5/5

The server covers the major openFDA data categories: adverse events (human/animal), device clearances, drug approvals, shortages, recalls, tobacco, labels, and NDC lookup. It also provides robust analytics via count_values and dataframe queries, plus field discovery. There are no obvious gaps for the stated domain, and the composite drug_profile fills integration needs.