Wordpress MCP plugins
WordPress MCP Server Plugin
Model Context Protocol (MCP) サーバー機能をWordPressサイトに追加するプラグインです。Claude Desktopやその他のMCPクライアントから、WordPressサイトのコンテンツにアクセスできるようになります。
概要
このプラグインは、WordPressサイトをMCP(Model Context Protocol)サーバーとして機能させ、AI アシスタント(Claude Desktop等)がサイトのコンテンツを読み取り、検索することを可能にします。
主な機能
- 投稿・ページの取得: WordPressの投稿や固定ページを取得
- コンテンツ検索: サイト内のコンテンツを検索
- サイト情報の取得: WordPressサイトの基本情報を取得
- カテゴリー・タグ管理: カテゴリーやタグの一覧を取得
- REST API: 標準的なREST APIエンドポイントを提供
- SSE サポート: Server-Sent Events による双方向通信
- レート制限: APIの使用制限機能
- CORS対応: クロスオリジンリクエストに対応
- エックスサーバー最適化: エックスサーバーでの動作に最適化
システム要件
- WordPress 5.0 以上
- PHP 7.4 以上
- REST API が有効であること
- 共有ホスティング対応(エックスサーバー等)
インストール
手動インストール
- プラグインファイルをダウンロード
/wp-content/plugins/wp-mcp-plugin/
ディレクトリにアップロード- WordPress管理画面でプラグインを有効化
- 設定 > MCP Server で設定を確認
GitHubからのインストール
cd /path/to/wordpress/wp-content/plugins/
git clone https://github.com/your-repo/wp-mcp-plugin.git
設定
1. 基本設定
WordPressの管理画面で「設定」→「MCP Server」にアクセスし、以下を設定:
- MCP サーバーを有効化: プラグインの有効/無効を切り替え
- API キー: 自動生成されたAPIキー(必要に応じて再生成可能)
- 許可するオリジン: アクセスを許可するドメイン(デフォルト: https://claude.ai)
- レート制限: 1時間あたりのリクエスト数制限
2. Claude Desktop の設定
Claude Desktop で使用する場合は、設定ファイル claude_desktop_config.json
に以下を追加:
{
"mcpServers": {
"your-wordpress-site": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"],
"env": {
"MCP_SERVER_URL": "https://your-site.com/wp-json/wp-mcp/v1/sse",
"MCP_API_KEY": "your-api-key-here"
}
}
}
}
3. CORS設定
プラグインは自動的に .htaccess
にCORS設定を追加しますが、手動で設定する場合:
# WordPress MCP Server CORS Settings
<IfModule mod_headers.c>
<FilesMatch "wp-json/wp-mcp/.*">
Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-MCP-API-Key"
Header always set Access-Control-Max-Age "3600"
</FilesMatch>
</IfModule>
API エンドポイント
基本エンドポイント
| エンドポイント | メソッド | 説明 |
|---|---|---|
| /wp-json/wp-mcp/v1/server-info
| GET | サーバー情報を取得 |
| /wp-json/wp-mcp/v1/tools
| GET | 利用可能なツール一覧 |
| /wp-json/wp-mcp/v1/tools/call
| POST | ツール実行 |
| /wp-json/wp-mcp/v1/resources
| GET | リソース一覧 |
| /wp-json/wp-mcp/v1/resources/read
| POST | リソース読み取り |
| /wp-json/wp-mcp/v1/sse
| GET | Server-Sent Events |
認証
すべてのAPIリクエストには、以下のいずれかの方法でAPIキーを含める必要があります:
-
ヘッダー認証:
X-MCP-API-Key: your-api-key-here
-
パラメータ認証:
?api_key=your-api-key-here
利用可能なツール
get_posts
投稿を取得します。
{
"name": "get_posts",
"arguments": {
"post_type": "post",
"posts_per_page": 10,
"post_status": "publish"
}
}
search_content
コンテンツを検索します。
{
"name": "search_content",
"arguments": {
"query": "検索キーワード",
"post_type": "any"
}
}
get_site_info
サイトの基本情報を取得します。
{
"name": "get_site_info",
"arguments": {}
}
get_categories
カテゴリー一覧を取得します。
{
"name": "get_categories",
"arguments": {
"hide_empty": true
}
}
get_tags
タグ一覧を取得します。
{
"name": "get_tags",
"arguments": {
"hide_empty": true
}
}
get_pages
固定ページ一覧を取得します。
{
"name": "get_pages",
"arguments": {
"sort_order": "ASC"
}
}
使用例
cURL での投稿取得
curl -X POST "https://your-site.com/wp-json/wp-mcp/v1/tools/call" \
-H "Content-Type: application/json" \
-H "X-MCP-API-Key: your-api-key" \
-d '{
"name": "get_posts",
"arguments": {
"posts_per_page": 5
}
}'
JavaScript での検索
const response = await fetch('https://your-site.com/wp-json/wp-mcp/v1/tools/call', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-MCP-API-Key': 'your-api-key'
},
body: JSON.stringify({
name: 'search_content',
arguments: {
query: '検索キーワード'
}
})
});
const data = await response.json();
console.log(data);
エックスサーバー対応
このプラグインはエックスサーバーでの動作に特別に最適化されています:
- 接続時間制限: SSE接続を25秒で自動終了(タイムアウト回避)
- レート制限: デフォルトで低めの制限値を設定
- バッファリング無効化: nginx 用の設定を追加
- メモリ効率: 大量データの処理を最適化
トラブルシューティング
よくある問題
1. CORS エラー
症状: ブラウザコンソールでCORSエラーが表示される 解決方法:
- 許可するオリジンの設定を確認
.htaccess
のCORS設定を確認
2. 認証エラー
症状: "Invalid API key" エラーが返される 解決方法:
- APIキーが正しく設定されているか確認
- 必要に応じてAPIキーを再生成
3. SSE接続が不安定
症状: Server-Sent Events接続が頻繁に切断される 解決方法:
- エックスサーバーの場合は正常な動作です(25秒で自動切断)
- より長時間の接続が必要な場合はVPS等への移行を検討
4. レート制限に引っかかる
症状: "Rate limit exceeded" エラーが返される 解決方法:
- レート制限設定を調整
- リクエスト頻度を下げる
ログの確認
WordPress のデバッグログでエラーを確認できます:
// wp-config.php に追加
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
ログファイル: /wp-content/debug.log
セキュリティ
推奨事項
- APIキーの定期的な更新: セキュリティ向上のため定期的にAPIキーを再生成
- アクセス制限: 必要なオリジンのみを許可リストに追加
- レート制限: 適切なレート制限を設定してDDoS攻撃を防ぐ
- HTTPS の使用: 本番環境では必ずHTTPSを使用
権限設定
プラグインは以下の権限を使用します:
manage_options
: 設定画面へのアクセス- REST API アクセス: APIキーによる認証
開発者向け情報
フック
// MCP ツール追加
add_filter('wp_mcp_available_tools', function($tools) {
$tools[] = 'custom_tool';
return $tools;
});
// カスタムツールの実装
add_action('wp_mcp_call_custom_tool', function($args) {
// カスタムツールの処理
return array('result' => 'custom data');
});
カスタムエンドポイント
add_action('rest_api_init', function() {
register_rest_route('wp-mcp/v1', '/custom', array(
'methods' => 'GET',
'callback' => 'custom_mcp_handler',
'permission_callback' => array($wp_mcp_server, 'check_mcp_permissions'),
));
});
ライセンス
GPL v2 or later
貢献
バグ報告や機能要求は GitHub Issues でお願いします。 プルリクエストも歓迎します。
変更履歴
1.0.0
- 初回リリース
- 基本的なMCP機能の実装
- エックスサーバー対応
- SSE サポート
- CORS対応
サポート
- GitHub Issues: バグ報告・機能要求
- Email: support@feelflow.com
- 公式サイト: https://feelflow.com/wordpress-mcp-server
English Version
WordPress MCP Server Plugin
A WordPress plugin that adds Model Context Protocol (MCP) server functionality to your WordPress site, enabling Claude Desktop and other MCP clients to access your WordPress content.
Overview
This plugin transforms your WordPress site into an MCP (Model Context Protocol) server, allowing AI assistants (like Claude Desktop) to read and search your site's content.
Key Features
- Post & Page Retrieval: Access WordPress posts and pages
- Content Search: Search through site content
- Site Information: Get WordPress site basic information
- Category & Tag Management: Retrieve categories and tags
- REST API: Standard REST API endpoints
- SSE Support: Server-Sent Events for bidirectional communication
- Rate Limiting: API usage restrictions
- CORS Support: Cross-origin request support
- Shared Hosting Optimized: Optimized for shared hosting environments
System Requirements
- WordPress 5.0+
- PHP 7.4+
- REST API enabled
- Shared hosting compatible
Installation
Manual Installation
- Download the plugin files
- Upload to
/wp-content/plugins/wp-mcp-plugin/
directory - Activate the plugin through WordPress admin
- Configure at Settings > MCP Server
GitHub Installation
cd /path/to/wordpress/wp-content/plugins/
git clone https://github.com/your-repo/wp-mcp-plugin.git
Configuration
Claude Desktop Setup
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"your-wordpress-site": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"],
"env": {
"MCP_SERVER_URL": "https://your-site.com/wp-json/wp-mcp/v1/sse",
"MCP_API_KEY": "your-api-key-here"
}
}
}
}
API Reference
Authentication
Include API key in requests:
- Header:
X-MCP-API-Key: your-api-key
- Parameter:
?api_key=your-api-key
Available Tools
get_posts
: Retrieve WordPress postssearch_content
: Search site contentget_site_info
: Get site informationget_categories
: Get category listget_tags
: Get tag listget_pages
: Get page list
License
GPL v2 or later
Support
- GitHub Issues: Bug reports & feature requests
- Email: support@feelflow.com
- Website: https://feelflow.com/wordpress-mcp-server