The 5 MCP tools
Tool names, parameters, and what each one returns to the AI editor.
For: developers writing prompts that should drive the editor to use QueryDeck.
QueryDeck's MCP server exposes five tools. The names are stable — your prompts and AI agent rules can reference them directly.
execute_query
Run a SQL query against the active QueryDeck connection.
Parameters:
| Name | Type | Required | Notes |
|---|---|---|---|
query | string | yes | The SQL to run. Reads (SELECT, SHOW, EXPLAIN) are allowed by default. Writes are blocked unless explicitly enabled. |
connection | string | no | Connection name. Defaults to the currently active connection in the QueryDeck app. |
limit | integer | no | Cap on rows returned. Defaults to the configured maxRowLimit (default 1000). Capped at the same value. |
Returns: A formatted text block with the column headers, the row data (table-rendered for small results, JSON-list for larger ones), the row count, and the execution time.
Example prompt:
"Count active users by country, top 10."
The AI generates a SQL SELECT and calls execute_query with it. The result lands back in the conversation.
Blocked by:
- Trial expired without license → error.
- Write keyword in query and
allowWrites: false→ error. - Query exceeds
queryTimeoutSeconds→ cancelled, error returned.
get_schema
Return the schema for a single table or the entire database.
Parameters:
| Name | Type | Required | Notes |
|---|---|---|---|
table | string | no | Table name. If omitted, returns the list of tables across all schemas. |
connection | string | no | Connection name. Defaults to the active connection. |
include | array of strings | no | Subset of ["columns", "indexes", "foreign_keys", "triggers"]. Defaults to all. |
Returns: Structured text with the table's columns (name, type, nullable, default), indexes (name, columns, unique), foreign keys (source column, referenced table.column, rules), and triggers if requested.
Example prompt:
"What does the
orderstable look like?"
search_schema
Find tables and columns by name or fragment.
Parameters:
| Name | Type | Required | Notes |
|---|---|---|---|
query | string | yes | The fragment to search for. Matches against table names, column names, and column comments. |
connection | string | no | Defaults to the active connection. |
kind | string | no | tables, columns, or all (default). |
Returns: A list of matching objects with their containing table, type, and a short description if available.
Example prompt:
"Where is the email stored?"
The AI calls search_schema with query: "email" and gets back something like:
users.email VARCHAR(255) — Primary email
contacts.email_addr VARCHAR(255)
admins.email VARCHAR(255) — Admin login email
audit.email_changes VARCHAR(255)Useful when you don't remember the exact column name.
explain_query
Run EXPLAIN (or the database's equivalent) on a query and return the plan.
Parameters:
| Name | Type | Required | Notes |
|---|---|---|---|
query | string | yes | The SQL to plan. |
connection | string | no | Defaults to the active connection. |
analyze | boolean | no | If true, runs EXPLAIN ANALYZE (executes the query). Defaults to false. |
Returns: The query plan as text — tree-formatted for PostgreSQL, table-formatted for MySQL.
Example prompt:
"Why is this query slow?" (paired with the SQL the user just ran)
The AI calls explain_query and gets back the plan, then reasons about indexes, joins, and selectivity.
Notes:
analyze: truerequires write-equivalent permissions on some databases (it executes the query). It's allowed in MCP because it's a read-only execution from the database's perspective — no rows are mutated.- For
INSERT/UPDATE/DELETEqueries withanalyze: true, the write guard still applies.
check_drift
Run the same Drift Mode comparison the QueryDeck app would, and return the result.
Parameters:
| Name | Type | Required | Notes |
|---|---|---|---|
connection | string | no | Defaults to the active connection. |
verbose | boolean | no | If true, includes per-card detail in the response. Defaults to false (summary only). |
Returns: A summary of how many drift items were found, by severity, plus the list of items in human-readable sentences. If verbose: true, each item includes the ORM value and the DB value side by side.
Example prompt:
"Is my Prisma schema in sync with the database?"
The AI calls check_drift and either reports "in sync" or lists the divergences with their severity.
Notes:
- Requires the connection to have been opened via
qdeck(so the ORM is known) or for the project to be discoverable from the current working directory. - Returns "not supported" for ORMs without a Drift parser (Knex, Sequelize, others).
Error handling
All five tools return errors in MCP's standard error envelope:
| Error code | Meaning |
|---|---|
-32601 | Unknown tool name |
-32602 | Invalid or missing parameters |
-32603 | Internal error — usually means QueryDeck is offline or the socket is stuck |
| Custom (positive) | Database returned an error (full text in the message) |
The AI editor surfaces the error message in the chat, so you'll see what went wrong.