Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea7b71d

Browse filesBrowse files
committed
Docusaurus
1 parent 6534d86 commit ea7b71d
Copy full SHA for ea7b71d
Expand file treeCollapse file tree

24 files changed

+18641
-0
lines changed

‎.gitignore

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

‎README.md

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

‎docs/index.md

Copy file name to clipboard
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Introduction
6+
7+
This projected originally kicked off during the [CloudFest Hackathon 2025](https://hackathon.cloudfest.com/project/wp-cli-mcp-host/) to implement the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) in the WordPress ecosystem, specifically integrating it with WP-CLI.
8+
9+
The core innovation is transforming WordPress into an MCP Server and WP-CLI into an MCP Host through a new package, enabling direct AI interactions with WordPress installations during development. This approach provides developers with powerful AI capabilities without requiring a live site or REST API endpoints.
10+
11+
**WordPress MCP Server Layer:**
12+
13+
1. Implementation of MCP Server interfaces in WordPress
14+
2. Resource providers for posts, pages, media, and other WordPress content types
15+
3. Tool definitions for common WordPress actions (content creation, media handling)
16+
4. Context providers for WordPress configuration and site state
17+
18+
**WP-CLI MCP Host Package:**
19+
20+
1. MCP Host implementation within WP-CLI framework
21+
2. New command namespace for AI operations
22+
3. Integration with (local and remote) LLM providers
23+
4. Transport layer for local WordPress communication
24+
25+
You can think of MCP as the "USB port for LLMs", a standard way for LLMs to interact with any third-party system using things like function calling.
26+
27+
While the Hackathon project focused on WP-CLI, the _MCP Server_ is usage-agnostic and can also be exposed via HTTP.
28+
29+
The _MCP Host_, gets information (such as list of available tools) from the server and passes it on to the LLM (e.g. Gemini).
30+
31+
## Contributors
32+
33+
Original CloudFest Hackathon Contributors:
34+
35+
- Pascal Birchler - [@swissspidy](https://github.com/swissspidy)
36+
- Jan-Willem Oostendorp - [@janw-me](https://github.com/janw-me)
37+
- Joost de Valk - [@jdevalk](https://github.com/jdevalk)
38+
- Marco Chiesi - [@marcochiesi](https://github.com/marcochiesi)
39+
- Matt Biscay - [@skyminds](https://github.com/skyminds)
40+
- Moritz Bappert - [@moritzbappert](https://github.com/moritzbappert)
41+
- James Hunt - [@thetwopct](https://github.com/thetwopct)
42+
- Tome Pajkovski - [@tomepajk](https://github.com/tomepajk)
43+
- David Mosterd - [@davidmosterd](https://github.com/davidmosterd)
44+
- Milana Cap - [@zzap](https://github.com/zzap)

‎docs/mcp-server/_category_.json

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "WordPress MCP Server",
3+
"position": 3,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}
24.8 KB
Loading
27.2 KB
Loading

‎docs/mcp-server/reference.md

Copy file name to clipboard
+106Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Reference
2+
3+
## `Server` class
4+
5+
The `Server` class is a core component of the MCP for WordPress implementation and is a small wrapper around the [MCP PHP SDK](https://github.com/logiscape/mcp-sdk-php).
6+
7+
This class provides:
8+
9+
- Tool registration (`register_tool()`)
10+
- Resource registration (`register_resource()`)
11+
- JSON-RPC request handling (`handle_message()`)
12+
13+
### Examples
14+
15+
Register a Tool
16+
17+
```PHP
18+
$server->register_tool(
19+
[
20+
'name' => 'calculate_total',
21+
'description' => 'Calculate the total amount'
22+
'callable' => function( $params ) {
23+
return $params['price'] * $params['quantity'];
24+
},
25+
'inputSchema' => [
26+
'properties' => [
27+
'price' => [ 'type' => 'integer' ],
28+
'quantity' => [ 'type' => 'integer' ]
29+
],
30+
],
31+
]
32+
);
33+
```
34+
35+
36+
## `RouteInformation` class
37+
38+
The `RouteInformation` class encapsulates metadata about a WordPress REST API route. It provides methods to determine route characteristics, REST method type, and controller details.
39+
40+
This class is used to:
41+
42+
- Identify REST route types (`singular`/`list`, `GET`/`POST`/`DELETE`, etc.).
43+
- Validate and process REST controller callbacks.
44+
- Generate sanitized route names for MCP registration.
45+
46+
### Methods
47+
48+
| Name | Return Type | Description |
49+
|----------------------------------------------------------|-------------|-------------------------------------------------------------|
50+
| `RouteInformation::__construct($route, $method, $title)` | `void` | Initializes the class with a REST route, method, and title. |
51+
| `RouteInformation::get_name()` | `string` | Get a tool name for the route. |
52+
| `RouteInformation::get_description()` | `string` | Get a human-friendly description. |
53+
54+
## `RestApi` class
55+
56+
The `RestApi` class is responsible for mapping WordPress REST API endpoints into MCP tools. It does this by:
57+
58+
- Extracting route details from the REST API.
59+
- Generating input schemas from REST arguments.
60+
- Creating AI tools dynamically based on route metadata.
61+
62+
This enables seamless AI-driven interactions with the WordPress REST API.
63+
64+
### Methods
65+
66+
| Name | Return Type | Description |
67+
|--------------------------------------------------------------------|-------------|-------------------------------------------------------|
68+
| `RestApi::args_to_schema( $args )` | `array` | Converts REST API arguments into a structured schema. |
69+
| `RestApi::sanitize_type( $type )` | `string` | Maps input types to standard schema types. |
70+
| `RestApi::get_tools()` | `array` | Registers REST API endpoints as AI tools in MCP. |
71+
| `RestApi::rest_callable( $inputs, $route, $method_name, $server )` | `array` | Executes a REST API call dynamically. |
72+
73+
## `MediaManager` class
74+
75+
The `MediaManager` class provides a static method to upload a media file to the WordPress Media Library. It:
76+
77+
- Copies a file into the WordPress uploads directory.
78+
- Registers the file as a WordPress media attachment.
79+
- Generates and updates attachment metadata.
80+
81+
This class is useful for automated media uploads within WP-CLI or AI-powered workflows.
82+
83+
### Methods
84+
85+
| Name | Return Type | Description |
86+
|--------------------------------------------------------|-------------|------------------------------------------------------------------|
87+
| `MediaManager::upload_to_media_library( $media_path )` | `int` | Uploads a media file to WordPress and returns its attachment ID. |
88+
89+
## `ImageTools` class
90+
91+
The `ImageTools` class provides AI-powered image generation functionality within WP-CLI.
92+
It:
93+
94+
- Integrates AI-based image generation tools.
95+
- Registers the tool in the system for easy access.
96+
- Uses a client to fetch AI-generated images.
97+
98+
This class is used to dynamically generate images based on user prompts.
99+
100+
### Methods
101+
102+
| Name | Return Type | Description |
103+
|---------------------------------------|-------------|----------------------------------------------|
104+
| `ImageTools::__construct( $client )` | `void` | Initializes ImageTools with an AI client. |
105+
| `ImageTools::get_tools()` | `array` | Returns a list of available AI tools. |
106+
| `ImageTools::image_generation_tool()` | `Tool` | Creates an AI-powered image generation tool. |

‎docs/wp-cli/_category_.json

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "WP-CLI",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "WP-CLI Usage"
7+
}
8+
}

‎docs/wp-cli/commands.md

Copy file name to clipboard
+125Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Commands
2+
3+
This package implements the following commands:
4+
5+
### wp ai
6+
7+
AI prompt.
8+
9+
~~~
10+
wp ai <prompt> [--skip-wordpress]
11+
~~~
12+
13+
**OPTIONS**
14+
15+
```
16+
<prompt>
17+
AI prompt.
18+
19+
[--skip-wordpress]
20+
Run command without loading WordPress. (Not implemented yet)
21+
```
22+
23+
**EXAMPLES**
24+
25+
```
26+
# Get data from WordPress
27+
$ wp ai "What are the titles of my last three posts?"
28+
- Hello world
29+
- My awesome post
30+
- Another post
31+
32+
# Interact with multiple MCP servers.
33+
$ wp ai "Take file foo.txt and create a new blog post from it"
34+
Success: Blog post created.
35+
```
36+
37+
38+
### wp mcp server list
39+
40+
Lists available MCP servers.
41+
42+
~~~
43+
wp mcp server list [--format=<format>]
44+
~~~
45+
46+
**OPTIONS**
47+
48+
```
49+
[--format=<format>]
50+
Render output in a particular format.
51+
---
52+
default: table
53+
options:
54+
- table
55+
- csv
56+
- json
57+
- count
58+
---
59+
```
60+
61+
**EXAMPLES**
62+
63+
```
64+
# Greet the world.
65+
$ wp mcp server list
66+
Success: Hello World!
67+
68+
# Greet the world.
69+
$ wp ai "create 10 test posts about swiss recipes and include generated featured images"
70+
Success: Hello World!
71+
```
72+
73+
74+
### wp mcp server add
75+
76+
Add a new MCP server to the list
77+
78+
~~~
79+
wp mcp server add <name> <server>
80+
~~~
81+
82+
**OPTIONS**
83+
84+
```
85+
<name>
86+
Name for referencing the server later
87+
88+
<server>
89+
Server command or URL.
90+
```
91+
92+
**EXAMPLES**
93+
94+
```
95+
# Add server from URL.
96+
$ wp mcp server add "server-github" "https://github.com/mcp"
97+
Success: Server added.
98+
99+
# Add server with command to execute
100+
$ wp mcp server add "server-filesystem" "npx -y @modelcontextprotocol/server-filesystem /my/allowed/folder/"
101+
Success: Server added.
102+
```
103+
104+
### wp mcp server remove
105+
106+
Remove a new MCP server from the list
107+
108+
~~~
109+
wp mcp server remove <name>
110+
~~~
111+
112+
**OPTIONS**
113+
114+
```
115+
<name>
116+
Name of the server to remove
117+
```
118+
119+
**EXAMPLES**
120+
121+
```
122+
# Remove server.
123+
$ wp mcp server remove "server-filesystem"
124+
Success: Server removed.
125+
```

‎docs/wp-cli/installation.md

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Installation
6+
7+
Installing this package requires WP-CLI v2.11 or greater. Update to the latest stable release with `wp cli update`.
8+
9+
Tip: for better on support of the latest PHP versions, use the v2.12 nightly build with `wp cli update --nightly`.
10+
11+
To install the latest development version of this package, use the following command instead:
12+
13+
```bash
14+
wp package install mcp-wp/ai-command:dev-main
15+
```

‎docs/wp-cli/prompts-cookbook.md

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Prompts cookbook
2+
3+
## Content creation
4+
5+
```
6+
wp ai "Create 10 posts about Pokemon, each post describing a generation 1 pokemon, with the title being the name of the pokemon and the category Pokemon"
7+
```
8+
9+
```
10+
wp ai "Get the last 5 posts and summarize them in 1 summary - then create a post with the title 'Summary of my last 5 posts' with that summary as content"
11+
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.