execute_sql
Execute SQL queries to retrieve or manipulate data in InterSystems IRIS databases. Use this tool to run queries with optional parameters for database operations.
Instructions
Execute an SQL query on the Server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| params | No |
Implementation Reference
- src/mcp_server_iris/server.py:155-155 (registration)Registers the execute_sql tool with the MCP server using the @server.tool decorator.@server.tool(description="Execute an SQL query on the Server")
- src/mcp_server_iris/server.py:156-167 (handler)The core handler function for the execute_sql tool. It takes a SQL query and optional parameters, executes it on the IRIS database connection from the context, limits results to 100 rows, and returns the results as a list of TextContent.async def execute_sql( query: str, ctx: Context, params: list[str] = [] ) -> list[types.TextContent]: # params = arguments.get("params", []) logger.info(f"Executing SQL query: {query}") conn = ctx.db with conn.cursor() as cursor: cursor.execute(query, params) # limit by 100 rows rows = cursor.fetchall()[:100] return [types.TextContent(type="text", text=str(rows))]