Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# WP-CLI AI Command

A WP-CLI package that enables AI interactions with WordPress via the Model Context Protocol (MCP).

## Project Overview

- **Type**: WP-CLI package
- **PHP Version**: 8.2+
- **Namespace**: `McpWp\AiCommand`
- **License**: Apache-2.0

## Architecture

```
src/
├── AI/ # AI client implementations (WpAiClient, AiClient)
├── MCP/ # MCP protocol implementation
│ ├── Servers/ # MCP servers (WP_CLI tools)
│ └── Client.php # MCP client
├── Utils/ # Utilities (logging, config)
├── AiCommand.php # Main `wp ai` command
├── CredentialsCommand.php # `wp ai credentials` subcommand
├── McpCommand.php # `wp mcp` command
└── McpServerCommand.php # `wp mcp server` subcommand
```

## Development Commands

```bash
# Run all tests
composer test

# Individual test suites
composer phpunit # PHPUnit tests
composer behat # Behat integration tests
composer phpcs # Code style checks
composer phpstan # Static analysis
composer lint # Linter

# Fix code style
composer format # or: composer phpcbf

# Prepare test environment
composer prepare-tests
```

## Code Style

- Uses WP_CLI_CS ruleset (WordPress coding standards)
- Global namespace prefix: `McpWp\AiCommand` (classes) or `ai_command` (functions/variables)
- Run `composer format` to auto-fix style issues

## Key Dependencies

- `logiscape/mcp-sdk-php`: MCP SDK for PHP
- `mcp-wp/mcp-server`: MCP server implementation
- `wp-cli/wp-cli`: WP-CLI framework
- `wordpress/wp-ai-client`: WordPress AI client (dev dependency for testing)

## WP-CLI Commands

- `wp ai` - Main AI interaction command
- `wp ai credentials list|set|delete` - Manage AI provider API keys
- `wp mcp prompt` - MCP prompt handling
- `wp mcp server add|list|remove|update` - Manage MCP servers

## Testing Notes

- PHPUnit tests are in `tests/phpunit/`
- Behat feature tests are in `features/`
- PHPStan config: `phpstan.neon.dist`
Comment on lines +1 to +71
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This documentation file seems to be outdated and doesn't reflect the significant changes made in this pull request. Several sections are now incorrect:

  • Line 3: The project no longer uses the Model Context Protocol (MCP). It now uses the WP AI Client.
  • Lines 15-25 (Architecture): The diagram includes the MCP/ directory, McpCommand.php, and McpServerCommand.php, all of which have been removed.
  • Lines 55-56 (Key Dependencies): It lists MCP-related dependencies that are no longer in the project.
  • Lines 64-65 (WP-CLI Commands): It lists wp mcp commands that have been removed.

Please update this file to accurately describe the current state of the project, focusing on the integration with WP AI Client.

18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ To install the latest development version of this package, use the following com
wp package install mcp-wp/ai-command:dev-main
```

Right now, the plugin requires a WordPress site with the [AI Services plugin](https://wordpress.org/plugins/ai-services) installed.
This package uses the **WP AI Client** (available in WordPress 7.0+ or via the AI plugin) for AI functionality.

### Configuration

Configure credentials for AI providers:

```bash
# Configure credentials for AI providers
wp ai credentials set openai sk-proj-YOUR-API-KEY
wp ai credentials set anthropic sk-ant-YOUR-API-KEY
wp ai credentials set google YOUR-GOOGLE-API-KEY

