Skip to main content
Glama
oracle-mcp-server

oracle-mcp-server

by Tommi2Day

sql_plan

Retrieve the actual execution plan for a cached Oracle SQL cursor by SQL_ID using DBMS_XPLAN.DISPLAY_CURSOR, including optional child cursor and ALLSTATS LAST row-source statistics.

Instructions

Show the actual execution plan of a cached cursor (DBMS_XPLAN.DISPLAY_CURSOR) by sql_id, e.g. from top_sql or session_activity. Use format 'ALLSTATS LAST' for row source statistics (requires the GATHER_PLAN_STATISTICS hint or STATISTICS_LEVEL=ALL). Needs SELECT on V$SQL, V$SQL_PLAN, V$SQL_PLAN_STATISTICS_ALL.

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": {
      "sql_id": "<sql_id>"
    },
    "name": "sql_plan"
  }
}

Input Schema

NameRequiredDescriptionDefault
formatNoDBMS_XPLAN format (default: TYPICAL +PEEKED_BINDS)
sql_idYes13-character SQL_ID
child_numberNoChild cursor number (default: all children)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses privilege requirements (SELECT on V$SQL, V$SQL_PLAN, V$SQL_PLAN_STATISTICS_ALL) and the precondition that ALLSTATS LAST only yields statistics under GATHER_PLAN_STATISTICS or STATISTICS_LEVEL=ALL. It stops short of describing behavior when the cursor has aged out of the cache or what errors surface.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each earning its place: what it does, how to use the format option, and what privileges are needed. Front-loaded with the action and the identifier, with prerequisites trailing in descending order of importance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, yet the description names the exact DBMS_XPLAN function producing the result, which compensates. Prerequisites and format caveats are covered; only edge-case behavior (stale cursor, empty plan) is missing, which is minor for this tool's complexity.

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 already defines all three parameters; the description still adds real meaning by explaining that 'ALLSTATS LAST' is a meaningful format choice with prerequisites, and by indicating where sql_id values originate. child_number is not discussed beyond the schema, keeping it below a 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — 'Show the actual execution plan of a cached cursor' — and names the underlying mechanism (DBMS_XPLAN.DISPLAY_CURSOR) plus the key lookup (sql_id). The 'cached cursor' framing implicitly separates it from explain_plan, but it never names that sibling, so the distinction is left to inference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete usage context: sql_id typically comes from top_sql or session_activity, and format 'ALLSTATS LAST' is recommended when row source statistics are wanted. It does not state when to prefer explain_plan or what to do if the cursor is no longer cached, so no explicit alternatives or exclusions.

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