
WordPress MCP Server
io.github.rnaga由 GitHub 账号 rnaga 发布v1.0.9更新于 Oct 24, 2026
MCP server for WordPress. Manage posts, users, comments, terms, metadata, and settings.
概览
一个本地 MCP 服务器,让助手直接连接 WordPress 数据库,创建、编辑和发布文章,并管理用户、评论、分类项和站点设置。
- 可以做什么
- 创建、更新、读取和删除文章及其修订版本,可直接起草并发布到数据库,无需经过 wp-admin。审核评论并添加回复。查看用户、调整角色和停用账户,可用工具按所假定用户的 WordPress 权限过滤。管理分类、标签和自定义分类法。读取、创建、更新和删除文章、用户、评论、分类项及站点元数据。切换站点设置和选项。
- 适用场景
- 适合让助手起草、修改并发布 WordPress 内容、审计用户与权限,或从 Claude Desktop 等 MCP 客户端调整分类法和站点设置,而无需进入 wp-admin。
- 运行要求
- 通过 npx 在本地运行,需要 Node.js。需要直接访问数据库:WP_DB_HOST、WP_DB_NAME、WP_DB_USER 和 WP_DB_PASSWORD,以及 LOCAL_USERNAME(决定可用工具的 WordPress 用户)。另有可选的 SSL 和多站点变量。README 还介绍了使用 OAuth 或应用程序密码的 HTTP 服务器和远程代理。
安装
在 SourceWeft 中
- 打开 控制台中的 WordPress MCP Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
wp-mcp
@rnaga/wp-mcp is a Model Context Protocol (MCP) server for WordPress that turns your site into an AI-operable surface. By exposing WordPress CRUD primitives to clients like Claude Desktop, an assistant can draft a post on demand, refine it collaboratively, and publish it straight into your database—no trip through wp-admin required.
Here are a few common scenarios this unlocks:
- Draft, revise, and publish posts directly from MCP clients such as Claude Desktop.
- Inspect WordPress users, their roles, and capabilities to audit site permissions or generate access reports.
Built on top of @rnaga/wp-node, the server ships with a curated MCP toolset covering posts, users, comments, terms, revisions, metadata, options, and site settings. The MCP server can manage the following database tables/resources:
You can spin up a STDIO server for direct database access or host a Streamable HTTP MCP server for remote access. For convenience, layer on the CLI proxy whenever your MCP client needs a local bridge to the HTTP server. The proxy behaves like a local MCP server while relaying requests to the HTTP endpoint—perfect for clients that lack OAuth or WordPress Application Password support—so you can fit MCP workflows into existing editorial pipelines without re-implementing WordPress business logic.
The project includes a CLI (wp-mcp) that helps you:
- configure and launch a local STDIO MCP server that connects straight to your WordPress database;
- scaffold and initialize an Express-based Streamable HTTP MCP server (with env/TS boilerplate);
- authenticate against a remote WordPress environment (OAuth or Application Password) and run a JSON-RPC proxy so MCP clients can reach it securely;
- inspect available MCP primitives and manage the credentials stored under
~/.wp-mcp.
Run this command to list the available CLI commands:
Together, the server, CLI utilities, and proxy tooling let you CRUD WordPress content, manage users, and sync settings through the MCP standard without re-implementing WordPress logic.
Getting Started
Local STDIO server
Run the STDIO server when you can reach the database directly. The CLI launches an MCP process that assumes a WordPress user locally and exposes your site's tools over STDIO to the MCP client.
-
Run the CLI to set up the database connection:
The CLI prompts you for
host,port,database name,user, andpassword. If your database requires SSL, you can provide CA, cert, and key file paths to secure remote access. Runnpx @rnaga/wp-mcp local configanytime to review the saved values. -
Configure your MCP client to launch the server. For Claude Desktop, open Settings → Developer → Edit Config and add this to your
claude_desktop_config.json:Activate the server: Save the config file, then quit and restart your MCP client (for example, Claude Desktop). The WordPress tools will now appear in the MCP indicator at the bottom right of the chat input.
Important: Replace
wp-adminwith your WordPress username. The server uses this to determine which MCP primitives are available based on the user's WordPress capabilities. For example, administrator roles get full access to all primitives (create, update, delete posts, manage users, etc.), while subscriber roles see only limited tools. This capability-based filtering prevents accidental execution of privileged operations. To see which primitives are available and the required capabilities and roles for each:This displays a table showing the primitive name, title, description, required capabilities, and allowed roles.
Optional: Provide a WordPress config manifest if your project defines one (e.g.,
src/_wp/config/wp.json). SetLOCAL_CONFIGin theenvobject above to the absolute path of your config file. If you don't have a custom config, omit this environment variable entirely. For the configuration manifest schema, see https://rnaga.github.io/wp-node/docs/getting-started/configuration.Testing the MCP server:
Use the MCP Inspector for interactive testing and debugging:
This opens a visual interface at
http://localhost:6274where you can explore available tools, test them with different arguments, and inspect server responses.Note: Inspector persists its "Environment Variables" panel in browser storage across sessions. If you previously added a
PATHentry there while troubleshooting, delete it manually in the UI — a stale value can shadow the environment the server actually needs and won't be overridden by CLI flags or script changes.
Usage reference for CLI flags and environment variables:
MCP Streamable HTTP server
Use the HTTP server when you need to expose MCP over the Internet or let remote teammates connect. The CLI scaffolds an Express app (see src/http/express/index.ts) that exposes both the MCP streaming HTTP transport and the SSE fallback while reusing the same primitive registry.
-
Scaffold a project
The wizard prompts for database connection details, creates a
wp-nodeproject, and seeds Express boilerplate plus TypeScript configuration for the HTTP transport.Resulting layout:
Populate
.envwith the values requested by the scaffolder and any HTTP-specific environment variables listed later in this document. -
Run the server in development
This relies on
ts-nodeso you can iterate without precompiling. -
Build and run in production
The compiled output boots the same Express server that
createHttpServerwires together in the library.
Connect via the Remote Proxy CLI
Use the remote proxy when your MCP client only understands STDIO or lacks full OAuth support but the WordPress environment is available over HTTP. The proxy keeps credentials in ~/.wp-mcp and relays MCP requests to the remote server with the right Authorization header.
-
Authenticate once
Begin by enrolling the proxy with either WordPress Application Password credentials or an OAuth device flow so it can sign requests on behalf of your MCP client.
-
WordPress Application Password
Provide the authorization URL for your server (for example
http://localhost:3000), then enter the WordPress username and application password. The credentials are stored securely so future proxy runs can supply HTTP Basic auth automatically (WordPress Application Passwords are transmitted via the Basic scheme.)Inspect the stored values with:
-
OAuth device flow
The CLI calls
/auth/device/start, prints the user code, and opens the verification URL in your browser. After you complete the device flow, the access and refresh tokens are written to~/.wp-mcp. You can re-runremote configorremote revoke-tokenas needed.
Use
npx @rnaga/wp-mcp -- remote config-clearif you ever need to remove stored secrets. -
-
Start the proxy
Configure Claude Desktop (or another MCP client) the same way you do for the local STDIO server, but point the command to the proxy:
Adjust the REMOTE_AUTH_TYPE (oauth or password) and REMOTE_URL to match your remote endpoint. You can also pass these at runtime with --authType and --remoteUrl. The proxy validates your saved credentials, refreshes OAuth tokens when they are within five minutes of expiry, and then exposes a local STDIO MCP server that delegates every call to the remote HTTP transport.
Once running, your client speaks STDIO locally while the proxy relays traffic to the remote Express server.
Streamable HTTP Server Internals
The Streamable HTTP deployment bundles Express middleware that bootstraps a WordPress context on each request, registers both the streaming HTTP and SSE transports, and layers in caching plus OAuth metadata handlers. The remote server operates as an OAuth 2.0 resource server — clients must supply either a bearer token or a WordPress Application Password, and the server never behaves as an OAuth client itself. Discovery metadata is served from /.well-known/oauth-protected-resource, keeping the implementation aligned with RFC 9728.
The CLI's device-code helper (npx @rnaga/wp-mcp -- remote login oauth) extends the MCP tooling with a terminal-friendly flow. It talks to the server's /auth/device/* endpoints, stores the resulting tokens in the secret vault (~/.wp-mcp), and enables the proxy to refresh and attach bearer credentials automatically.
Access Control
The HTTP layer applies authentication across /mcp and /sse so only authorized callers can negotiate sessions. It supports:
- OAuth Bearer tokens – validated through the configured provider, with access tokens mapped to WordPress users before the MCP session initializes.
- WordPress Application Passwords – accepted over HTTP Basic auth and verified before the WordPress user is assumed server-side.
Failed bearer requests receive RFC 6750-compliant WWW-Authenticate headers that include the authorization URI and requested scopes so clients can recover gracefully.
Endpoints
Supported OAuth providers
The server ships with provider profiles for GitHub, Google, and Auth0. Each profile encapsulates device-code issuance, token polling, refresh, and revocation logic that can be wired in when you instantiate the HTTP server. To use a different identity system, supply your own provider implementation through the same hook and keep the rest of the deployment unchanged.
Setting up OAuth providers
To enable OAuth authentication, you need to register an application with your chosen provider and configure the credentials in your environment variables.
GitHub OAuth Setup
- Create an OAuth App: Navigate to GitHub Developer Settings > OAuth Apps > "New OAuth App"
- Configure your application:
- Application Name: Your app's display name
- Homepage URL: Your application's homepage
- Authorization Callback URL: Your OAuth callback endpoint
- Get credentials: After creation, note your Client ID and generate a Client Secret
- Set environment variables:
- Documentation: GitHub OAuth Apps Documentation
Google OAuth Setup
- Access Google Cloud Console: Go to Google Cloud Console
- Create OAuth credentials: Navigate to Menu > APIs & Services > Credentials > Create Credentials > OAuth client ID
- Configure OAuth consent screen: Set up app name, user support email, and audience settings
- Select application type: Choose the appropriate type (Web application, Desktop app, etc.)
- Get credentials: Note your Client ID and Client Secret
- Set environment variables:
- Documentation: Setting up OAuth 2.0 in Google Cloud
Auth0 OAuth Setup
- Create application: Register a Native Application in your Auth0 Dashboard
- Configure grant types: In Application Settings > Advanced > Grant Types, enable:
- Device Code (required for device flow)
- Refresh Token (optional, for token refresh)
- Enable OIDC Conformant: In Application Settings > Advanced > OAuth, ensure OIDC Conformant is enabled
- Configure connections: Set up and enable at least one connection for the application
- Get credentials: Note your Client ID, Client Secret, and Domain
- Set environment variables:
- Documentation: Auth0 Device Authorization Flow
Usage reference for environment variables
The HTTP server loads its configuration from environment variables—typically via a local .env file, inherited process environment, or settings provided by your hosting platform.
If a variable is omitted, the server falls back to safe defaults (for example CORS defaults to *, DNS rebinding protection is disabled, and OAuth metadata is skipped). Set only the values your provider requires.
Developing Custom MCP Primitives
The Model Context Protocol defines three first-class primitives: tools (callable actions), resources (readable assets exposed by URI), and prompts (templated message sequences). defaultMcpPrimitives in this package currently ships tool implementations, but the same decorator + registration pattern lets you expose resources and prompts as well. The workflow below covers scaffolding, authoring a class, and wiring it into each transport.
1. Scaffold a project
Use the CLI to initialize the TypeScript scaffolding and install dependencies.
Local STDIO server
The command implemented in src/cli/local.cli.ts installs @rnaga/wp-node and @rnaga/wp-mcp, places a starter src/index.ts, copies tsconfig.json, creates a .gitignore, and adds dev, build, and start scripts to package.json.
Resulting layout:
Streamable HTTP server
This subcommand (see src/cli/http.cli.ts) runs the WordPress prompts, installs the same dependencies, copies the HTTP src/index.ts template, and appends the MCP-specific settings to .env or .env.<environment>. After the scaffold finishes you can run npm run dev to boot the Express transport.
2. Implement a primitive class
Create a file such as src/mcp/example-suite.mcp.ts and add a class decorated with @mcp and @mcpBind. Each @mcpBind method receives the MCP server instance plus runtime metadata so you can register tools, resources, or prompts in one place.
See the @modelcontextprotocol/typescript-sdk repository for end-to-end SDK usage and primitive registration examples.
Each handler receives the same tuple:
server– theMcpServerinstance from@modelcontextprotocol/sdk/server/mcp.js, which exposesregisterTool,registerResource, andregisterPrompt.username– the WordPress identity attached to the session; pass it toMcps.getWpContextto enforce capability checks when you touch WordPress APIs.meta– the decorator metadata (name,title,description, capabilities, roles) that you can reuse when you register primitives.
Mcps.getWpContext yields the hydrated @rnaga/wp-node context. Use it inside tools, resources, or prompts to call CRUD helpers, gather site metadata, or enforce additional logic before returning MCP responses.
3. Register the class with the server entry point
Both transports expose an mcps array; append your class so the server wires it up when booting. All primitives registered inside the class methods (tools, resources, prompts) become available to connected MCP clients.
Local STDIO server
Streamable HTTP server
Start the server (npm run dev locally or npm start after building) and the registered tools, resources, and prompts appear to any MCP client connected through the local proxy or HTTP transport.
MCP Registry
This server is published to the Model Context Protocol Registry, making it easily discoverable and installable by MCP clients.
You can find the server at: https://registry.modelcontextprotocol.io/v0/servers?search=wp-mcp&version=latest
The registry entry includes configuration details, required environment variables, and installation instructions.
来源:README.md,提交 4953e04
工具
0版本历史
1- v1.0.9最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。