Skip to main content
Glama
WordPress
by WordPress

MCP アダプター

AI Building Blocks for WordPress イニシアチブ の一部です。

WordPress のアビリティを Model Context Protocol (MCP) ツール、リソース、プロンプトとして AI エージェントに公開する、MCP 統合用の公式 WordPress パッケージです。

Ask DeepWiki

概要

このアダプターは、WordPress の Abilities API と MCP 仕様 を橋渡しし、AI エージェントが WordPress の機能と対話するための標準化された方法を提供します。HTTP および STDIO トランスポートのサポート、包括的なエラーハンドリング、カスタム統合のための拡張可能なアーキテクチャが含まれています。

Related MCP server: MCP Adapter Implementation Example

特徴

コア機能

  • アビリティから MCP への変換: WordPress のアビリティを MCP ツール、リソース、プロンプトに自動変換します。

  • マルチサーバー管理: 独自の設定を持つ複数の MCP サーバーを作成・管理できます。

  • 拡張可能なトランスポート層:

    • HTTP トランスポート: HTTP ベースの通信用に MCP 2025-11-25 仕様 を実装した統合トランスポート。

    • STDIO トランスポート: ローカル開発および CLI 統合のための標準入出力を介したプロセスベースの通信。

    • カスタムトランスポートのサポート: McpTransportInterface を実装して、専用の通信プロトコルを作成できます。

    • マルチトランスポート構成: 複数のトランスポート方式を同時に使用するようにサーバーを構成できます。

  • 柔軟なエラーハンドリング:

    • 組み込みエラーハンドラー: WordPress 互換のデフォルトのエラーロギングが含まれています。

    • カスタムエラーハンドラー: McpErrorHandlerInterface を実装して、カスタムのロギング、監視、通知システムを実現できます。

    • サーバー固有のハンドラー: MCP サーバーごとに異なるエラーハンドリング戦略を設定できます。

  • 可観測性:

    • 組み込みの可観測性: 設定可能なハンドラーを備えた、デフォルトのオーバーヘッドゼロのメトリクストラッキング。

    • カスタム可観測性ハンドラー: McpObservabilityHandlerInterface を実装して、監視システムと統合できます。

  • 検証: ツール、リソース、プロンプトの組み込み検証と、拡張可能な検証ルールを提供します。

  • 権限制御: 公開されるすべての機能に対する詳細な権限チェックと、設定可能なトランスポート権限を提供します。

MCP コンポーネントのサポート

  • ツール: WordPress のアビリティを、AI エージェントが操作できる実行可能な MCP ツールに変換します。

  • リソース: WordPress のデータを MCP リソースとして公開し、コンテキスト情報へアクセスできるようにします。

  • プロンプト: アビリティを構造化された MCP プロンプトに変換し、AI のガイダンスやテンプレートを提供します。

  • サーバーディスカバリー: MCP プロトコル標準に従った MCP サーバーの自動登録と検出。

  • 組み込みアビリティ: システムのイントロスペクションとアビリティ管理のためのコア WordPress アビリティ。

  • CLI 統合: MCP 仕様で定義されている STDIO トランスポートをサポートする WP-CLI コマンド。

アーキテクチャ

コンポーネント構成の詳細については、アーキテクチャの概要 を参照してください。

依存関係

  • PHP: >= 7.4

  • WordPress: >= 6.9 (Abilities API をコアに含みます。別途プラグインは不要です)

  • php-mcp-schema (^0.1.0): MCP プロトコルタイプ用の型付き DTO

インストール

MCP Adapter は WordPress プラグインとして配布されています。他のプラグインと同様にインストールして有効化してください。リリースには必要なものがすべて同梱されているため、オートローダーの配線やビルド手順は不要です。

WordPress 6.9 以降が必要です。Abilities API はコアの一部であるため、別途プラグインをインストールする必要はありません。

手動インストール

GitHub リリースページ から最新の安定版 mcp-adapter.zip をダウンロードし、プラグイン → 新規プラグインを追加 → プラグインのアップロード からアップロードして有効化します。

WP-CLI を使用する場合

wp plugin install https://github.com/WordPress/mcp-adapter/releases/latest/download/mcp-adapter.zip --activate

WP-Env を使用する場合

// .wp-env.json
{
  "$schema": "https://schemas.wp.org/trunk/wp-env.json",
  "plugins": [
    "https://github.com/WordPress/mcp-adapter/releases/latest/download/mcp-adapter.zip"
  ]
}

プラグインの依存関係として使用する場合

WP\MCP クラスは MCP Adapter プラグインによって提供されるため、プラグインヘッダーRequires Plugins フィールドを使用して、プラグインの依存関係として宣言してください。

<?php
/**
 * Plugin Name:      My Plugin
 * Description:      Adds MCP tools for my feature.
 * Requires Plugins: mcp-adapter
 */

