You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference.md
+78-10Lines changed: 78 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,11 +85,15 @@ This class acts as the server component in the MCP architecture, interfacing wit
85
85
|`Server::register_resource()`| Registers structured data for AI access. |
86
86
|`Server::get_capabilities()`| Retrives server capabilities and returns the list of available tools and resources. Used by AI clients to understand what functions and data are accessible. |
|`Server::process_method_call()`| Determines whether the request is for fetching capabilities (`get_capabilities`), accessing data (`get_users`, `get_products`), or executing a tool (`calculate_total`, `greet`, etc.) |
89
-
|`Server::handle_data_request()`| Extracts requested resource and returns structured data. |
90
-
|`Server::execute_tool()`| Calls registered AI tools and validates input against schema. |
88
+
|`Server::list_resources()`| List registered resources. |
The `RouteInformation` class encapsulates details about a WordPress REST API route, including its method type (`GET`, `POST`, `PUT`, etc.), callback function, and whether it conforms to a `WP_REST_Controller`. The class provides helper methods for route sanitization, method checking, and controller validation.
163
+
164
+
### Methods
165
+
166
+
| Name | Return Type | Description |
167
+
| --- | --- | --- |
168
+
|`RouteInformation::get_sanitized_route_name()`|`string`| Returns a cleaned-up route name (e.g., GET_wp-v2-posts_p_id). |
169
+
|`RouteInformation::get_method()`|`string`| Returns the HTTP method (`GET`, `POST`, etc.). |
170
+
|`RouteInformation::is_create()`|`bool`| Returns `true` if the method is `POST`. |
171
+
|`RouteInformation::is_update()`|`bool`| Returns `true` if the method is `PUT` or `PATCH`. |
172
+
|`RouteInformation::is_delete()`|`bool`| Returns `true` if the method is `DELETE`. |
173
+
|`RouteInformation::is_get()`|`bool`| Returns `true` if the method is `GET`. |
174
+
|`RouteInformation::is_singular()`|`bool`| Returns `true` if the route targets a single resource. |
175
+
|`RouteInformation::is_list()`|`bool`| Returns `true` if the route retrieves multiple resources. |
176
+
|`RouteInformation::is_wp_rest_controller()`|`bool`| Returns `true` if the callback is a valid REST controller. |
177
+
|`RouteInformation::get_wp_rest_controller()`|`WP_REST_Controller`| Returns the controller instance (throws an error if invalid). |
178
+
179
+
## `MapRESTtoMCP` class
180
+
181
+
The `MapRESTtoMCP` class is responsible for mapping WordPress REST API endpoints into MCP tools. It dynamically registers REST API routes as AI-callable tools in the MCP system.
182
+
183
+
This class enables AI-driven automation by exposing WordPress REST API endpoints to AI services in WP-CLI.
184
+
185
+
### Methods
186
+
187
+
| Name | Return Type | Description |
188
+
| --- | --- | --- |
189
+
|`MapRESTtoMCP::args_to_schema()`|`array`| Converts REST API arguments into JSON Schema. |
190
+
|`MapRESTtoMCP::sanitize_type()`|`string`| Maps REST API types to standardized types. |
191
+
|`MapRESTtoMCP::map_rest_to_mcp()`|`void`| Registers REST API endpoints as AI tools in MCP. |
192
+
|`MapRESTtoMCP::generate_description()`|`string`| Creates human-readable descriptions for API tools. |
193
+
|`MapRESTtoMCP::rest_callable()`|`array`| Executes REST API calls and returns formatted data. |
0 commit comments