|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +--- |
| 4 | + |
| 5 | +# Installation |
| 6 | + |
| 7 | +You can install the MCP Server plugin to turn any WordPress site into a fully functioning MCP server. |
| 8 | + |
| 9 | +[](https://mcp-wp.github.io/mcp-server/mcp.zip) |
| 10 | + |
| 11 | +This WordPress plugin aims to implement the new [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http), as described in the latest MCP specification. It is supposed to work with any MCP client that supports this transport, but it has been tested mostly with the [WP-CLI AI command](https://github.com/mcp-wp/ai-command). |
| 12 | + |
| 13 | +Under the hood it uses the [`logiscape/mcp-sdk-php`](https://github.com/logiscape/mcp-sdk-php) package to set up a fully functioning MCP server. Then, this functionality is exposed through a new `wp-json/mcp/v1/mcp` REST API route in WordPress. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Install the latest version of the plugin, either via the link above or the following WP-CLI command: |
| 18 | + |
| 19 | +```bash |
| 20 | +wp plugin install --activate https://github.com/mcp-wp/mcp-server/archive/refs/heads/main.zip |
| 21 | +``` |
| 22 | + |
| 23 | +Then, go to Users -> Profile in your WordPress admin and create a new application password. |
| 24 | + |
| 25 | +After that, you can add the MCP server to your WP-CLI config like so: |
| 26 | + |
| 27 | +```bash |
| 28 | +wp mcp server add "mysite" "https://johndie:yourapplicationpassword@example.com/wp-json/mcp/v1/mcp" |
| 29 | +``` |
| 30 | + |
| 31 | +To verify that it works as expected, you can run something like this: |
| 32 | + |
| 33 | +```bash |
| 34 | +wp ai --skip-builtin-servers "List my most recent posts" |
| 35 | +``` |
| 36 | + |
| 37 | +`--skip-builtin-servers` ignores the MCP server of your local installation so that only the remote one is connected to. |
| 38 | + |
| 39 | +Example using cURL: |
| 40 | + |
| 41 | +```bash |
| 42 | +curl -i -X POST -H "Content-Type: application/json" http://johndoe@yourapplicationpassword:example.com/wp-json/mcp/v1/mcp -d '{"jsonrpc":"2.0", "method":"initialize", "id": "0"}' |
| 43 | +``` |
| 44 | + |
| 45 | +## Testing |
| 46 | + |
| 47 | +You can also test this plugin's functionality with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is a developer tool for testing and debugging MCP servers. |
| 48 | + |
| 49 | +For this purpose, the plugin also supports authentication via the `Authorization` header, so you can pass the application password like so: |
| 50 | + |
| 51 | +```http |
| 52 | +Authorization: Bearer johndoe:yourapplicationpassword |
| 53 | +``` |
| 54 | + |
| 55 | +Example using cURL: |
| 56 | + |
| 57 | +```bash |
| 58 | +curl -i -X POST -H "Content-Type: application/json" -H "Authorization: Bearer johndoe:yourapplicationpassword" http://example.com/wp-json/mcp/v1/mcp -d '{"jsonrpc":"2.0", "method":"initialize", "id": "0"}' |
| 59 | +``` |
0 commit comments