warden_db_query
Execute SQL queries in Magento databases within Warden-managed development environments to manage and retrieve data.
Instructions
Run a SQL query in the Warden database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | Path to the project directory | |
| query | Yes | SQL query to execute | |
| database | No | Database name (optional, defaults to magento) | magento |
Implementation Reference
- server.js:547-569 (handler)The main handler function that implements the 'warden_db_query' tool. It destructures the arguments, builds a 'warden env exec db mysql ...' command to execute the provided SQL query in the specified database (default 'magento'), and calls executeWardenCommand to run it and format the response.
async runDbQuery(args) { const { project_path, query, database = "magento" } = args; const wardenCommand = [ "env", "exec", "-T", "db", "mysql", "-u", "root", "-pmagento", database, "-e", query, ]; return await this.executeWardenCommand( project_path, wardenCommand, `Running database query in ${database}`, ); } - server.js:103-121 (schema)Input schema definition for the warden_db_query tool, specifying required project_path and query parameters, and optional database (defaults to 'magento').
inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the project directory", }, query: { type: "string", description: "SQL query to execute", }, database: { type: "string", description: "Database name (optional, defaults to magento)", default: "magento", }, }, required: ["project_path", "query"], }, - server.js:100-122 (registration)Tool registration entry in the ListToolsRequestSchema handler's tools array, defining the name, description, and input schema for 'warden_db_query'.
{ name: "warden_db_query", description: "Run a SQL query in the Warden database", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the project directory", }, query: { type: "string", description: "SQL query to execute", }, database: { type: "string", description: "Database name (optional, defaults to magento)", default: "magento", }, }, required: ["project_path", "query"], }, }, - server.js:331-332 (registration)Handler dispatch registration in the CallToolRequestSchema switch statement, mapping 'warden_db_query' to the runDbQuery method.
case "warden_db_query": return await this.runDbQuery(request.params.arguments);