Skip to main content
Glama

query_cohort

Query cohort counts from clinical datasets by filtering on patient demographics, diagnoses, ICU stay, and mortality. Returns patient and admission counts with demographics.

Instructions

Query cohort counts based on filtering criteria.

Used by the cohort builder UI for live updates as users adjust filters. Can also be called directly to get cohort statistics.

Args: dataset: Dataset name, e.g. 'mimic-iv'. age_min: Minimum patient age (0-130, inclusive). age_max: Maximum patient age (0-130, inclusive). gender: Patient gender ('M' or 'F'). icd_codes: List of ICD diagnosis code prefixes to filter by. icd_match_all: If True, patient must have ALL ICD codes (AND); default is ANY (OR). has_icu_stay: If True, require ICU stay; if False, exclude ICU patients. in_hospital_mortality: If True, require in-hospital death; if False, exclude deaths.

Returns: JSON with patient_count, admission_count, demographics, and SQL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
age_minNo
age_maxNo
genderNo
icd_codesNo
icd_match_allNo
has_icu_stayNo
in_hospital_mortalityNo
datasetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations, the description carries the full burden. It describes filtering logic (icd_match_all default), return fields, and the nature of the operation (query). It does not cover performance or side effects, but for a read-only query tool this is adequate.

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?

Description is succinct with a clear intro, usage context, and well-structured Args/Returns sections. Every sentence adds value, no redundancy.

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?

Covers purpose, parameters, and return structure comprehensively. Given the presence of an output schema, the description complements it well. Minor gap: no mention of prerequisites (e.g., need to select dataset first) but dataset is a parameter.

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%, but the description provides full details for all 8 parameters, including acceptable values (age range, gender, icd_codes list) and semantics (icd_match_all default). This adds significant value beyond the schema definition.

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?

Description clearly states the tool queries cohort counts with filtering criteria. It specifies two use cases (cohort builder UI and direct calls), distinguishing it from sibling tools like `cohort_builder` which likely handles building rather than querying.

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?

Explicitly mentions usage in cohort builder UI and as a direct query tool, providing clear context. However, no exclusions or comparisons to siblings like `execute_query` or `get_table_info` are given, which could help agents decide when to use this specific tool.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hannesill/m4'

If you have feedback or need assistance with the MCP directory API, please join our Discord server