Skip to main content
Glama

gograph_sql

Read-onlyIdempotent

Audit PostgreSQL query literals in Go code: filter static SQL by operation, read/write/DDL access, table, function, or module; returns paginated evidence with source locations.

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. The MCP server checks freshness before this call and refreshes in the current requested analysis mode. Read-only; no side effects. 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[].

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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"
      +}
  2. 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')"
  3. First observedv1.0.0

TDQS

A4.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, non-destructive, and closed-world behavior, so the safety profile is covered. The description adds useful operational context not in annotations: server-side freshness checks, refresh mode, AND/OR filter composition, test inclusion default, and classification rules for CTEs/UPSERT. However, it does not describe pagination mechanics beyond the return shape or any rate limit or auth requirements. It is solid, but not rich enough for a 4-5 given the lower bar with 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?

The description is front-loaded with the core behavior, then extraction scope, freshness, filter semantics, defaults, and finally WHEN/NOT TO USE and RETURNS blocks. It is dense but every section serves a distinct purpose. Minor inefficiency: the classification rules for CTEs and UPSERT feel like implementation notes that could be trimmed.

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?

Given a 9-parameter, highly configurable query tool with no output schema, the description provides the missing pieces: filter combination logic, default test inclusion, pagination via cursor, freshness guarantees, and return page shape. An agent has everything needed to call it correctly and interpret the response.

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 every parameter is documented in the schema. The description only adds high-level filter composition rules (AND across categories, OR within) and the test-inclusion default; the rest of the semantics for term, module, function, cursor, and tables come from the schema. A baseline 3 is appropriate because the description does not meaningfully extend the schema's parameter documentation.

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: returns one bounded page of static PostgreSQL query literals, enumerated with precise fields. It distinguishes itself from siblings by explicitly routing ORM mappings to gograph_schema and runtime SQL elsewhere. An agent can identify this tool 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?

Explicit WHEN TO USE and NOT TO USE sections name concrete scenarios, including the sibling (gograph_schema) to use instead for ORM mappings. The only missing negative is runtime-generated SQL, but that is called out as well, leaving nothing to inference.

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