Skip to main content
Glama
db-conn-mcp

db-conn-mcp

get_object_definition

Read-onlyIdempotent

Retrieve the exact SQL definition of a database view, function, trigger, sequence, or index by name, with optional schema qualification and all matches returned.

Instructions

Get the faithful SQL definition of a non-table object by name.

For a table's columns and keys use get_table_schema; for the whole schema as a script use get_database_schema(format="sql").

Covers views (and materialized views), functions/procedures, triggers, sequences, and indexes — produced by the database's own pg_get_*def functions. name may be schema-qualified ("public.my_view"); all matches are returned (same name in several schemas, overloaded functions).

Returns meta, object_type, name and matches, each with its schema, name, kind and definition; no match is an error.

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>",
      "object_type": "<object_type>",
      "name": "<name>"
    },
    "name": "get_object_definition"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesObject name as stored (case-sensitive, no quotes), optionally schema-qualified: 'my_view' or 'public.my_view'.
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.
object_typeYesKind of object. 'view' also covers materialized views, 'function' also covers procedures.

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 / name / description
      Added value: +"Object name as stored (case-sensitive, no quotes), optionally schema-qualified: 'my_view' or 'public.my_view'."
    • addedInput schema / properties / object_type / description
      Added value: +"Kind of object. 'view' also covers materialized views, 'function' also covers procedures."
  2. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already cover the read-only, idempotent, non-destructive profile, yet the description still adds real behavior: definitions come from the database's own pg_get_*def functions, all name matches across schemas are returned, overloaded functions yield multiple results, and no match is an error. It stops short of noting any permission prerequisites, but the mutation/safety surface is fully covered by annotations.

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, then alternatives, then scope, then return shape — a sensible ordering with no filler sentences. Slight redundancy with the schema on schema-qualified names keeps it from perfect conciseness.

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 supplies the return structure (meta, object_type, name, matches with schema/name/kind/definition) and the error case, plus the three-parameter routing. Nothing an agent needs 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.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all three parameters are already documented, including the enum's view/materialized-view and function/procedure aliasing. The description reinforces schema-qualified naming and multi-match behavior for overloaded functions, but that meaning largely duplicates the schema text.

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?

Starts with a specific verb and resource scoped precisely ('faithful SQL definition of a non-table object'), then immediately contrasts itself with get_table_schema and get_database_schema. The enumerated object types (views, functions/procedures, triggers, sequences, indexes) make the boundary of the tool 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?

Explicitly routes the agent: tables' columns/keys go to get_table_schema, whole-schema script goes to get_database_schema(format="sql"). That is a concrete when-to-use-this vs when-to-use-sibling rule rather than implied usage.

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