Skip to main content
Glama

Sf Query

sf_query
Read-onlyIdempotent

Run a raw SoQL query against any San Francisco open-data resource (data.sfgov.org, also written data.sf.gov) by its Socrata id (8-char like "wg3w-h783" or "ebsh-uavg"). Covers SF city purchasing/procurement records (resource id "ebsh-uavg") — real column names fiscal_year, po_dt, purchase_order, purchase_order_line, purchasing_department, purchasing_department_title, commodity_code, commodity_title (the item name/description column — there is no "commodity_description"), vendor_name, vendor_street, vendor_city, vendor_state, vendor_zip_code, vendor_contact, vendor_email, vendor_phone, encumbered_quantity, encumbered_amount — as well as every other SF Socrata dataset by resource id; if you do not already know a dataset's exact column names, omit select (every column comes back) rather than guessing one, since Socrata 400s on an unknown column instead of ignoring it. Full SoQL: where/select/group/order/limit/offset. Use sf_datasets to find a resource id, or sf_recent for the common ones (including "purchasing").

Input Schema

NameRequiredDescriptionDefault
groupNoSoQL $group (e.g. "incident_category").
limitNoMax rows (default 100, max 5000).
orderNoSoQL $order (e.g. "incident_datetime DESC").
whereNoSoQL $where filter (e.g. "incident_year=2025").
offsetNoRow offset for paging.
selectNoSoQL $select (e.g. "incident_category, count(*)").
_apiKeyNoOptional — your own Socrata app token for higher rate limits. Omit to use the keyless endpoint.
resource_idYesSocrata resource id, e.g. "wg3w-h783" (police incidents).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "_apiKey": "your-data-sf-api-key",
      +    "limit": 100,
      +    "resource_id": "wg3w-h783",
      +    "where": "incident_year=2025"
      +  },
      +  {
      +    "_apiKey": "your-data-sf-api-key",
      +    "group": "incident_category",
      +    "order": "count(*) DESC",
      +    "resource_id": "wg3w-h783",
      +    "select": "incident_category, count(*)"
      +  }
      +]
  2. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare this as a safe, read-only, idempotent, open-world query. The description adds useful behavioral detail beyond those hints, notably that Socrata returns a 400 on unknown columns instead of ignoring them and that omitting `select` returns every column.

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?

The purpose and key guidance are front-loaded, and the long purchasing column list is relevant to avoiding SoQL errors. It is still a dense single paragraph, and some dataset-specific column enumeration could be structured more cleanly.

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?

For a complex query tool with 8 parameters and no output schema, the description covers usage, resource ids, SoQL clauses, and a major error mode well. It does not fully describe the returned row shape or pagination behavior, though the `select` omission note partially covers return fields.

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 coverage is 100%, so the schema already documents every parameter, setting the baseline at 3. The description adds real semantic value by naming the supported SoQL clauses, giving resource-id format examples, warning about unknown `select` columns, and listing exact purchasing column names.

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 states a specific verb and resource: 'Run a raw SoQL query against any San Francisco open-data resource' by Socrata resource id. It also names the sibling tools sf_datasets and sf_recent, so an agent can distinguish it from dataset discovery or recent-dataset shortcuts.

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 says when to use sf_datasets to find a resource id and when sf_recent covers common datasets such as purchasing. It also gives a concrete usage rule: if exact column names are unknown, omit `select` rather than guessing.

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.