Skip to main content
Glama
db-conn-mcp

db-conn-mcp

get_table_schema

Read-onlyIdempotent

Retrieve a table's columns, data types, primary and foreign keys, and optional indexes before writing filters or JOINs. Use it to inspect structure and verify what a slow query actually indexes.

Instructions

Get columns, types, and primary/foreign keys for a table.

For one table. For every table at once use get_database_schema; for a view, function, trigger, sequence or index definition use get_object_definition.

Returns meta, table, columns (name, type, nullable, default), primary_key and foreign_keys, plus indexes when asked for; a table that does not exist is an error.

Pass include_indexes=true to also get the table's indexes (name, its KEY columns in index order — an INCLUDE payload is not listed — whether it is unique, and its method: btree, gin, ...). Use it before writing a filter or a JOIN, or when a query is slow and you want to know what is actually indexed. Omitted by default, so the plain answer stays small.

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": {
      "database": "<database>",
      "table": "<table>"
    },
    "name": "get_table_schema"
  }
}

Input Schema

NameRequiredDescriptionDefault
tableYesTable or view name exactly as list_tables shows it (case-sensitive, no quotes), optionally schema-qualified: 'orders' or 'public.orders'.
databaseYesName of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names.
include_indexesNoAlso return the table's indexes. Default false keeps it small.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.8.1
    • addedInput schema / properties / database / description
      Added value: +"Name of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names."
    • addedInput schema / properties / include_indexes / description
      Added value: +"Also return the table's indexes. Default false keeps it small."
    • addedInput schema / properties / table / description
      Added value: +"Table or view name exactly as list_tables shows it (case-sensitive, no quotes), optionally schema-qualified: 'orders' or 'public.orders'."
  2. First observed

TDQS

A4.4/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false and closed-world, so the safety profile is pre-established. The description adds genuinely useful behavior beyond that: the exact return fields, that a missing table is an error, and that include_indexes defaults off to keep the plain answer small. It stops short of pagination, size limits or column-count caveats, so it is solid but not exhaustive.

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 purpose and scope, then alternatives, then return shape, then the option — a logical reading order with no filler sentences. It runs slightly long and the index-method examples ("btree, gin, ...") are marginal, but every paragraph carries information an agent needs given there is no 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?

With no output schema, the description carries the return-value burden itself and does so: it enumerates meta, table, columns (name, type, nullable, default), primary_key, foreign_keys, and the conditional indexes. It also covers the error case and the default-off behavior, which is everything needed to call this correctly on the first attempt.

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, and the description earns above that by explaining what include_indexes actually yields: index name, KEY columns in index order, the fact that an INCLUDE payload is not listed, uniqueness and access method. That INCLUDE exclusion is a real semantic detail absent from the schema and prevents a wrong inference about covered columns.

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 and resource set: "Get columns, types, and primary/foreign keys for a table," then immediately scopes it with "For one table." An agent can distinguish it from get_database_schema (all tables) and get_object_definition (non-table objects) without opening any 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 names both alternatives and the condition that selects each: get_database_schema for every table at once, get_object_definition for views, functions, triggers, sequences and indexes. It also states when to reach for include_indexes (before writing a filter or JOIN, or when a query is slow), so both the routing and the option choice are covered.

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