Skip to content

Commit d5cff84

Browse files
Merge pull request #48 from Automattic/add/rest-api-crud-tools-documentation
Add/rest api crud tools documentation
2 parents b381915 + df472a7 commit d5cff84

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

Readme.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A comprehensive WordPress plugin that implements the [Model Context Protocol (MC
1212
- 🤖 **AI-Friendly APIs**: JSON-RPC 2.0 compliant endpoints for AI integration
1313
- 🏗️ **Extensible Architecture**: Custom tools, resources, and prompts support
1414
- 🔌 **WordPress Feature API**: Adapter for standardized WordPress functionality
15+
- 🧪 **Experimental REST API CRUD Tools**: Generic tools for any WordPress REST API endpoint
1516
- 🧪 **Comprehensive Testing**: 200+ test cases covering all protocols and authentication
1617
-**High Performance**: Optimized routing and caching mechanisms
1718
- 🔒 **Enterprise Security**: Multi-layer authentication and audit logging
@@ -195,6 +196,42 @@ The streamable transport provides a direct JSON-RPC 2.0 compliant endpoint, whil
195196
| `prompts/list` | List available prompts | Both |
196197
| `prompts/get` | Get prompt template | Both |
197198

199+
### 🧪 Experimental REST API CRUD Tools
200+
201+
⚠️ **EXPERIMENTAL FEATURE**: This functionality is experimental and may change or be removed in future versions.
202+
203+
When enabled via `Settings > WordPress MCP > Enable REST API CRUD Tools`, the plugin provides three powerful generic tools that can interact with any WordPress REST API endpoint:
204+
205+
#### Available Tools
206+
207+
| Tool Name | Description | Type |
208+
| ---------------------- | --------------------------------------------------- | ------ |
209+
| `list_api_functions` | Discover all available WordPress REST API endpoints | Read |
210+
| `get_function_details` | Get detailed metadata for specific endpoint/method | Read |
211+
| `run_api_function` | Execute any REST API function with CRUD operations | Action |
212+
213+
#### Usage Workflow
214+
215+
1. **Discovery**: Use `list_api_functions` to see all available endpoints
216+
2. **Inspection**: Use `get_function_details` to understand required parameters
217+
3. **Execution**: Use `run_api_function` to perform CRUD operations
218+
219+
#### Security & Permissions
220+
221+
- **User Capabilities**: All operations respect current user permissions
222+
- **Settings Control**: Individual CRUD operations can be disabled in settings:
223+
- Enable Create Tools (POST operations)
224+
- Enable Update Tools (PATCH/PUT operations)
225+
- Enable Delete Tools (DELETE operations)
226+
- **Automatic Filtering**: Excludes sensitive endpoints (JWT auth, oembed, autosaves, revisions)
227+
228+
#### Benefits
229+
230+
- **Universal Access**: Works with any WordPress REST API endpoint, including custom post types and third-party plugins
231+
- **AI-Friendly**: Provides discovery and introspection capabilities for AI agents
232+
- **Standards Compliant**: Uses standard HTTP methods (GET, POST, PATCH, DELETE)
233+
- **Permission Safe**: Inherits WordPress user capabilities and respects endpoint permissions
234+
198235
## 🔧 Development
199236

200237
### Project Structure
@@ -322,6 +359,8 @@ npm run start
322359
- **Secure Storage**: Never commit tokens to repositories
323360
- **Regular Cleanup**: Revoke unused tokens promptly
324361
- **Access Control**: Streamable transport requires admin privileges
362+
- **CRUD Operations**: Only enable create/update/delete tools when necessary
363+
- **Experimental Features**: Use REST API CRUD tools with caution in production environments
325364

326365
### Security Features
327366

@@ -361,8 +400,21 @@ Access via `Settings > WordPress MCP`:
361400
- **Enable/Disable MCP**: Toggle plugin functionality
362401
- **Transport Configuration**: Configure STDIO/Streamable transports
363402
- **Feature Toggles**: Enable/disable specific tools and resources
403+
- **CRUD Operation Controls**: Granular control over create, update, and delete operations
404+
- **Experimental Features**: Enable REST API CRUD Tools (experimental functionality)
364405
- **Authentication Settings**: JWT token management
365406

407+
#### CRUD Operation Settings
408+
409+
The plugin provides granular control over CRUD operations:
410+
411+
- **Enable Create Tools**: Allow POST operations via MCP tools
412+
- **Enable Update Tools**: Allow PATCH/PUT operations via MCP tools
413+
- **Enable Delete Tools**: ⚠️ Allow DELETE operations via MCP tools (use with caution)
414+
- **Enable REST API CRUD Tools**: 🧪 Enable experimental generic REST API access tools
415+
416+
⚠️ **Security Note**: Delete operations can permanently remove data. Only enable delete tools if you trust all users with MCP access.
417+
366418
## 🤝 Contributing
367419

368420
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md).

includes/Tools/McpRestApiCrud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct() {
3434
* Example usage: You can extend this to register tools for any custom endpoint.
3535
*/
3636
public function register_tools(): void {
37-
// Check if REST API CRUD tools are enabled in settings
37+
// Check if REST API CRUD tools are enabled in settings.
3838
$settings = get_option( 'wordpress_mcp_settings', array() );
3939
if ( empty( $settings['enable_rest_api_crud_tools'] ) ) {
4040
return;

0 commit comments

Comments
 (0)