automattic/wp-feature-api
最新稳定版本:0.1.8
Composer 安装命令:
composer require automattic/wp-feature-api
包简介
A system for exposing WordPress functionality in a standardized, discoverable way for both server and client-side use
关键字:
README 文档
README
This repository will be deprecated as the Abilities API AI Building Block for WordPress continues releasing stable versions, and becomes a core API in WordPress 6.9.
We encourage all users to migrate to Abilities API. Future work, including new features and fixes, will happen there. This repository will remain available in archived form for historical reference.
WordPress Feature API
The WordPress Feature API is a system for exposing WordPress functionality in a standardized, discoverable way for both server and client-side use. It's designed to make WordPress functionality accessible to AI systems (particularly LLMs) and developers through a unified registry of resources and tools.
Key Features
- Unified Registry: Central registry of features accessible from both client and server
- Standardized Format: uses the MCP specification for the registry
- Reuses existing functionality: existing WordPress functionality like REST endpoints are reused as features, making them more discoverable and easier to use by LLMs
- Filterable: Features can be filtered, categorized, and searched for more accurate feature matching
- Extensible: Easy to register new features from plugins and themes
Project Structure
This project is structured as a monorepo using npm workspaces:
packages/client: The core client-side SDK (@automattic/wp-feature-api). Provides the API (registerFeature,executeFeature,Featuretype) for interacting with the feature registry on the frontend and manages the underlying data store. Third-party plugins can use this to register their own client-side features.packages/client-features: A library containing implementations of standard client-side features (e.g., block insertion, navigation). It depends on the client SDK and is used by the main plugin to register the core features for WordPress.demo/wp-feature-api-agent: A demo WordPress plugin showcasing how to use the Feature API, including registering features, and implementing WP Features as tools in a Typescript based AI Agent.src/: Contains the main JavaScript entry point (src/index.js) for the core WordPress plugin. This script initializes the client SDK and registers the core client features when the plugin is active.wp-feature-api.php&includes/: Contains the core PHP logic for the Feature API, including the registry, REST API endpoints, and server-side feature definitions. This is exported as a Composer package for use in other plugins.
MCP
It relies heavily on the MCP Specification, however it's tailored to the needs of WordPress. Since WordPress is by nature both the server and the client, the Feature API is designed to be used in both contexts, and leverage existing WordPress functionality.
Features may surface in an actual WP MCP server consumed by an external MCP client. The main difference is that the features are compatible across the server and client, allowing for WordPress to execute features itself on both the backend and frontend.
Note, this does not implement the MCP server and transport layer. However, the feature registry may be used by an MCP server like Automattic's wordpress-mcp plugin.
Features are not limited to LLM consumption and can be used throughout WordPress directly as a primitive API for generic functionality. Hence the more generic name of "Feature API" instead of "MCP API".
Filtering
An important aspect of the Feature API is its ability to filter features manually and automatically. Since the success of an LLM agent will depend on the quality of tools that match the user's intent or current context within WordPress, the Feature API provides several mechanisms to ensure that the right tools are available at the right time.
Filtering can be done by:
- Querying feature properties
- Keyword search across name, description, and ID.
- Categories
is_eligibleboolean callback- Context matching for when we already have some context and want Features that can be fulfilled using that context.
Getting Started
Development
Installation
- Clone the repository.
- Run
npm run setupto install all dependencies (both PHP and JavaScript).
Building
Run npm run build from the root directory. This command will build all the JavaScript packages (client, client-features, demo) and the main plugin script (src/index.js).
Using WordPress Feature API in Your Plugin via Composer
Plugin developers should include the WordPress Feature API in their plugins using Composer. The Feature API will automatically handle version conflicts when multiple plugins include it.
1. Add as a Composer dependency
Manually adding to your composer.json file:
{
"require": {
"automattic/wp-feature-api": "^0.1.8" // Make sure to use the latest version
}
}
If using the composer command in the terminal:
composer require automattic/wp-feature-api:"^0.1.8"
2. Load the Feature API in your plugin
To safely load the Feature API:
// Plugin bootstrap code function my_plugin_init() { // Just include the main plugin file - it automatically registers itself with the version manager require_once __DIR__ . '/vendor/automattic/wp-feature-api/wp-feature-api.php'; // Register our features once we know API is initialized add_action( 'wp_feature_api_init', 'my_plugin_register_features' ); } // hook into plugins_loaded - the Feature API will resolve which version to use add_action( 'plugins_loaded', 'my_plugin_init' ); /** * Register features provided by this plugin */ function my_plugin_register_features() { // Register your features here wp_register_feature( array( 'id' = 'my-plugin/example-feature', 'name' => 'Example Feature', 'description' => 'An example feature from my plugin', 'callback' => 'my_plugin_example_feature_callback', 'type' => 'tool', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'example_param' => array( 'type' => 'string', 'description' => 'An example parameter', ), ), ), ) ); }
Running the Demo
- Ensure dependencies are installed and code is built (see above).
- Use
@wordpress/env(or your preferred local WordPress environment such as Studio) to start WordPress. You can usenpm run wp-env startfrom the root directory. - Activate the "WordPress Feature API" plugin.
- The demo plugin (
wp-feature-api-agent) should load automatically (controlled by theWP_FEATURE_API_LOAD_DEMOconstant inwp-feature-api.php). You should see an admin notice confirming this. - Navigate to the "WP Feature Agent Demo" page added under the Settings menu in the WordPress admin to configure your OpenAI API key.
- Refresh and see the AI Agent chat interface.
- Ask the AI Agent questions about your WordPress site and features. It has access to both server-side and client-side features.
Contributing
We welcome contributions! Please see our CONTRIBUTING.md for details on how to contribute to this project.
automattic/wp-feature-api 适用场景与选型建议
automattic/wp-feature-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.89k 次下载、GitHub Stars 达 168, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「wordpress」 「features」 「ai」 「llm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 automattic/wp-feature-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 automattic/wp-feature-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 automattic/wp-feature-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adds some direct links and composer auto-fill capabilities.
Application helper classes and methods.
A PSR-7 compatible library for making CRUD API endpoints
Provides basic functionality of a common application
Provee funciones comunes de uso frecuente en proyectos PHP
SamsonFramework Behat generic features,steps and extenstions
统计信息
- 总下载量: 23.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 168
- 点击次数: 16
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-01-04