Package org.gridgain.internal.mcp.tools
Class QueryAnalysisTool
java.lang.Object
org.gridgain.internal.mcp.tools.QueryAnalysisTool
MCP tool for analyzing SQL query execution plans.
This tool generates execution plans for SQL queries using the EXPLAIN statement,
helping users understand query performance characteristics without actually executing the query.
Features
- Generates execution plans showing operations, row estimates, and distribution strategies
- Shows join strategies, index usage, predicates, and projections
- Safe analysis - EXPLAIN does not execute the actual query
Usage Example
{
"query": "SELECT o.order_id, c.name FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.status = 'PENDING'"
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic McpResponsegetExecutionPlan(String query, String explainType) Generates an execution plan for the provided SQL query.static reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>handleGetQueryExecutionPlan(io.modelcontextprotocol.server.McpAsyncServerExchange exchange, Map<String, Object> arguments) Handles execution of theget_query_execution_plantool.
-
Constructor Details
-
QueryAnalysisTool
public QueryAnalysisTool()
-
-
Method Details
-
handleGetQueryExecutionPlan
public static reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult> handleGetQueryExecutionPlan(io.modelcontextprotocol.server.McpAsyncServerExchange exchange, Map<String, Object> arguments) Handles execution of theget_query_execution_plantool.- Parameters:
exchange- MCP server exchangearguments- tool arguments containing the SQL query- Returns:
- reactive MCP tool result with execution plan
-
getExecutionPlan
Generates an execution plan for the provided SQL query.This method:
- Validates the query to reject data-modifying operations
- Executes
EXPLAIN <query>to generate the plan - Formats the plan output for readability
- Parameters:
query- SQL query to analyzeexplainType- PLAN or MAPPING- Returns:
- MCP response containing the formatted execution plan or error
-