Skip to main content
Glama

Run a database query

execute_sql_query

Run single SQL queries on a WordPress database with enforced row limits and mutating statements blocked until preview confirmation. Use when REST API and WP-CLI cannot access the data.

Instructions

Run a SQL query against the WordPress database through the companion plugin. SELECT/SHOW/DESCRIBE/EXPLAIN run immediately with an enforced row limit. Anything that mutates data is blocked unless you pass allow_mutation: true, and even then it first returns a preview and a confirm_token that you must echo back — stacked statements are always refused. Reach for this only when the REST API and WP-CLI cannot get at the data: raw SQL bypasses WordPress hooks, so caches are not invalidated and plugin logic does not run.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesA single SQL statement. Use the site's real table prefix — get it from site_info if you are unsure it is wp_.
site_idNoWhich configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids.
max_rowsNoRow ceiling. A LIMIT is appended automatically to unbounded SELECTs.
confirm_tokenNoToken returned by the preview, required to actually run a mutating statement.
allow_mutationNoPermit a data-changing statement. Still requires a confirm_token from the preview.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description reveals critical behavioral details beyond the annotations: row limits are enforced, mutations are blocked by default, a preview and confirm_token are required, stacked statements are refused, and bypassing WordPress hooks means caches are not invalidated. This goes far beyond the sparse annotation hints and gives the agent a complete behavioral picture.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise yet information-dense, front-loading the purpose, then the safety mechanism, and finally the usage caveat. Every sentence adds necessary information with no fluff or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with mutation safety and multiple parameters, the description covers all essential aspects: what it does, when to use it, safety gating, the two-step confirmation flow, and the consequences of using raw SQL. The agent has everything needed to call it correctly, even without an output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All parameters have schema descriptions (100% coverage), so the baseline is 3. The description adds value by explaining the dependency between allow_mutation and confirm_token (preview flow) and noting that max_rows triggers an automatic LIMIT. This clarifies interactions not obvious from the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool runs a SQL query against the WordPress database, specifies the immediate execution of read-type statements, and explicitly distinguishes it from the REST API and WP-CLI by stating it should be used only when those cannot access the data. This provides a precise verb+resource and sets it apart from sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit usage guidance: use this tool only when the REST API and WP-CLI are insufficient. It also explains the mutation safety flow, noting that mutations require allow_mutation and a confirm_token, which tells the agent when and how to use the tool safely.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alokemajumder/wpxmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server