Skip to main content
Glama

select_schema

Read-onlyIdempotent

Pick the few tables and views a question needs as compact DDL for SQL, scoped to the caller so hidden objects and columns are excluded.

Instructions

Start here for any question about the data. Returns the few tables and views the question needs, as compact DDL to write SQL against, scoped to the caller: objects and columns they may not read are absent, not ranked low. Pass principal and roles whenever you know who is asking. Returns 'ddl' (put it in your SQL prompt), 'objects' (the names chosen), 'explain' (score and reason per object) and 'selected' / 'total_objects'. Reads table structure only, never rows. Next: write one SELECT against 'ddl' and call run_query with the same principal and roles; call describe_object if a table needs more columns than the compact DDL shows. If the right table is missing, raise top_k or rephrase rather than writing SQL against a table that was not returned.

Input Schema

NameRequiredDescriptionDefault
rolesNoThe caller's roles or groups, e.g. ['finance', 'payroll']. Objects and columns restricted to a role are visible only when it is listed here. Omitted = no roles.
top_kNoHow many tables and views to select for the question (default 6). Raise it for questions that span many areas; the caller's visible objects are the upper bound.
questionYesThe user's question in plain language, e.g. 'revenue by month' or 'which customers owe us money'.
principalNoWho is asking, as an identity string such as 'okta:jdoe'. Pass it whenever you know the user: visibility is decided for this identity. Omitted = anonymous, which sees only unrestricted objects.
expand_foreign_keysNoAlso pull in tables joined by foreign key to the selected ones (default true), only where the caller may read them. Set false for the bare top matches.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare read-only/idempotent/non-destructive, but the description adds substantial context those annotations cannot convey: access scoping ('objects and columns they may not read are absent, not ranked low'), anonymous-by-default visibility when principal/roles are omitted, and the key constraint that it 'Reads table structure only, never rows.'

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?

It is longer than typical but front-loads the core purpose, then the scoping behavior, then the return keys, then the next-step workflow. Nearly every sentence carries actionable information, though the return-key enumeration is somewhat redundant with the output schema.

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 tool with 5 parameters, an output schema, and access-control complexity, the description covers purpose, scoping, return shape, and the follow-up workflow. Nothing an agent needs to call it correctly — including which downstream tool to use next — is missing.

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 baseline is 3. The description still adds operational meaning beyond the schema by advising 'Pass principal and roles whenever you know who is asking' and by tying top_k to a failure mode ('raise top_k or rephrase'), reinforcing when to adjust selection breadth.

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 names a specific verb and resource ('Returns the few tables and views the question needs, as compact DDL to write SQL against') and immediately scopes it to the caller's permissions. It is clearly distinguishable from siblings like describe_object and run_query, which are named as the next steps.

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 states when to use it ('Start here for any question about the data'), the exact follow-up ('write one SELECT against ddl and call run_query with the same principal and roles'), and the alternative for deeper column detail ('call describe_object'). It also gives a recovery path when results are wrong ('raise top_k or rephrase').

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