Skip to content

Commit aa8716a

Browse files
Merge pull request #44 from Automattic/try/mcp-sse-server
Implemented streamable transport protocol and JWT authentication
2 parents 5308b24 + 071af6f commit aa8716a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+7043
-825
lines changed

Readme.md

Lines changed: 372 additions & 33 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,18 @@
1313
"allow-plugins": {
1414
"dealerdirect/phpcodesniffer-composer-installer": true
1515
}
16+
},
17+
"require": {
18+
"firebase/php-jwt": "^6.11"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"Automattic\\WordpressMcp\\": "includes/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"Automattic\\WordpressMcp\\Tests\\": "tests/phpunit/"
28+
}
1629
}
1730
}

composer.lock

Lines changed: 72 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/client-setup.md

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
# MCP Client Setup Guide
2+
3+
This guide explains how to connect various MCP clients to your WordPress MCP server using different transport protocols and authentication methods.
4+
5+
## Overview
6+
7+
WordPress MCP supports two transport protocols:
8+
9+
- **STDIO Transport**: Traditional transport via `mcp-wordpress-remote` proxy
10+
- **Streamable Transport**: Direct HTTP-based transport with JSON-RPC 2.0
11+
12+
## Authentication Methods
13+
14+
### JWT Tokens (Recommended)
15+
16+
- Generate tokens from `Settings > MCP > Authentication Tokens`
17+
- Tokens expire in 1-24 hours (configurable)
18+
- More secure than application passwords
19+
- Required for Streamable transport
20+
21+
### Application Passwords
22+
23+
- WordPress built-in authentication method
24+
- Only works with STDIO transport via proxy
25+
- Generate from `Users > Profile > Application Passwords`
26+
27+
## Client Configurations
28+
29+
### Claude Desktop
30+
31+
#### Using JWT Token with mcp-wordpress-remote (Recommended)
32+
33+
Add to your Claude Desktop `claude_desktop_config.json`:
34+
35+
```json
36+
{
37+
"mcpServers": {
38+
"wordpress-mcp": {
39+
"command": "npx",
40+
"args": [ "-y", "@automattic/mcp-wordpress-remote@latest" ],
41+
"env": {
42+
"WP_API_URL": "https://your-site.com/",
43+
"JWT_TOKEN": "your-jwt-token-here",
44+
"LOG_FILE": "optional-path-to-log-file"
45+
}
46+
}
47+
}
48+
}
49+
```
50+
51+
#### Using Application Password with mcp-wordpress-remote
52+
53+
```json
54+
{
55+
"mcpServers": {
56+
"wordpress-mcp": {
57+
"command": "npx",
58+
"args": [ "-y", "@automattic/mcp-wordpress-remote@latest" ],
59+
"env": {
60+
"WP_API_URL": "https://your-site.com/",
61+
"WP_API_USERNAME": "your-username",
62+
"WP_API_PASSWORD": "your-application-password",
63+
"LOG_FILE": "optional-full-path-to-log-file"
64+
}
65+
}
66+
}
67+
}
68+
```
69+
70+
### Cursor IDE
71+
72+
#### Using mcp-wordpress-remote proxy
73+
74+
Add to your Cursor MCP configuration file:
75+
76+
```json
77+
{
78+
"mcpServers": {
79+
"wordpress-mcp": {
80+
"command": "npx",
81+
"args": [ "-y", "@automattic/mcp-wordpress-remote@latest" ],
82+
"env": {
83+
"WP_API_URL": "https://your-site.com/",
84+
"JWT_TOKEN": "your-jwt-token-here",
85+
"LOG_FILE": "optional-full-path-to-log-file"
86+
}
87+
}
88+
}
89+
}
90+
```
91+
92+
### VS Code MCP Extension
93+
94+
#### Direct Streamable Transport (JWT Only)
95+
96+
Add to your VS Code MCP settings:
97+
98+
```json
99+
{
100+
"servers": {
101+
"wordpress-mcp": {
102+
"type": "http",
103+
"url": "https://your-site.com/wp-json/wp/v2/wpmcp/streamable",
104+
"headers": {
105+
"Authorization": "Bearer your-jwt-token-here"
106+
}
107+
}
108+
}
109+
}
110+
```
111+
112+
### MCP Inspector (Development/Testing)
113+
114+
#### Using JWT Token with proxy
115+
116+
```bash
117+
npx @modelcontextprotocol/inspector \
118+
-e WP_API_URL=https://your-site.com/ \
119+
-e JWT_TOKEN=your-jwt-token-here \
120+
-e WOO_CUSTOMER_KEY=optional-woo-customer-key \
121+
-e WOO_CUSTOMER_SECRET=optional-woo-customer-secret \
122+
-e LOG_FILE="optional-full-path-to-log-file"
123+
npx @automattic/mcp-wordpress-remote@latest
124+
```
125+
126+
#### Using Application Password with proxy
127+
128+
```bash
129+
npx @modelcontextprotocol/inspector \
130+
-e WP_API_URL=https://your-site.com/ \
131+
-e WP_API_USERNAME=your-username \
132+
-e WP_API_PASSWORD=your-application-password \
133+
-e WOO_CUSTOMER_KEY=optional-woo-customer-key \
134+
-e WOO_CUSTOMER_SECRET=optional-woo-customer-secret \
135+
-e LOG_FILE="optional-full-path-to-log-file"
136+
npx @automattic/mcp-wordpress-remote@latest
137+
```
138+
139+
## Transport Protocol Details
140+
141+
### STDIO Transport
142+
143+
- **Endpoint**: `/wp-json/wp/v2/wpmcp`
144+
- **Format**: WordPress-style REST API
145+
- **Authentication**: JWT tokens OR Application passwords
146+
- **Use Case**: Legacy compatibility, works with most MCP clients
147+
- **Proxy Required**: Yes (`mcp-wordpress-remote`)
148+
149+
#### Advantages:
150+
151+
- Compatible with all MCP clients
152+
- Supports both authentication methods
153+
- Enhanced features via proxy (WooCommerce, logging)
154+
155+
#### Example Tools Available:
156+
157+
- `wp_get_posts` - Retrieve WordPress posts
158+
- `wp_create_post` - Create new posts
159+
- `wp_update_post` - Update existing posts
160+
- `wp_get_users` - Get user information
161+
- And many more...
162+
163+
### Streamable Transport
164+
165+
- **Endpoint**: `/wp-json/wp/v2/wpmcp/streamable`
166+
- **Format**: JSON-RPC 2.0 compliant
167+
- **Authentication**: JWT tokens only
168+
- **Use Case**: Modern AI clients, direct integration
169+
- **Proxy Required**: No
170+
171+
#### Advantages:
172+
173+
- Direct connection (no proxy needed)
174+
- Standard JSON-RPC 2.0 protocol
175+
- Lower latency
176+
- Modern implementation
177+
178+
#### Example Methods:
179+
180+
- `tools/list` - List available tools
181+
- `tools/call` - Execute a tool
182+
- `resources/list` - List available resources
183+
- `resources/read` - Read resource content
184+
- `prompts/list` - List available prompts
185+
- `prompts/get` - Get prompt template
186+
187+
## Local Development Setup
188+
189+
### WordPress Local Environment
190+
191+
```json
192+
{
193+
"mcpServers": {
194+
"wordpress-local": {
195+
"command": "node",
196+
"args": [ "/path/to/mcp-wordpress-remote/dist/proxy.js" ],
197+
"env": {
198+
"WP_API_URL": "http://localhost:8080/",
199+
"JWT_TOKEN": "your-local-jwt-token",
200+
"LOG_FILE": "/tmp/wordpress-mcp-local.log"
201+
}
202+
}
203+
}
204+
}
205+
```
206+
207+
## Troubleshooting
208+
209+
### Common Issues
210+
211+
#### JWT Token Expired
212+
213+
- Generate a new token from WordPress admin
214+
- Check token expiration time in settings
215+
- Ensure system clock is synchronized
216+
217+
#### Authentication Failed
218+
219+
- Verify JWT token is correctly copied
220+
- Check application password format (username:password)
221+
- Ensure user has appropriate permissions
222+
223+
#### Connection Timeout
224+
225+
- Verify WordPress site is accessible
226+
- Check firewall settings
227+
- Ensure proper SSL certificate if using HTTPS
228+
229+
#### Proxy Issues
230+
231+
- Update mcp-wordpress-remote to latest version:
232+
```bash
233+
npm install -g @automattic/mcp-wordpress-remote@latest
234+
```
235+
- Check proxy logs for error details
236+
- Verify environment variables are set correctly
237+
238+
## Security Best Practices
239+
240+
1. **Use JWT tokens** instead of application passwords when possible
241+
2. **Set shortest expiration time** needed for your use case (1-24 hours)
242+
3. **Revoke unused tokens** promptly from the admin interface
243+
4. **Never commit tokens** to version control systems
244+
5. **Use HTTPS** for production environments
245+
6. **Regularly rotate tokens**
246+
247+
## Support
248+
249+
For additional help:
250+
251+
- Check the [WordPress MCP documentation](https://github.com/Automattic/wordpress-mcp)
252+
- Visit the [mcp-wordpress-remote repository](https://github.com/Automattic/mcp-wordpress-remote)
253+
- Report issues on [GitHub Issues](https://github.com/Automattic/wordpress-mcp/issues)

includes/Admin/Settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function enqueue_scripts( string $hook ): void {
115115
'settings' => get_option( self::OPTION_NAME, array() ),
116116
'toolStates' => get_option( self::TOOL_STATES_OPTION, array() ),
117117
'featureApiAvailable' => $this->is_feature_api_available(),
118+
'pluginUrl' => WORDPRESS_MCP_URL,
118119
'strings' => array(
119120
'enableMcp' => __( 'Enable MCP functionality', 'wordpress-mcp' ),
120121
'enableMcpDescription' => __( 'Toggle to enable or disable the MCP plugin functionality.', 'wordpress-mcp' ),

0 commit comments

Comments
 (0)