Skip to content

Conversation

eoigal
Copy link
Contributor

@eoigal eoigal commented Sep 8, 2025

Fixes https://linear.app/a8c/issue/AIINT-164/mcp-abilitieis-on-atomic

Proposed changes:

New Package:

  • Add packages/mcp - Model Context Protocol implementation for Jetpack
  • Provides structured abilities registry for AI model interactions
  • Enables standardized communication between AI models and WordPress functionality
  • Adds WordPress/abilities-api dependency - needed to register abilities - can be removed when available on core.

Core Components:

  • AbilitiesRegistry - Central registry for managing available abilities
  • Executors - Handlers for specific functionality (User, Post, Analytics)
  • Abilities - Individual capability definitions and configurations
  • Helpers - Utility classes for common operations

Key Features:

  • User management abilities (profile, security, notifications, subscriptions)
  • Content management abilities (posts, search, analytics)
  • Site statistics and metrics collection
  • WordPress.com integration for enhanced functionality

Purpose:
Enables AI models to interact with WordPress sites through a standardized protocol, providing secure and structured access to site data and functionality.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Tests included
  • To test on Simple - refer to 192070-ghe-Automattic/wpcom

Copy link
Contributor

github-actions bot commented Sep 8, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/mcp-package branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/mcp-package
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/mcp-package

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] WPCOM API [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Sep 8, 2025
Copy link
Contributor

github-actions bot commented Sep 8, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 7, 2025
    • Code freeze: October 6, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 8, 2025
Copy link

jp-launch-control bot commented Sep 8, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php 387/842 (45.96%) -0.02% -2 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@eoigal eoigal added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Sep 9, 2025
@eoigal eoigal changed the title Add MCP package Add MCP (Model Context Protocol) package Sep 9, 2025
Copy link

@aaronfc aaronfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about Jetpack's but generally speaking looks good to me.

I left a minor comment regarding the README.md and a thought: we will need to review these and make sure new abilities are included in here (like the one I am trying to add in 192057-ghe-Automattic/wpcom/files).

I can do the migration myself once we have this deployed and my PR is approved.

Comment on lines +46 to +53
### 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
Copy link

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].

- Port complete AbilitiesRegistry from wpcom-mcp to Jetpack
- Update site settings endpoint to use Jetpack MCP package
- Add comprehensive tests for AbilityRegistry functionality
- Fix PHP 7.3 compatibility issues (remove typed properties)
- Update namespaces from WpcomMcp to Jetpack
- Fix text domain from wpcom-mcp to jetpack-mcp
- Add missing doc comments and parameter tags to AbilityRegistry methods
- Add @throws tag to AbilityTrait method
- Add missing doc comments to ExecutorFactory methods
- Fix parameter comment formatting in ExecutorInterface
- Fix ExampleUserSitesResourceAbility file naming and add file doc comment
- Remove trailing whitespace in ExecutorFactory
- Update namespaces from WpcomMcp to Jetpack
- Add missing parameter doc comment in AbilityRegistry get_resource_uri method
- Fix trailing whitespace in ExecutorFactory
- Add missing doc comments to UserSitesExecutor methods

All tests still passing (17 tests, 95 assertions)
- Replace PHP 8.0+ union types (WP_Error|array) with PHPDoc annotations
- Remove union type syntax from method signatures
- Maintain type safety through PHPDoc comments
- All tests still passing (17 tests, 95 assertions)

This ensures compatibility with PHP 7.3+ while maintaining code quality.
- Add phpcs:ignore comments for unused parameters and variables
- Fix isset() usage warnings by separating multiple argument checks
- All methods maintain interface compatibility while suppressing warnings
- All 42 files now pass linting with 0 errors and 0 warnings

This ensures clean code standards while maintaining functionality.
eoigal and others added 17 commits September 11, 2025 14:50
- Remove unused Phan suppressions for standard WordPress functions
- Add Phan suppressions for WordPress.com specific functions:
  * is_suspended(), should_check_confidentiality(), has_blog_sticker()
  * user_achieved(), user_achieved_feat(), get_achievement_extras()
  * notes_get(), wpcom_subs_get_wpcom_subscribers_of_blog()
  * get_user_attribute()
- Add Phan suppressions for WordPress.com specific classes:
  * Notification_Settings::__construct(), get_user_attributes_for_notifications()
  * Notification_Settings::get_settings(), get_mobile_push_tokens_of_user()
- Fix type safety issues:
  * Remove redundant object type check in format_notification()
  * Fix WP_Error foreach issue in UserConnectionsExecutor
  * Remove redundant array_values() call
- Fix syntax errors and indentation issues
- All files now pass PHPCS with 0 errors and 0 warnings
- Add Phan suppression for PhanTypeSuspiciousNonTraversableForeach
- Suppress warning about WP_Error in foreach loop where we already check is_wp_error()
- This is a false positive since we return early if  is WP_Error
- All Phan issues now completely resolved
- All Phan static analysis issues have been resolved
- No suppressions needed in baseline
- MCP package now passes all static analysis checks
- This is the best possible outcome for code quality
- Initialize AbilitiesRegistry when package loads
- Hook into abilities_api_init to register abilities dynamically
- Only load for Automatticians on WordPress.com
- Load abilities from configuration without hardcoded names
- Package will now be active and register abilities when loaded
- Call init() directly in the action hook
- Simplifies the initialization flow
- Add Phan suppression for is_automattician() function
- Add Phan suppression for new object creation side effects
- Fix PHPCS formatting for class closing brace
- Use anonymous function instead of class reference in add_action
- Ensures class is autoloaded before init() is called
- Fixes PHPCS formatting issues
- Add automattic/jetpack-mcp:@dev to composer.json
- Regenerate autoloader to include MCP package
- Package is now available for loading in Jetpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs [Feature] WPCOM API I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Mcp [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants