Skip to main content
Glama

Sergio by Serviche

query

query
Read-only

Run a read-only SQL SELECT over the business database and get rows back. It is the FALLBACK, not the first move: when a read(entity) answers the question (leads, clients, conversations, bookings and the rest of read's catalog), use read, which carries the business's own definitions (e.g. open leads = read lead_pursuits active:true) that raw tables do not. Use query only when read cannot express the question (a count, a GROUP BY, a JOIN across tables, filtering on a column read() does not expose, a discount a customer used, an arbitrary aggregate). SCHEMA: query the org-scoped view schema soul_read (NOT public). Every table you can read is a view there, already filtered to THIS business. You never write a WHERE organization_id clause and never pass an org id. START with client_timeline for any question about one person or booking: every SMS, call (with AI summary), email, booking and human action in one feed (columns: channel, direction, actor, at, text, ai_summary, sentiment, category, client_id, conversation_id, booking_id). Filter client_id, ORDER BY at DESC, LIMIT. Read SELECT * FROM schema_notes once for column semantics (event-time columns, value meanings, columns that lie: e.g. use sent_at not created_at; contact_type = client means a real client). Never guess a column name: before you name a column of any other table you have not listed in this conversation, list THAT table's columns first (one table, never the whole schema): SELECT column_name FROM information_schema.columns WHERE table_schema='soul_read' AND table_name='<table>'. Reference tables unqualified (e.g. FROM bookings). Search_path is already soul_read. RULES: exactly ONE SELECT statement (a second statement, SET, INSERT/UPDATE/DELETE or DDL is refused). Results cap at 100 rows; the response is {rows, returned, truncated}. When truncated is true, add your OWN aggregation (COUNT/GROUP BY) or a tighter WHERE rather than paging blindly. Dates are stored as the business's local calendar; compare bare dates directly (e.g. scheduled_date BETWEEN '2026-07-01' AND '2026-07-31'). Prefer one precise aggregate query over many row dumps. YOUR ROLE reads only these views here (every other view returns no rows): activity_log, booking_assignments, booking_events, booking_notes, booking_series, bookings, call_transcripts, calls, campaign_recipients, campaigns, checks, claims, client_checkins, client_identifiers, client_pinned_notes, client_relationships, client_staff_relationships, clients, company_documents, contact_list_members, contact_lists, contact_tag_members, contact_tags, conversation_flows, conversation_reads, conversations, emails, flows, import_jobs, leads, messages, org_email_config, org_holidays, organizations, outbound_gate_verdicts, payments, recurrence_series, scheduling_rules, sop_categories, sop_question_log, sops, soul_findings, staff_availability_overrides, staff_default_availability, staff_earnings, staff_events, staff_profiles, tasks, team_members, training_assignments, training_modules, training_questions.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sql": "<sql>"
    },
    "name": "query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesA single read-only SQL SELECT over the soul_read schema, e.g. "SELECT status, count(*) FROM bookings WHERE scheduled_date BETWEEN '2026-07-01' AND '2026-07-31' GROUP BY status".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, but the description adds substantial behavior: exactly one SELECT (second statements, SET, DML and DDL refused), a 100-row cap, the {rows, returned, truncated} response shape, and how to react when truncated. It also discloses the org-scoping model (views are pre-filtered, never pass an org id) and a column-discovery procedure to avoid guessing.

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?

Front-loaded with the most decision-relevant point (fallback vs read) followed by schema guidance, a starting-table recommendation, rules, and the readable-view catalog. It is long and has minor redundancy (org-scoping restated, unqualified-name rule stated twice), but every section serves a distinct purpose and the dense view list is genuinely needed.

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 free-form SQL tool with no output schema, the description supplies the return contract, the row cap and truncation handling, the readable view inventory, and the exact guardrails on what statements are accepted. Nothing an agent needs in order to call this correctly 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?

The single 'sql' parameter is already 100% documented in the schema, yet the description adds deep semantics beyond it: target schema soul_read, unqualified table references, date comparison rules for local-calendar storage, the client_timeline starting point, schema_notes, and the information_schema column-listing step. This meaningfully improves how the parameter value should be constructed.

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?

Opens with a specific verb+resource: 'Run a read-only SQL SELECT over the business database and get rows back.' It immediately distinguishes itself from the sibling 'read' tool and frames itself as the fallback, so an agent can identify its role without opening the schema.

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 NOT to use it ('when a read(entity) answers the question... use read') and enumerates the conditions that select it: counts, GROUP BY, JOINs, columns read() does not expose, arbitrary aggregates. It even names the alternative tool and why its business definitions are preferable.

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.

Resources