# List configured credentials
wp ai credentials list
```

Credentials are stored in the WordPress database and can also be managed through the WordPress admin settings screen.

### Reporting a bug

Expand Down
6 changes: 2 additions & 4 deletions ai-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
require_once __DIR__ . '/vendor/autoload.php';
}

WP_CLI::add_command( 'ai', AiCommand::class );
WP_CLI::add_command( 'mcp prompt', AiCommand::class );
WP_CLI::add_command( 'mcp', McpCommand::class );
WP_CLI::add_command( 'mcp server', McpServerCommand::class );
WP_CLI::add_command( 'ai', \McpWp\AiCommand\AiCommand::class );
WP_CLI::add_command( 'ai credentials', \McpWp\AiCommand\CredentialsCommand::class );
25 changes: 10 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
"authors": [],
"require": {
"php": "^8.2",
"logiscape/mcp-sdk-php": "dev-main",
"mcp-wp/mcp-server": "dev-main",
"wp-cli/wp-cli": "^2.11"
"wp-cli/wp-cli": "^2.12"
},
"require-dev": {
"humbug/php-scoper": "^0.18.17",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-strict-rules": "^1.6",
"roave/security-advisories": "dev-latest",
"wordpress/wp-ai-client": "^0.2.1",
"wp-cli/extension-command": "^2.1",
"wp-cli/wp-cli-tests": "^v4.3.9",
"wpackagist-plugin/ai-services": "^0.6.0"
"wp-cli/wp-cli-tests": "^5.0"
},
"repositories":[
{
Expand Down Expand Up @@ -48,19 +46,16 @@
},
"bundled": false,
"commands": [
"ai",
"mcp prompt",
"mcp server add",
"mcp server list",
"mcp server remove",
"mcp server update"
"ai prompt",
"ai credentials list",
"ai credentials set",
"ai credentials delete"
],
"installer-disable": true
},
"autoload": {
"psr-4": {
"McpWp\\AiCommand\\": "src/",
"McpWp\\AiCommand\\MCP\\": "src/MCP"
"McpWp\\AiCommand\\": "src/"
},
"files": [
"ai-command.php"
Expand Down
27 changes: 27 additions & 0 deletions features/ai-credentials.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: AI Credentials command
Scenario: Credentials management with WP AI Client
Given a WP installation

When I run `wp ai credentials list`
Then STDOUT should contain:
"""
No credentials configured.
"""

When I run `wp ai credentials set openai sk-test-key`
Then STDOUT should contain:
"""
Success: Credentials for 'openai' saved.
"""

When I run `wp ai credentials list`
Then STDOUT should contain:
"""
openai
"""

When I run `wp ai credentials delete openai`
Then STDOUT should contain:
"""
Success: Credentials for 'openai' deleted.
"""
19 changes: 7 additions & 12 deletions features/ai.feature
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
Feature: AI command
Scenario: Missing AI Services plugin
When I try `wp ai "Hello World"`
Scenario: AI prompt requires WordPress
When I try `wp ai prompt "Hello World"`
Then STDERR should contain:
"""
This does not seem to be a WordPress installation.
"""

When I try `wp ai "Hello World" --skip-wordpress`
Scenario: Skip WordPress not implemented
When I try `wp ai prompt "Hello World" --skip-wordpress`
Then STDERR should contain:
"""
Not implemented yet.
"""

Scenario: AI prompt requires configured models
Given a WP installation
When I try `wp ai "Hello World"`
When I try `wp ai prompt "Hello World"`
Then STDERR should contain:
"""
This command currently requires the AI Services plugin.
"""

When I run `wp plugin install ai-services --activate`
When I try `wp ai "Hello World"`
Then STDERR should contain:
"""
No service satisfying the given arguments is registered and available.
No models found
"""
75 changes: 0 additions & 75 deletions features/mcp-server.feature

This file was deleted.

6 changes: 1 addition & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ parameters:
- ai-command.php
- src/
scanDirectories:
- vendor/wpackagist-plugin/ai-services/includes
- vendor/wpackagist-plugin/ai-services/third-party
- vendor/wordpress/wp-ai-client/src
- vendor/wp-cli/wp-cli/bundle/rmccue/requests
- vendor/wp-cli/wp-cli/php
bootstrapFiles:
- tests/phpstan/bootstrap.php
reportMaybesInMethodSignatures: false
strictRules:
disallowedEmpty: false
strictArrayFilter: false
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
Loading
Loading