show_query_history
Retrieve executed query history to audit data access, analyze performance patterns, and troubleshoot Trino operations.
Instructions
Get the history of executed queries
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | maximum number of history entries to return |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server.py:221-234 (handler)The main tool handler function decorated with @mcp.tool. Takes an optional 'limit' parameter and returns query history as a JSON string by calling client.get_query_history().
@mcp.tool(name="show_query_history", description="Get the history of executed queries") def show_query_history( limit: int = Field(description="maximum number of history entries to return", default=None), ) -> str: """Get the history of executed queries. Args: limit: maximum number of history entries to return. If None, returns all entries. Returns: str: JSON-formatted string containing query history. """ return client.get_query_history(limit) - src/trino_client.py:86-98 (helper)Helper method that constructs and executes the SQL query to fetch query history from system.runtime.queries. Adds LIMIT clause if specified.
def get_query_history(self, limit: int) -> str: """Retrieve the history of executed queries. Args: limit (Optional[int]): Maximum number of queries to return. If None, returns all queries. Returns: str: JSON-formatted string containing query history. """ query = "SELECT * FROM system.runtime.queries" if limit is not None: query += f" LIMIT {limit}" return self.execute_query(query)