Skip to main content
Glama
andronaft

health-os

sql_query

Read-only

Run read-only SELECT or WITH queries over approved health views to compare markers, apply custom date filters, or aggregate data when dedicated tools don't fit. Returns up to 200 rows.

Instructions

Run a custom read-only SQL query (one SELECT or WITH … SELECT) over the approved views when no other tool answers the question — e.g. comparing several markers, custom date filters or aggregates. Runs as a view-only database role in a read-only transaction with a 5 s timeout; returns at most 200 rows (truncated tells you if there were more). Base tables, pending values and writes are not accessible. Prefer the dedicated tools (query_observations, get_trend, query_food…) when they fit.

Only READ-ONLY views are available (approved + not deleted): v_observations(id, user_id, type_code, name_uk, category, specimen, effective_at, value_numeric, comparator, value_text, unit, value_canonical, canonical_unit, ref_min, ref_max, status, result_status, context, panel_id) v_observations_pending(... , review_status, review_note) -- NOT fact, only for review v_medications_current(id, medication_name, dose_amount, dose_unit, times_per_day, ...) v_diagnoses(id, diagnosed_at, diagnosis_name, icd10_code, clinical_status, verification_status) v_allergies(id, allergen, reaction, severity, verified) -- verified=false is ALSO an allergy v_food_log(id, user_id, eaten_at, meal_type, description, portion, nutrient_source, glycemic_index, glycemic_load, symptoms, wellbeing, notes) v_food_nutrients(food_log_id, user_id, eaten_at, meal_type, nutrient_code, name_uk, category, unit, amount, rda, upper_limit) -- nutrients per meal v_meal_templates(id, user_id, name, meal_type, description, nutrients, glycemic_index) health_timeline(kind, user_id, id, at, title) Examples: SELECT type_code, effective_at, value_canonical FROM v_observations WHERE type_code='cholesterol_total' ORDER BY effective_at DESC; SELECT * FROM v_diagnoses WHERE verification_status='confirmed';

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations cover read-only status, but the description adds substantial behavioral detail beyond them: view-only database role, read-only transaction, 5-second timeout, 200-row cap with a `truncated` flag, and explicit statement that base tables, pending values, and writes are inaccessible. This is exactly the context an agent needs before issuing arbitrary SQL.

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 and usage guidance are front-loaded in the first two sentences, followed by the view catalog and examples. It is long, but nearly every line (column lists, the pending-view caveat, the allergy caveat) earns its place for a free-form SQL tool; only slight density keeps it from a 5.

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 high-complexity, open-ended SQL tool, the description covers access scope, limits, timeout, row truncation, view/column inventory, and usage routing. An output schema exists, so return-shape explanation is unnecessary, and the `truncated` mention is appropriate extra signal.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% for the single `sql` parameter, so the description must compensate — and it does thoroughly. It enumerates every accessible view with its columns, flags semantic traps ('verified=false is ALSO an allergy', pending view 'NOT fact'), and gives two worked SQL examples, far exceeding what the bare schema provides.

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 custom read-only SQL query (one SELECT or WITH … SELECT) over the approved views') and adds a scope qualifier ('when no other tool answers the question'). An agent can immediately tell this apart from the dedicated query tools listed as siblings.

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?

Explicitly states when to use it ('when no other tool answers the question — e.g. comparing several markers, custom date filters or aggregates') and when not to ('Prefer the dedicated tools (query_observations, get_trend, query_food…) when they fit'), naming the alternatives. Nothing is left to inference.

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