Skip to main content
Glama

gbif-biodiversity-mcp-server

Count Occurrences

gbif_count_occurrences
Read-onlyIdempotent

Count occurrences matching a taxon + location filter without fetching records. Use for quick totals ("how many Aves records in Sweden?") or before deciding whether to paginate a full search. Accepts taxonKey, country (uppercase ISO 3166-1 alpha-2), publishingCountry, stateProvince, isGeoreferenced, datasetKey, year, occurrenceStatus, and iucnRedListCategory. Counts sightings only by default, matching gbif_search_occurrences — GBIF also indexes absence records, and for some taxa they are the overwhelming majority. A count above 100,001 is the signal to partition rather than page: gbif_search_occurrences cannot reach past that offset, so split the query by DATASET_KEY via gbif_occurrence_facets and search each dataset separately.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoYear or year range (e.g., "2024" or "2020,2024"). Both endpoints inclusive. Omit the field to count across every year — a blank or whitespace-only value is rejected rather than dropped, because GBIF answers one with the unfiltered total.
countryNoISO 3166-1 alpha-2 code, uppercase, of where the occurrence was recorded (e.g., "GB", "US"). Not the publisher's country — that is publishingCountry, and the two disagree on most records. Lowercase and alpha-3 forms ("gb", "USA") match nothing upstream, which is why only the uppercase two-letter form is accepted here. Take a value from a COUNTRY facet on gbif_occurrence_facets; an uppercase pair GBIF does not know ("XX") is rejected upstream by name.
taxonKeyNoGBIF backbone taxon key from gbif_match_species. Matches the given taxon and all descendant taxa (subspecies, varieties, etc.).
datasetKeyNoFilter to a specific dataset UUID (8-4-4-4-12 hex) from gbif_search_datasets. Omit the field to count across every dataset — an empty string is rejected rather than read as no filter, because GBIF answers a blank datasetKey with the unfiltered total. The result is not the recordCount the dataset tools and the gbif://dataset/{datasetKey} resource report for the same key: that figure spans every occurrenceStatus, while this count applies occurrenceStatus below, PRESENT by default.
stateProvinceNoState, province, or first-level administrative division, matched as a verbatim string — exact and case-sensitive. GBIF stores what each dataset recorded without normalizing it, so there is no vocabulary to guess from: "England", "England - Greater London", and "Greater London" are three distinct values, and "england" is none of them. Take one from a STATE_PROVINCE facet on gbif_occurrence_facets scoped the same way and pass it back unchanged — an unmatched value counts zero rather than erroring. Omit the field to count across every state or province — a blank or whitespace-only value is rejected rather than dropped, because GBIF answers one with the unfiltered total.
isGeoreferencedNoWhen true, count only georeferenced records. When false, count only non-georeferenced records.
occurrenceStatusNoPresence/absence filter. Defaults to PRESENT: an ABSENT record documents a survey that looked for the taxon and did not find it, so counting one inflates the total with the opposite of a sighting. Use ANY for both (GBIF's own default), or ABSENT for non-observations alone. Matches the gbif_search_occurrences default, so the two tools agree.PRESENT
publishingCountryNoISO 3166-1 alpha-2 code, uppercase, of the organization that published the record — not where the occurrence was observed, which is country. The two differ constantly: of 60,290,950 records observed in GB, 1,548,928 were published by US organizations. Take a value from a PUBLISHING_COUNTRY facet on gbif_occurrence_facets. Lowercase and alpha-3 forms ("us", "USA") match nothing upstream, which is why only the uppercase two-letter form is accepted here.
iucnRedListCategoryNoCount only records whose taxon carries this IUCN Red List category: CR Critically Endangered, EN Endangered, VU Vulnerable, NT Near Threatened, LC Least Concern, DD Data Deficient, EX Extinct, EW Extinct in the Wild, CD Conservation Dependent. Records with no category are excluded when this is set.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoTotal occurrences matching the supplied filters.
errorNoPresent when the call failed. Absent on success.
noticeNoGuidance when the count is zero under a verbatim stateProvince filter, larger than gbif_search_occurrences can page to, or narrowed by a presence/absence filter. Absent when none applies.
occurrenceStatusNoThe presence/absence filter applied upstream — PRESENT, ABSENT, or ANY when no filter was sent. Says what the count covers.

TDQS

A5/5.0
Behavior5/5

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

Beyond the readOnlyHint and idempotentHint annotations, the description discloses critical behavioral nuances: the default occurrenceStatus of PRESENT, the absence-record caveat, the blank/whitespace rejection (vs. treating as no filter), and the difference from dataset recordCount. These are non-obvious and essential for correct use.

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?

The description is long but every sentence earns its place. It is front-loaded with the purpose, then flows logically into usage, then details each parameter's semantics. The density is high with zero filler, and the structure aids comprehension for a complex tool.

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?

Given the tool has an output schema (exempting return-value explanations) and 9 optional parameters, the description covers all necessary edge cases, default behaviors, and integration points with sibling tools. Nothing an agent needs to correctly invoke it is missing.

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?

Despite 100% schema coverage, the description adds substantial meaning: it explains why only uppercase two-letter country codes are accepted, the verbatim case-sensitive matching for stateProvince, the interaction between country and publishingCountry, and the default-and-rejection behavior for datasetKey and stateProvince. This goes far beyond repeating schema definitions.

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?

The description opens with a specific verb and resource: 'Count occurrences matching a taxon + location filter without fetching records.' This clearly differentiates it from sibling gbif_search_occurrences, which fetches records, and states the tool's core function precisely. The scope is unambiguous.

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?

It explicitly states when to use the tool ('quick totals', 'before deciding whether to paginate') and when not to, via the 100,001 offset limitation and the recommendation to partition using gbif_occurrence_facets. It also references the sibling search tool's behavior, providing concrete, actionable guidance.

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/5.0
Disambiguation5/5

Each tool targets a distinct action and resource pair: matching (single and batch), retrieving species details, hierarchy traversal, searching occurrences, counting, aggregating by facets, and searching datasets/publishers. There is no functional overlap or ambiguity between tools.

Naming Consistency4/5

The naming is largely consistent with the gbif_ prefix followed by a verb and noun (e.g., gbif_match_species, gbif_count_occurrences, gbif_get_dataset). However, a few tools use a search_<noun> pattern (e.g., gbif_search_datasets) and one uses a noun phrase without a verb (gbif_occurrence_facets), introducing a minor inconsistency.

Tool Count5/5

13 tools is well within the optimal range for a domain-specific API. The tools cover taxonomy resolution, species lookup and hierarchy, occurrence search/count/aggregation, and dataset/publisher discovery—no unnecessary bloat or sparse coverage.

Completeness4/5

The surface covers the core GBIF workflows: match → search/get occurrences, get species details and classification, and find datasets/publishers. Missing bulk download is explicitly acknowledged and not served by this tool, and searching datasets by taxon is indirect (via occurrence datasetKey), but these are workable gaps rather than blockers.