Install
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.zipAdds database inspection tools to the WordPress mcp-adapter plugin.
The plugin exposes two MCP tools:
db_querydb_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:
sqlstringparamsstring 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
- Copy this plugin into
wp-content/plugins/mcp-wpdb - Activate
mcp-adapter - Activate
mcp-wpdb - 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-adapterallows transport accessmcp-wpdbchecksmanage_optionsbefore executingdb_queryordb_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_queryuses 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