プラグインで MCP Adapter を使用する

plugins_loaded で利用可能かどうかを確認し、初期化して、アダプターが起動する前にすべてのプラグインが利用可能であることを確認します。

add_action( 'plugins_loaded', function() {
    if ( ! class_exists( 'WP\MCP\Core\McpAdapter' ) ) {
        // MCP Adapter is not active — show an admin notice or return early.
        return;
    }

    \WP\MCP\Core\McpAdapter::instance();
} );

基本的な使い方

MCP Adapter は、登録された WordPress アビリティを階層化アーキテクチャを通じて公開するデフォルトサーバーを自動的に作成します。これにより、手動でサーバーを設定することなく、すぐに MCP 機能を利用できます。

仕組み:

  • meta.publictrue に設定して wp_register_ability() で登録された WordPress アビリティは、組み込みのアダプターツールを介してデフォルトサーバー上で検出・実行可能になります。

  • meta.mcp.public を明示的に設定すると、MCP のみの高レベル設定を上書きできます。false を指定すると公開アビリティがオプトアウトされ、true を指定すると非公開アビリティが MCP に公開されます。

  • デフォルトサーバーでは、公開アビリティは tools/list に個別に自動登録されるのではなく、mcp-adapter/discover-abilitiesmcp-adapter/get-ability-infomcp-adapter/execute-ability を介してアクセスされます。

  • あるいは、カスタム MCP サーバーの作成 時にアビリティを明示的にリストすることもできます。その場合、meta.mcp.public フラグを必要とせずに、MCP ツール、リソース、プロンプトとして直接公開できます。

  • デフォルトサーバーは HTTP と STDIO の両方のトランスポートをサポートし、複数の MCP プロトコルバージョンをサポートしています。

  • 組み込みのエラーハンドリングと可観測性が含まれています。

  • HTTP でのアクセス: /wp-json/mcp/mcp-adapter-default-server

  • STDIO でのアクセス: wp mcp-adapter serve --server=mcp-adapter-default-server

// Simply register a WordPress ability
add_action( 'wp_abilities_api_init', function() {
    wp_register_ability( 'my-plugin/get-posts', [
        'label' => 'Get Posts',
        'description' => 'Retrieve WordPress posts with optional filtering',
        'category' => 'site',
        'input_schema' => [
            'type' => 'object',
            'properties' => [
                'numberposts' => [
                    'type' => 'integer',
                    'description' => 'Number of posts to retrieve',
                    'default' => 5,
                    'minimum' => 1,
                    'maximum' => 100
                ],
                'post_status' => [
                    'type' => 'string',
                    'description' => 'Post status to filter by',
                    'enum' => ['publish', 'draft', 'private'],
                    'default' => 'publish'
                ]
            ]
        ],
        'output_schema' => [
            'type' => 'array',
            'items' => [
                'type' => 'object',
                'properties' => [
                    'ID' => ['type' => 'integer'],
                    'post_title' => ['type' => 'string'],
                    'post_content' => ['type' => 'string'],
                    'post_date' => ['type' => 'string'],
                    'post_author' => ['type' => 'string']
                ]
            ]
        ],
        'execute_callback' => function( $input ) {
            $args = [
                'numberposts' => $input['numberposts'] ?? 5,
                'post_status' => $input['post_status'] ?? 'publish'
            ];
            return get_posts( $args );
        },
        'permission_callback' => function() {
            return current_user_can( 'read' );
        },
        'meta' => [
            'public' => true, // Expose to clients, including the default MCP server
        ],
    ]);
});

// With the meta.public flag, the ability is exposed through the default MCP server.
// In the default server configuration, discover it via `discover-abilities`
// and invoke it via `mcp-adapter/execute-ability` rather than expecting
// it to appear as its own entry in `tools/list`.
// To opt out of MCP while remaining public to other clients, explicitly set
// meta.mcp.public to false.
// To expose only through MCP, omit `meta.public` and set `meta.mcp.public` to true.
// Without either public flag, abilities are only accessible through custom MCP
// servers that explicitly list them.
// Note: how far `meta.public` reaches depends on the WordPress version. WordPress
// core starts applying `meta.public` to the REST API (`meta.show_in_rest`) in 7.1. On
// WordPress 6.9 and 7.0, this adapter honors `meta.public` for MCP, but REST API
// access still requires setting `meta.show_in_rest` to true.

WordPress アビリティの作成に関する詳細は、Abilities API 開発者向けドキュメント を参照してください。

MCP サーバーへの接続

MCP Adapter は複数の接続方法をサポートしています。MCP クライアントで接続する例を以下に示します。

STDIO トランスポート (ローカル開発)

ローカル開発およびテスト用に、WP-CLI コマンドを使用して MCP サーバーと直接対話できます。

