Bỏ qua đến nội dung chính
Premier Solutions
Phát triển & Tối ưu hóa WordPress

How to Expose a WordPress Ability to Claude or ChatGPT with the MCP Adapter, Safely

The MCP Adapter lets AI clients call WordPress abilities. Learn how to register one read-only ability, expose it on purpose and check that permissions still apply.

Nội dung chưa có bản dịch được hiển thị bằng tiếng Anh gốc.

WordPress Ability to Claude or ChatGPT with the MCP Adapter
Trong bài viết này

The Abilities API, added in WordPress 6.9, lets core and plugins register things they can do in a standard, typed and discoverable way. The official MCP Adapter plugin then turns those abilities into tools that AI clients such as Claude or ChatGPT can call through the Model Context Protocol. This guide shows how to register one read-only ability, expose it on purpose and keep WordPress permissions in charge.

What you need

  • WordPress 6.9 or later, which includes the Abilities API in core.
  • The MCP Adapter plugin. The WordPress.org page lists version 0.7.0, and you can install it with WP-CLI:

wp plugin install mcp-adapter --activate

  • An MCP client that can connect to the server, set up by following the adapter's README for the transport you choose.
  • A staging site. Do not try this on production first.

Plugin developers who depend on the adapter can add Requires Plugins: mcp-adapter to their plugin header.

Step 1: register one read-only ability

Each ability has a name, a description, input and output schemas, an execute callback and a permission callback. This example returns the site name and the number of published posts, and requires the edit_posts capability. It follows the pattern in the official documentation, so check the details against the Abilities API reference for your version.

<?php
/**
* Plugin Name: Premier Read-Only Ability (example)
*/
add_action( 'wp_abilities_api_init', function () {
wp_register_ability( 'premier-example/site-summary', array(
'label' => 'Site summary',
'description' => 'Returns the site name and the number of published posts.',
'input_schema' => array( 'type' => 'object', 'properties' => array() ),
'output_schema' => array(
'type' => 'object',
'properties' => array(
'name' => array( 'type' => 'string' ),
'published_posts' => array( 'type' => 'integer' ),
),
),
'execute_callback' => function () {
$counts = wp_count_posts( 'post' );
return array(
'name' => get_bloginfo( 'name' ),
'published_posts' => (int) $counts->publish,
);
},
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
'meta' => array( 'mcp' => array( 'public' => true ) ),
) );
} );

If registration fails, check whether your WordPress version expects an ability category, and follow the Abilities API documentation to add one.

Step 2: expose it on purpose

Abilities are not exposed to MCP clients by default. The adapter's documentation says an ability is available through its default server only if it is marked public, using meta.mcp.public set to true, as in the example above.

WordPress 7.1 adds a unified meta.public flag. The adapter's 0.7.0 notes say abilities with meta.public: true are exposed through the default MCP server unless meta.mcp.public explicitly opts out. Core's announcement is clear that the flag controls exposure only: it does not make an ability executable without authorization and does not replace the permission callback.

Hỗ trợ chuyên môn khi bạn cần

Đưa những ý tưởng vào thực tế.

Từ một cải tiến cụ thể đến một website hoàn chỉnh, chúng tôi giúp bạn xác định phạm vi và triển khai.

Trao đổi về website của tôiPhát triển Web WordPress Tùy chỉnh

Chia sẻ mục tiêu của bạn. Chúng tôi thường phản hồi trong vòng 4 giờ kèm theo các câu hỏi và bước tiếp theo thiết thực.

Step 3: know what the client sees

The adapter registers a default server, mcp-adapter-default-server, with three abilities of its own: mcp-adapter/discover-abilities, mcp-adapter/get-ability-info and mcp-adapter/execute-ability. Public abilities are reached through those three, not listed one by one.

Step 4: test the permissions, not just the happy path

  1. Ask the client to discover abilities and confirm premier-example/site-summary appears.
  2. Read its details, then run it as a user who has the edit_posts capability.
  3. Run it as a user who does not. It should be refused.
  4. Remove the public flag, reload, and confirm the ability disappears from discovery.

If step 3 succeeds for a user without the capability, your permission callback is too loose.

Mistakes to avoid

  • Treating the public flag as security. It controls visibility. The permission callback decides who can run the ability.
  • Returning private data. Keep outputs to what the task needs.
  • Starting with write abilities. Add them one at a time, and only on staging first. Our guide to abilities you should never expose to an AI agent lists the risky ones.
  • Using a broad account. Give the agent a dedicated account with the minimum capabilities.

Các câu hỏi thường gặp

What is the WordPress Abilities API?

It is a way for WordPress core and plugins to register functions that are described, typed and executable, each with a permission callback. It arrived in WordPress 6.9.

Do I need the MCP Adapter plugin to use abilities?

No. Abilities work without it. The adapter is the official bridge that exposes them to AI clients through the Model Context Protocol.

Is it safe to connect an AI agent to my site?

Only as safe as the abilities you expose and the permissions behind them. Start with one read-only ability on a staging site.

Want an agent-ready plugin built carefully?

We build custom plugins with permission checks, strict inputs and logging designed in. See our custom WordPress plugin development.

Được viết bởi

Muhammad Junaid Tariq

Muhammad Junaid Tariq là nhà phát triển web toàn diện và là người sáng lập Premier Solutions. Với 5+ năm kinh nghiệm và 200+ dự án đã giao, anh ấy chuyên phát triển WordPress tùy chỉnh, bảo mật WordPress và loại bỏ phần mềm độc hại, ứng dụng Next.js và SEO kỹ thuật cho khách hàng trên khắp Hoa Kỳ, Vương quốc Anh và Châu Âu.

Quay Lại Blog
Dịch vụ liên quan

Chuyên môn đằng sau hướng dẫn này.

Khám phá các dịch vụ giúp bạn áp dụng kiến thức đã học.

WordPress Biểu tượng

Giải pháp Bảo mật WordPress Nâng cao

Kiểm toán bảo mật WordPress, tăng cường bảo mật, loại bỏ phần mềm độc hại, cập nhật được quản lý và giám sát có phạm vi. Các nghiên cứu tình huống khôi phục được xuất bản cho thấy công việc được thực hiện trên từng trang web riêng lẻ.

Khám phá dịch vụ này

Tiếp tục đọc

Tất cả bài viết