localwp-mcp
v0.1.11
Published
A LocalWP-aware MCP server for WordPress developers with simple safe and full-access profiles, logs, doctor diagnostics, SQL access, backups, restore flows, MCP resources/prompts, and site-aware WP-CLI.
Downloads
145
Maintainers
Readme
localwp-mcp
localwp-mcp gives AI agents direct access to LocalWP sites through MCP.
It automatically finds your Local sites, uses the correct Local PHP and MySQL runtimes for each one, and lets an agent work with WordPress through WP-CLI, MySQL, logs, diagnostics, backups, and restore flows.
What You Can Do
- inspect Local sites and their runtime details
- start, stop, and restart Local sites
- list, read, search, write, and delete files inside a selected Local site
- run WP-CLI against the correct site
- query the WordPress database
- allow full database writes when you want unrestricted local development
- read recent logs and run site health checks
- export, import, back up, and restore LocalWP sites
Install
Use npx in your MCP client:
{
"mcpServers": {
"localwp": {
"command": "npx",
"args": ["-y", "localwp-mcp"],
"env": {
"LOCALWP_MCP_PROFILE": "safe"
}
}
}
}localwp-mcp currently supports STDIO clients. Streamable HTTP is not supported yet.
If you want the MCP to focus on one site by default, set:
{
"LOCAL_SITE_NAME": "example-site"
}Client Setup
Use these settings across supported clients:
- transport:
STDIO - command:
npx - arguments:
-y,localwp-mcp - default environment variable:
LOCALWP_MCP_PROFILE=safe - optional environment variables:
LOCAL_SITE_NAMELOCAL_SITE_IDLOCALWP_MCP_BACKUPS_DIR
Do not choose Streamable HTTP. localwp-mcp currently runs as a local stdio MCP server.
Codex Desktop
In Codex Desktop:
- Open
Settings - Open
MCP servers - Add a custom MCP
- Choose
STDIO
Then enter:
- Name:
localwp - Command to launch:
npx - Arguments:
-ylocalwp-mcp
- Environment variables:
LOCALWP_MCP_PROFILE=safe- optional:
LOCAL_SITE_NAME=your-site-name
Cursor
Add this to your Cursor MCP config, for example .cursor/mcp.json:
{
"mcpServers": {
"localwp": {
"command": "npx",
"args": ["-y", "localwp-mcp"],
"env": {
"LOCALWP_MCP_PROFILE": "safe"
}
}
}
}Claude Code
Add the MCP through the Claude Code CLI.
macOS and Linux:
claude mcp add localwp -- npx -y localwp-mcpWindows:
claude mcp add localwp -- cmd /c npx -y localwp-mcpThe space before and after -- is intentional. -- is the separator between the Claude command and the command Claude should launch.
After adding the server, configure:
LOCALWP_MCP_PROFILE=safe- optional:
LOCAL_SITE_NAME=your-site-name
OpenCode
Use a local MCP server entry in your OpenCode config:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"localwp": {
"type": "local",
"command": ["npx", "-y", "localwp-mcp"],
"enabled": true,
"environment": {
"LOCALWP_MCP_PROFILE": "safe"
}
}
}
}Other STDIO MCP Clients
If your MCP client supports launching a local server over STDIO, use:
- command:
npx - arguments:
-y,localwp-mcp - environment:
LOCALWP_MCP_PROFILE=safe
If a client only accepts an MCP URL and cannot launch a local command, it cannot use localwp-mcp yet.
Access Modes
localwp-mcp has 2 access modes:
safeBest default for most people. Safe WordPress inspection commands, read-oriented runtime calls, diagnostics, logs, database reads, and backup/export flows.full-accessBest when you want the agent to fully work on your local site, including SQL writes, imports, restore operations, and explicit WordPress runtime PHP execution.
safe is the default.
To enable full local access:
{
"LOCALWP_MCP_PROFILE": "full-access"
}First Things To Try
Start with:
local_environment_checklocal_doctorlist_local_sites
Those will tell you:
- which Local sites were discovered
- whether the site is running
- which Local runtimes were resolved
- whether WP-CLI and MySQL are reachable
Common Workflows
Inspect a Site
Use:
local_site_infolocal_doctorlocal_logs
local_logs accepts:
siteglobalall- aliases:
both,combined
Work With Site Files
Use:
list_site_filesread_site_filesearch_site_fileswrite_site_filedelete_site_file
These tools are always scoped to the selected site's root directory.
- In
safe, you can list, read, and search files. - In
full-access, you can also write and delete files.
Control a Local Site
Use:
start_local_sitestop_local_siterestart_local_site
Work With WordPress
Use:
execute_wp_cliwp_call_functionwp_call_static_methodexecute_wp_php_readonlyexecute_wp_php
Examples:
- list plugins
- inspect options
- list posts or users
- run plugin-specific WP-CLI commands
- call a function or static method inside the loaded WordPress runtime with explicit JSON args
- run protected read-only PHP snippets or PHP files inside the loaded WordPress runtime
- run high-trust PHP snippets or PHP files inside the loaded WordPress runtime in
full-access
execute_wp_cli is for ordinary WP-CLI commands. It intentionally blocks eval, eval-file, shell, and db query, and blocked commands return structured policy details with suggested alternatives.
wp_call_function and wp_call_static_method are read-oriented runtime inspection tools. They run inside the loaded WordPress runtime with explicit JSON arguments and add best-effort read-only guardrails around common SQL writes, HTTP requests, and outgoing email.
execute_wp_php_readonly is the protected arbitrary-snippet companion to those tools. It runs a PHP snippet or workspace/site .php file inside the loaded WordPress runtime with the same best-effort read-only guardrails, so you can inspect composed logic without jumping straight to unrestricted PHP execution. For snippet workflows, stdout is usually the primary output field, while rawResultType and rawResult preserve the underlying PHP include return value for debugging.
When a read-only tool blocks side effects, the top-level response becomes explicit instead of exposing a success-looking raw mutation result as authoritative. Those responses set outcome to blocked_side_effects, return a wrapped result, preserve the raw callable/snippet return value in rawResultType and rawResult, and include a richer readOnlyState with:
blockedSideEffectsblockedSqlVerbsblockedSqlCountblockedHttpCountblockedMailCountwritesBlockedsideEffectsPreventedtransactionStartedtransactionRolledBacktransactionCommitted
execute_wp_php is the explicit high-trust runtime path for full-access. It runs a PHP snippet or workspace/site .php file inside the selected site's loaded WordPress runtime using a file-based eval-file flow.
Work With the Database
Use:
mysql_queryRead-only SQL insafemysql_executeFull SQL execution infull-accessmysql_schemaTable listing and table description helpers
Back Up or Restore a Site
Use:
backup_sitelist_backupsdelete_backupcleanup_backupsdb_exportdb_importpreview_restore_backuprestore_backup
backup_site supports:
databasefull
The full backup format is folder-based and includes the site's app, conf, and logs directories plus a fresh SQL dump.
If you want to manage backup storage over time:
list_backupsShows the managed backup directories and SQL artifacts for a site.delete_backupRemoves one managed backup artifact infull-access.cleanup_backupsCleans up older backups by age and/or retention count infull-access.
Use preview_restore_backup when you want to inspect the restore plan, effective restore mode, compatibility warnings, and current site state before making changes.
Built-In Capabilities
Tools
list_local_sitesstart_local_sitestop_local_siterestart_local_sitelocal_environment_checklocal_doctorlocal_logslocal_site_infolist_site_filesread_site_filesearch_site_fileswrite_site_filedelete_site_fileexecute_wp_cliwp_call_functionwp_call_static_methodexecute_wp_php_readonlyexecute_wp_phpmysql_querymysql_executemysql_schemadb_exportdb_importbackup_sitelist_backupsdelete_backupcleanup_backupspreview_restore_backuprestore_backup
MCP Resources
localwp://siteslocalwp://sites/{siteName}/summarylocalwp://sites/{siteName}/doctorlocalwp://sites/{siteName}/logs
MCP Prompts
diagnose_local_siterestore_local_site
Platform Support
localwp-mcp is designed for:
- macOS
- Windows
- Linux
It supports both current Local lightning-services layouts and older site-binaries layouts.
Live validation has been completed on:
- macOS
- Windows
Linux support is implemented in the code paths and tests, but has not yet been live-validated on a machine with LocalWP.
Useful Environment Variables
Most users only need these:
LOCALWP_MCP_PROFILELOCAL_SITE_NAMELOCAL_SITE_IDLOCALWP_MCP_BACKUPS_DIR
Advanced override variables also exist for custom Local layouts, but most installations do not need them.
Troubleshooting
If the MCP does not find your site or cannot run WP-CLI/MySQL:
- Start the site in Local.
- Run
local_environment_check. - Run
local_doctor. - Check
local_logs.
Those tools are the fastest way to see whether the problem is:
- site selection
- Local metadata resolution
- WP-CLI resolution
- MySQL connectivity
- missing or stopped Local services
If plain shell wp behaves differently from MCP, call local_site_info.
local_site_info now includes wpCliRuntime, mysqlRuntime, and shellReproduction sections that show the exact Local-managed binaries, working directory, environment overrides, and command arrays this MCP uses. MCP does not rely on your ambient shell wp; it resolves the selected site's Local runtime directly.
For Contributors
Contributor and maintainer docs live outside the main user guide:
