gograph_sql
Returns bounded pages of static PostgreSQL query literals with operation, read/write/DDL access, tables, enclosing function, and source location. Use it to audit database interactions and write paths.
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
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | 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. | |
| term | No | Optional case-insensitive raw SQL substring filter | |
| limit | No | Page size from 1 to 200; defaults to 100 | |
| verbs | No | Optional PostgreSQL operation filters; values OR-compose | |
| cursor | No | Opaque next_cursor from the previous gograph_sql page; reuse the same filters | |
| module | No | Optional exact module path/directory, unique nested basename, or repository basename for a root module | |
| tables | No | Optional PostgreSQL table selectors; values OR-compose and may be table or schema.table | |
| accesses | No | Optional statement access classes; values OR-compose | |
| function | No | Optional case-insensitive enclosing-function substring | |
| no_tests | No | Exclude SQL facts from *_test.go files; tests are included by default | |
| intention | No | Technical rationale, required for analytical calls selecting an active session. | |
| session_id | No | Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session. |