Skip to main content

Reference

AiCommand class

The AiCommand class registers CLI command for WP-CLI. It is a WP-CLI command handler designed to integrate AI capabilities within WordPress. It connects AI-driven services with WP-CLI using the MCP (Multi-Client Processor) architecture, allowing AI models to:

  • Access resources (e.g., WordPress posts, users, products).
  • Call AI-powered tools (e.g., image generation, event lookup).
  • Execute AI-generated functions dynamically.

Methods

NameReturn TypeDescription
AiCommand::__invoke()voidExecutes AI-driven WP-CLI commands.
AiCommand::register_tools( $server )voidRegisters AI-powered tools in MCP.
AiCommand::register_resources( $server )voidRegisters data resources (e.g., users, products).

Client class

The Client class is a core component of the MCP for WordPress implementation and is a small wrapper around the MCP PHP SDK.

It allows connecting to different MCP servers via local commands, PHP, or HTTP.

Methods

NameReturn TypeDescription
Client::__construct()Constructor
Client::connect()ClientSessionConnects to the server and returns a session instance.