Skip to content

Commit 73e70b8

Browse files
committed
Add reference for Client class.
1 parent c5b0810 commit 73e70b8

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

docs/reference.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,37 @@ This class follows an MCP client-server architecture, where:
2121

2222
| Name | Description |
2323
| --- | --- |
24-
| `AiCommand:__invoke( $args, $assoc_args )` | <ul><li>Creates an AI server and client instance.</li><li>Registers tools & resources for AI processing.</li><li>Sends user input ($args[0]) to AI.</li><li>Outputs AI-generated results.</li></ul> |
25-
| `AiCommand:register_tools( $server, $client )` | Registers functionality AI can invoke. See [available tools](tools.md). |
26-
| `AiCommand:register_resources( $server )` | Registers structured datasets AI can access. See [available resources](). |
24+
| `AiCommand:__invoke( array $args, array $assoc_args )` | <ul><li>Creates an AI server and client instance.</li><li>Registers tools & resources for AI processing.</li><li>Sends user input ($args[0]) to AI.</li><li>Outputs AI-generated results.</li></ul> |
25+
| `AiCommand:register_tools( Server $server, $client )` | Registers functionality AI can invoke. See [available tools](tools.md). |
26+
| `AiCommand:register_resources( Server $server )` | Registers structured datasets AI can access. See [available resources](). |
2727

2828

2929
## `Client` class
3030

31+
`Client` class is part of the `WP_CLI\AiCommand\MCP` namespace and serves as an intermediary between the WP-CLI and an AI-based service. It interacts with an MCP (Multi-Client Processor) AI service using JSON-RPC over a local server instance.
32+
33+
The service supports:
34+
35+
- Sending and receiving requests from the AI service.
36+
- Retrieving resources from the AI service.
37+
- Generating images via AI.
38+
- Processing AI-generated text responses.
39+
- Managing function calls and executing AI-invoked functions dynamically.
40+
41+
### Properties
42+
43+
| Name | Visibility modifier | Description |
44+
| --- | --- | --- |
45+
| `$server` | private | An instance of MCPServer. |
46+
47+
### Methods
48+
49+
| Name | Description |
50+
| --- | --- |
51+
| `Client:__construct( Server $server )` | Constructor |
52+
| `Client:send_request( string $method, array $params = [] )` | Constructs a JSON-RPC request, sends it to the AI service, and decodes the response. |
53+
| `Client:__call( string $name, array $arguments )` | A magic method to call any AI service method dynamically. |
54+
| `Client:list_resources()` | Retrieves available AI-generated content. |
55+
| `Client:read_resource( string $uri )` | Reads a specific AI-generated resource. |
56+
3157
## `Server` class

0 commit comments

Comments
 (0)