Skip to main content
Glama

gograph_sql

Read-onlyIdempotent

Audit PostgreSQL database interactions by returning bounded pages of static SQL literals with operation, access type, tables, enclosing function, module, and source location.

Instructions

Return one bounded gograph.sql.v1 page of static PostgreSQL query literals with operation, read/write/DDL access, referenced tables, enclosing function, module ownership, and source location. Extraction covers direct literals plus statically resolvable local or same-file package const/var declarations, straight-line assignments, and bounded string concatenations. Filters in different categories AND-compose; repeated values within tables, verbs, and accesses OR-compose. Tests remain included by default for backward compatibility; set no_tests=true for production-only results. CTEs resolve to their actual operation, data-modifying CTEs retain write access/table evidence, PostgreSQL UPSERT remains INSERT, and unsupported classification is explicit rather than guessed. WHEN TO USE: Audit database interactions, write paths, or queries touching a table. NOT TO USE: For ORM struct mappings (use gograph_schema) or runtime-generated SQL that is not a static literal. RETURNS: A deterministic page with total/returned/truncated/next_cursor and queries[].

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "gograph_sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
rootNoAbsolute path of your checkout or worktree (alias cwd).
termNoOptional case-insensitive raw SQL substring filter
limitNoPage size from 1 to 200; defaults to 100
verbsNoOptional PostgreSQL operation filters; values OR-compose
cursorNoOpaque next_cursor from the previous gograph_sql page; reuse the same filters
moduleNoOptional exact module path/directory, unique nested basename, or repository basename for a root module
tablesNoOptional PostgreSQL table selectors; values OR-compose and may be table or schema.table
accessesNoOptional statement access classes; values OR-compose
functionNoOptional case-insensitive enclosing-function substring
no_testsNoExclude SQL facts from *_test.go files; tests are included by default
intentionNoRationale; required with an active session.
session_idNoSession from session_create; omit for none.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.7.21
    • changedInput schema / properties / intention / description
      Previous value: -"Technical rationale, required for analytical calls selecting an active session."New value: +"Rationale; required with an active session."
    • changedInput schema / properties / root / description
      Previous value: -"Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean."New value: +"Absolute path of your checkout or worktree (alias cwd)."
    • changedInput schema / properties / session_id / description
      Previous value: -"Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session."New value: +"Session from session_create; omit for none."
  2. Changed3 schema fields changedv1.7.18
    • addedInput schema / properties / intention
      Added value: +{
      +  "description": "Technical rationale, required for analytical calls selecting an active session.",
      +  "type": "string"
      +}
    • addedInput schema / properties / root
      Added value: +{
      +  "description": "Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean.",
      +  "type": "string"
      +}
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session.",
      +  "type": "string"
      +}
  3. Changed10 schema fields changedv1.7.5
    • addedInput schema / properties / accesses
      Added value: +{
      +  "description": "Optional statement access classes; values OR-compose",
      +  "items": {
      +    "enum": [
      +      "read",
      +      "write",
      +      "ddl"
      +    ],
      +    "type": "string"
      +  },
      +  "maxItems": 32,
      +  "type": "array"
      +}
    • addedInput schema / properties / cursor
      Added value: +{
      +  "description": "Opaque next_cursor from the previous gograph_sql page; reuse the same filters",
      +  "maxLength": 1024,
      +  "type": "string"
      +}
    • addedInput schema / properties / function
      Added value: +{
      +  "description": "Optional case-insensitive enclosing-function substring",
      +  "maxLength": 1024,
      +  "type": "string"
      +}
    • addedInput schema / properties / limit
      Added value: +{
      +  "description": "Page size from 1 to 200; defaults to 100",
      +  "maximum": 200,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / module
      Added value: +{
      +  "description": "Optional exact module path/directory, unique nested basename, or repository basename for a root module",
      +  "maxLength": 1024,
      +  "type": "string"
      +}
    • addedInput schema / properties / no_tests
      Added value: +{
      +  "description": "Exclude SQL facts from *_test.go files; tests are included by default",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / tables
      Added value: +{
      +  "description": "Optional PostgreSQL table selectors; values OR-compose and may be table or schema.table",
      +  "items": {
      +    "maxLength": 256,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "maxItems": 32,
      +  "type": "array"
      +}
    • changedInput schema / properties / term / description
      Previous value: -"Optional SQL keyword or table name to filter database queries (e.g., 'SELECT', 'users')"New value: +"Optional case-insensitive raw SQL substring filter"
    • addedInput schema / properties / term / maxLength
      Added value: +4096
    • addedInput schema / properties / verbs
      Added value: +{
      +  "description": "Optional PostgreSQL operation filters; values OR-compose",
      +  "items": {
      +    "enum": [
      +      "SELECT",
      +      "INSERT",
      +      "UPDATE",
      +      "DELETE",
      +      "MERGE",
      +      "CREATE",
      +      "ALTER",
      +      "DROP",
      +      "TRUNCATE"
      +    ],
      +    "type": "string"
      +  },
      +  "maxItems": 32,
      +  "type": "array"
      +}
  4. Changed1 schema field changedv1.4.70
    • changedInput schema / properties / term / description
      Previous value: -"Optional string to filter the queries"New value: +"Optional SQL keyword or table name to filter database queries (e.g., 'SELECT', 'users')"
  5. First observedv1.0.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already establish readOnly/idempotent/non-destructive/closed-world, yet the description adds substantial behavior beyond that: a bounded pagination model with next_cursor, AND/OR filter composition rules, the backward-compatible inclusion of tests with a no_tests escape hatch, and classification rules for CTEs, data-modifying CTEs, and UPSERT. It also states that unsupported classification is explicit rather than guessed, which tells an agent how to interpret edge-case results.

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 front-loaded with purpose, then the extraction scope, filter composition, defaults, classification guarantees, usage routing, and return shape. Every section is relevant, though the extraction-coverage and classification sentences are dense and could be trimmed slightly without losing routing value.

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 12 optional parameters, no output schema, and rich annotations, the description covers everything an agent needs: what is scanned, how filters combine, pagination via cursor, default inclusion of tests, and the exact return envelope (total/returned/truncated/next_cursor and queries[]). No material gap remains for correct invocation.

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 alone establishes the baseline of 3. The description adds meaning the schema does not fully convey: cross-category filters AND-compose while repeated values within tables/verbs/accesses OR-compose, plus the default test-inclusion behavior. That cross-parameter interaction is genuine added value.

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 opens with a specific verb and resource: returning a bounded page of static PostgreSQL query literals, and enumerates the returned evidence fields (operation, read/write/DDL access, tables, enclosing function, module, source location). It also draws explicit boundaries against gograph_schema and runtime-generated SQL, so an agent can distinguish it from siblings without inspecting schemas.

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 contains explicit 'WHEN TO USE' (auditing database interactions, write paths, or queries touching a table) and 'NOT TO USE' clauses that name alternatives (gograph_schema for ORM mappings) and the excluded case of runtime-generated SQL. This is as close to unambiguous routing guidance as a description can provide.

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