WP Manifestindependent plugin directory
manifest / developer / mcp-wpdb

MCP WPDB

Adds read-only DB query and schema inspection tools to the MCP Adapter plugin.

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/bradvin/mcp-wpdb/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Adds database inspection tools to the WordPress mcp-adapter plugin.

The plugin exposes two MCP tools:

  • db_query
  • db_schema

These tools are intended for authenticated WordPress users who can manage_options.

Requirements

  • WordPress 6.9+
  • PHP 7.4+
  • mcp-adapter
  • WordPress Abilities API available in the site runtime

What It Does

db_query

Runs a restricted SQL query against the local WordPress database.

Input:

  • sql string
  • params string array for ? placeholders

Current intent is read-oriented usage only. The plugin blocks many obvious non-read-only statements, but this is validation-based, not a database privilege boundary.

db_schema

Reads schema information from INFORMATION_SCHEMA.

Input:

  • no args: lists tables in the current database
  • table: returns columns and indexes for a specific table

Installation

  1. Copy this plugin into wp-content/plugins/mcp-wpdb
  2. Activate mcp-adapter
  3. Activate mcp-wpdb
  4. Visit Settings -> MCP WPDB

Authentication

For HTTP MCP access, use a WordPress username and Application Password.

The MCP client should send:

Authorization: Basic base64("username:application-password")

The MCP route is authenticated by WordPress first. After that:

  • mcp-adapter allows transport access
  • mcp-wpdb checks manage_options before executing db_query or db_schema

MCP Endpoint

Default endpoint:

/wp-json/mcp/mcp-adapter-default-server

Example local endpoint:

http://localhost:10003/wp-json/mcp/mcp-adapter-default-server

Client Setup

The plugin settings page shows generated connection examples for:

  • direct HTTP with Basic Auth
  • bridge-based stdio using @automattic/mcp-wordpress-remote@latest

Example Direct HTTP Config

{
  "mcpServers": {
    "wordpress": {
      "type": "http",
      "url": "http://localhost:10003/wp-json/mcp/mcp-adapter-default-server",
      "headers": {
        "Authorization": "Basic ${WP_MCP_BASIC_AUTH}"
      }
    }
  }
}

To create WP_MCP_BASIC_AUTH:

printf '%s' 'YOUR_WP_USERNAME:YOUR_WP_APPLICATION_PASSWORD' | base64

Example Tool Calls

db_schema

{
  "name": "db_schema",
  "arguments": {}
}
{
  "name": "db_schema",
  "arguments": {
    "table": "wp_posts"
  }
}

db_query

{
  "name": "db_query",
  "arguments": {
    "sql": "SELECT option_name, option_value FROM wp_options ORDER BY option_id DESC LIMIT ?",
    "params": ["5"]
  }
}

Notes

  • db_query uses the normal WordPress database connection.
  • Query restrictions are implemented in PHP validation logic.
  • If you need a stronger read-only guarantee, use a separate MySQL user with read-only privileges.

Admin UI

The plugin adds a setup page at:

Settings -> MCP WPDB

This page shows:

  • the detected site URL
  • the generated MCP endpoint
  • direct HTTP setup
  • bridge setup
  • expected tool names