QueryDeck Docs
MCP Server

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:

NameTypeRequiredNotes
querystringyesThe SQL to run. Reads (SELECT, SHOW, EXPLAIN) are allowed by default. Writes are blocked unless explicitly enabled.
connectionstringnoConnection name. Defaults to the currently active connection in the QueryDeck app.
limitintegernoCap 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:

NameTypeRequiredNotes
tablestringnoTable name. If omitted, returns the list of tables across all schemas.
connectionstringnoConnection name. Defaults to the active connection.
includearray of stringsnoSubset 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 orders table look like?"

search_schema

Find tables and columns by name or fragment.

Parameters:

NameTypeRequiredNotes
querystringyesThe fragment to search for. Matches against table names, column names, and column comments.
connectionstringnoDefaults to the active connection.
kindstringnotables, 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:

NameTypeRequiredNotes
querystringyesThe SQL to plan.
connectionstringnoDefaults to the active connection.
analyzebooleannoIf 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: true requires 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/DELETE queries with analyze: true, the write guard still applies.

check_drift

Run the same Drift Mode comparison the QueryDeck app would, and return the result.

Parameters:

NameTypeRequiredNotes
connectionstringnoDefaults to the active connection.
verbosebooleannoIf 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 codeMeaning
-32601Unknown tool name
-32602Invalid or missing parameters
-32603Internal 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.

What's next

  • Safety — what's blocked and how to allow writes if you really need to
  • Install — if you haven't set up the editor yet
  • Uninstall — clean removal