# List all available MCP servers
wp mcp-adapter list

# Test the discover abilities tool to see all available WordPress abilities
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"mcp-adapter-discover-abilities","arguments":{}}}' | wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server

# Test listing available tools
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server

MCP クライアントの設定

MCP クライアント (Claude Desktop、Claude Code、VS Code、Cursor など) を WordPress MCP サーバーに接続するように設定します。

{
  "mcpServers": {
    "wordpress-default": {
      "command": "wp",
      "args": [
        "--path=/path/to/your/wordpress/site",
        "mcp-adapter",
        "serve",
        "--server=mcp-adapter-default-server",
        "--user=admin"
      ]
    },
    "wordpress-custom": {
      "command": "wp",
      "args": [
        "--path=/path/to/your/wordpress/site",
        "mcp-adapter",
        "serve",
        "--server=your-custom-server-id",
        "--user=admin"
      ]
    }
  }
}

@automattic/mcp-wordpress-remote プロキシはローカルで実行され、AI クライアントからの STDIO ベースの MCP 通信を、WordPress が理解できる HTTP REST API 呼び出しに変換します。認証には WordPress アプリケーションパスワード を使用します。

{
  "mcpServers": {
    "wordpress-http-default": {
      "command": "npx",
      "args": [
        "-y",
        "@automattic/mcp-wordpress-remote@latest"
      ],
      "env": {
        "WP_API_URL": "http://your-site.test/wp-json/mcp/mcp-adapter-default-server",
        "LOG_FILE": "/path/to/logs/mcp-adapter.log",
        "WP_API_USERNAME": "your-username",
        "WP_API_PASSWORD": "your-application-password"
      }
    },
    "wordpress-http-custom": {
      "command": "npx",
      "args": [
        "-y",
        "@automattic/mcp-wordpress-remote@latest"
      ],
      "env": {
        "WP_API_URL": "http://your-site.test/wp-json/your-namespace/your-route",
        "LOG_FILE": "/path/to/logs/mcp-adapter.log",
        "WP_API_USERNAME": "your-username",
        "WP_API_PASSWORD": "your-application-password"
      }
    }
  }
}

高度な使い方

カスタム MCP サーバーの作成

特定の設定でカスタム MCP サーバーを作成するなど、高度なユースケースに対応できます。

add_action( 'mcp_adapter_init', function( $adapter ) {
    $adapter->create_server(
        'my-server-id',                    // Unique server identifier
        'my-namespace',                    // REST API namespace
        'mcp',                             // REST API route
        'My MCP Server',                   // Server name
        'Description of my server',        // Server description
        'v1.0.0',                          // Server version
        array(                             // Transport methods
            \WP\MCP\Transport\HttpTransport::class,
        ),
        \WP\MCP\Infrastructure\ErrorHandling\ErrorLogMcpErrorHandler::class,        // Error handler
        \WP\MCP\Infrastructure\Observability\NullMcpObservabilityHandler::class,    // Observability handler
        array( 'my-plugin/my-ability' ),   // Abilities to expose as tools
        array(),                           // Resources (optional)
        array()                            // Prompts (optional)
    );
} );

カスタムトランスポートの実装

MCP Adapter には本番稼働可能な HTTP トランスポートが含まれています。カスタム認証、メッセージキュー、エンタープライズ統合などの特別な要件がある場合は、カスタムトランスポートプロトコルを作成できます。

詳細な実装手順については、カスタムトランスポートガイド を参照してください。

カスタムトランスポート権限

MCP Adapter は、トランスポート権限コールバックによるカスタム認証ロジックをサポートしています。デフォルトの is_user_logged_in() チェックの代わりに、MCP サーバー用のカスタム認証を実装できます。

詳細な認証パターンについては、トランスポート権限ガイド を参照してください。

カスタムエラーハンドラー

MCP Adapter には WordPress 互換のデフォルトのエラーハンドラーが含まれていますが、既存のロギングシステムや監視ツールと統合したり、特定の要件を満たすためにカスタムエラーハンドリングを実装できます。

詳細な実装手順については、エラーハンドリングガイド を参照してください。

カスタム可観測性ハンドラー

MCP Adapter には、メトリクスとイベントを追跡するための組み込みの可観測性が含まれています。カスタムの可観測性ハンドラーを実装して、監視システム、分析プラットフォーム、パフォーマンス追跡ツールと統合できます。

詳細なメトリクストラッキングとカスタムハンドラーの実装については、可観測性ガイド を参照してください。

移行

ライセンス

GPL-2.0-or-later

A
license - permissive license
Not graded
quality - not tested
A
maintenance

Maintenance

Maintainers
53dResponse time
8wRelease cycle
6Releases (12mo)
Commit activity
Issues opened vs closed

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/WordPress/mcp-adapter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server