-
Notifications
You must be signed in to change notification settings - Fork 830
Add MCP (Model Context Protocol) package #45108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eoigal
wants to merge
52
commits into
trunk
Choose a base branch
from
add/mcp-package
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
256f445
Add MCP package
eoigal b505c66
Add MCP package
eoigal dd0a61a
changelog
eoigal db3c249
Add Jetpack MCP package with AbilityRegistry port
eoigal 6700ef8
Fix linting errors in MCP package
eoigal 3efab21
Fix remaining critical linting errors
eoigal 2a43719
Fix PHP 7.3 compatibility issues
eoigal 0ee6dde
Fix all PHP linting warnings in MCP package
eoigal a977a2c
fix lint errors
eoigal da5b6c2
Fix syntax errors introduced by PHPCBF
eoigal fa8fa83
Fix remaining syntax errors in UserNotificationsInboxExecutor
eoigal b054812
Fix final syntax errors in remaining MCP executor files
eoigal f3aedc0
Fix final syntax errors in UserConnectionsExecutor
eoigal 7625ef4
Fix indentation errors in PostsSearchExecutor
eoigal d48509b
Fix all remaining PHPCS coding standards violations
eoigal c489171
Fix PHP 7.4 compatibility issues
eoigal ee15d71
Fix remaining PHPCS coding standards violations
eoigal 9246914
Fix Phan static analysis issues
eoigal 2bdba81
Fix remaining Phan static analysis issues
eoigal 396e2de
Fix duplicate Phan suppressions in Ability classes
eoigal 2ec0bb7
Fix final Phan static analysis issues
eoigal 4c99d46
Comprehensive Phan static analysis fixes for AbilitiesRegistry
eoigal 07cb102
Fix final batch of Phan static analysis issues
eoigal 51555d1
Fix comprehensive final batch of Phan static analysis issues
eoigal 0dfad17
Fix final Phan type issue in UserConnectionsExecutor
eoigal 291e4b1
Remove empty Phan baseline file
eoigal 946d165
Add MCP package initialization
eoigal c553d98
Remove redundant package_init method
eoigal b653ea6
Fix PHPCS and Phan issues in class-mcp.php
eoigal 9224779
Fix MCP package initialization
eoigal 0feb5ad
Add MCP package to main Jetpack plugin dependencies
eoigal fa6212f
remove check on wp_abilities_api_init
eoigal 0a10ecd
Remove Phan suppression comments from AbilityRegistry calls
lezama 3294b67
remove check on is_automattican
eoigal cb4a8bb
remove sandbox handling of user ID - seems redundant
eoigal a07af16
add get_current_user_id method
eoigal 070f303
add filters to abilities executors
eoigal f2fa492
fix phan errors
eoigal 7c15a02
add casting and address some minor feedback
eoigal 99c3b7c
add filter for jetpack_mcp_get_ordered_blogs_of_user
eoigal 8de9cbc
Add Abilities API dependency
eoigal e4bf918
update abilities api version
eoigal f587d40
fix phan errors
eoigal 8fc05d9
fix composer issues
eoigal 126e429
fix composer issue
eoigal 8ed0efd
try to resolve php version issue
eoigal 61efd26
move autoloader to suggest
eoigal 376f2a8
update jp composer.lock
eoigal ebfa955
tie jetpack mcp to php 7.4+
eoigal 77eb148
update composer again to make jetpack-mcp optional (depending on php …
eoigal e4d3ddc
more composer meddling
eoigal cbb97d2
fix phan
eoigal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Files not needed to be distributed in the package. | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
package.json export-ignore | ||
|
||
# Files to include in the mirror repo, but excluded via gitignore | ||
# Remember to end all directories with `/**` to properly tag every file. | ||
# /src/js/example.min.js production-include | ||
/vendor/wordpress/abilities-api/** production-include | ||
|
||
# Files to exclude from the mirror repo, but included in the monorepo. | ||
# Remember to end all directories with `/**` to properly tag every file. | ||
.gitignore production-exclude | ||
changelog/** production-exclude | ||
.phpcs.dir.xml production-exclude | ||
tests/** production-exclude | ||
.phpcsignore production-exclude |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor/ | ||
node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* This configuration will be read and overlaid on top of the | ||
* default configuration. Command-line arguments will be applied | ||
* after this file is read. | ||
* | ||
* @package automattic/jetpack-mcp | ||
*/ | ||
|
||
// Require base config. | ||
require __DIR__ . '/../../../../.phan/config.base.php'; | ||
|
||
return make_phan_config( dirname( __DIR__ ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<ruleset> | ||
|
||
<rule ref="WordPress.WP.I18n"> | ||
<properties> | ||
<property name="text_domain" type="array"> | ||
<element value="jetpack-mcp" /> | ||
</property> | ||
</properties> | ||
</rule> | ||
<rule ref="Jetpack.Functions.I18n"> | ||
<properties> | ||
<property name="text_domain" value="jetpack-mcp" /> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="WordPress.Utils.I18nTextDomainFixer"> | ||
<properties> | ||
<property name="old_text_domain" type="array" /> | ||
<property name="new_text_domain" value="jetpack-mcp" /> | ||
</properties> | ||
</rule> | ||
|
||
</ruleset> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Jetpack MCP Package | ||
|
||
Provides MCP (Model Context Protocol) ability registry and related functionality for Jetpack. This package enables cross-platform MCP support across WPCOM, Atomic, and self-hosted Jetpack sites. | ||
|
||
## Features | ||
|
||
- **Complete Abilities Registry**: Port of the WordPress.com MCP Abilities Registry | ||
- **Cross-Platform Support**: Works on WPCOM, Atomic, and self-hosted sites | ||
- **Memory Efficient**: Configuration-driven architecture with lazy loading | ||
- **Extensible**: Easy to add new abilities and executors | ||
- **Integration Ready**: Powers site settings and MCP server functionality | ||
|
||
## What's Included | ||
|
||
This package contains the complete AbilitiesRegistry system: | ||
|
||
- **Registry/AbilityRegistry.php** - Main registry class with lookup methods | ||
- **abilities-config.php** - Central configuration for all abilities | ||
- **Abilities/** - Lightweight ability classes (User, Post, Analytics, etc.) | ||
- **Executors/** - Heavy execution logic classes | ||
- **Interfaces/** - Contracts for abilities and executors | ||
- **Traits/** - Shared functionality and user context | ||
- **Helpers/** - Utility classes for common operations | ||
- **Factories/** - On-demand executor creation with caching | ||
|
||
## Usage | ||
|
||
### Getting MCP Abilities | ||
|
||
```php | ||
use Automattic\Jetpack\AbilitiesRegistry\Registry\AbilityRegistry; | ||
|
||
// Get all resources for site-level server | ||
$resources = AbilityRegistry::get_resources_for_server( 'site-level' ); | ||
|
||
// Get all tools for site-level server | ||
$tools = AbilityRegistry::get_tools_for_server( 'site-level' ); | ||
|
||
// Get all prompts for site-level server | ||
$prompts = AbilityRegistry::get_prompts_for_server( 'site-level' ); | ||
|
||
// Get metadata for a specific ability | ||
$metadata = AbilityRegistry::get_metadata( 'wpcom-mcp/posts-search' ); | ||
``` | ||
|
||
### Available Abilities | ||
|
||
The package includes these ability categories: | ||
|
||
- **User Abilities**: Profile, sites, achievements, connections, notifications, security, subscriptions | ||
- **Post Abilities**: Search, retrieval, and management | ||
- **Analytics Abilities**: Site statistics and metrics | ||
- **Example Abilities**: Templates for creating new abilities | ||
|
||
### Integration | ||
|
||
This package integrates with: | ||
- **Site Settings API**: Provides MCP abilities to the site settings endpoint | ||
- **MCP Servers**: Used by MCP servers to determine available abilities | ||
- **WordPress Admin**: Powers MCP ability configuration in WordPress admin | ||
|
||
## Architecture | ||
|
||
The Abilities Registry uses a memory-efficient, configuration-driven architecture: | ||
|
||
- **Abilities**: Lightweight classes that handle registration and delegate execution | ||
- **Executors**: Heavy classes containing the actual execution logic (only loaded when needed) | ||
- **Registry**: Configuration-driven system that eliminates hardcoded ability names | ||
- **Factory**: Creates executor instances on-demand with caching | ||
|
||
## How to install mcp | ||
|
||
### Installation From Git Repo | ||
|
||
This package is part of the Jetpack monorepo and is automatically available when Jetpack is installed. | ||
|
||
## Contribute | ||
|
||
## Get Help | ||
|
||
## Using this package in your WordPress plugin | ||
|
||
If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well. | ||
|
||
## Security | ||
|
||
Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic). | ||
|
||
## License | ||
|
||
mcp is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt) | ||
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Initial version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"name": "automattic/jetpack-mcp", | ||
"description": "Adds MCP tools support", | ||
"type": "jetpack-library", | ||
"license": "GPL-2.0-or-later", | ||
"require": { | ||
"php": ">=7.4", | ||
"wordpress/abilities-api": "^0.1.1" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"automattic/jetpack-autoloader": true | ||
} | ||
}, | ||
"require-dev": { | ||
"yoast/phpunit-polyfills": "^4.0.0", | ||
"automattic/jetpack-changelogger": "@dev", | ||
"automattic/phpunit-select-config": "@dev", | ||
"phpunit/phpunit": "^9.6" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"scripts": { | ||
"build-development": "echo 'Add your build step to composer.json, please!'", | ||
"build-production": "echo 'Add your build step to composer.json, please!'", | ||
"phpunit": [ | ||
"phpunit-select-config phpunit.#.xml.dist --colors=always" | ||
], | ||
"test-coverage": [ | ||
"php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"" | ||
], | ||
"test-php": [ | ||
"@composer phpunit" | ||
] | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/WordPress/abilities-api" | ||
}, | ||
{ | ||
"type": "path", | ||
"url": "../../packages/*", | ||
"options": { | ||
"monorepo": true | ||
} | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"extra": { | ||
"autotagger": false, | ||
"branch-alias": { | ||
"dev-trunk": "0.1.x-dev" | ||
}, | ||
"changelogger": { | ||
"link-template": "https://github.com/Automattic/jetpack-mcp/compare/v${old}...v${new}" | ||
}, | ||
"mirror-repo": "Automattic/jetpack-mcp", | ||
"textdomain": "jetpack-mcp", | ||
"version-constants": { | ||
"::PACKAGE_VERSION": "src/class-mcp.php" | ||
} | ||
}, | ||
"suggest": { | ||
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@automattic/jetpack-mcp", | ||
"version": "0.1.0-alpha", | ||
"private": true, | ||
"description": "Adds MCP tools support", | ||
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/mcp/#readme", | ||
"bugs": { | ||
"url": "https://github.com/Automattic/jetpack/labels/[Package] Mcp" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Automattic/jetpack.git", | ||
"directory": "projects/packages/mcp" | ||
}, | ||
"license": "GPL-2.0-or-later", | ||
"author": "Automattic", | ||
"scripts": { | ||
"build": "echo 'Not implemented.'", | ||
"build-js": "echo 'Not implemented.'", | ||
"build-production": "echo 'Not implemented.'", | ||
"build-production-js": "echo 'Not implemented.'", | ||
"clean": "true" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="tests/php/bootstrap.php" | ||
cacheDirectory=".phpunit.cache" | ||
colors="true" | ||
executionOrder="depends" | ||
beStrictAboutOutputDuringTests="true" | ||
displayDetailsOnPhpunitDeprecations="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
failOnDeprecation="true" | ||
failOnEmptyTestSuite="true" | ||
failOnPhpunitDeprecation="true" | ||
failOnNotice="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
> | ||
<testsuites> | ||
<testsuite name="main"> | ||
<directory suffix="Test.php">tests/php</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<source> | ||
<include> | ||
<!-- Better to only include "src" than to add "." and then exclude "tests", "vendor", and so on, as PHPUnit still scans the excluded directories. --> | ||
<!-- Add additional lines for any files or directories outside of src/ that need coverage. --> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</source> | ||
<coverage ignoreDeprecatedCodeUnits="true"> | ||
</coverage> | ||
</phpunit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
phpunit.11.xml.dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
phpunit.9.xml.dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" | ||
bootstrap="tests/php/bootstrap.php" | ||
cacheResultFile=".phpunit.cache/test-results" | ||
colors="true" | ||
executionOrder="depends" | ||
beStrictAboutOutputDuringTests="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
> | ||
<testsuites> | ||
<testsuite name="main"> | ||
<directory suffix="Test.php">tests/php</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of this information being included in READMEs which will quickly get outdated.
Saying that because I already added a "Comment" related a "SiteCommentsSearch" ability in a separate "Comment Abilities" category [192057-ghe-Automattic/wpcom/files].