Feat - Add a built-in MCP server for AI-assistant control in NotificationX - #156
Open
ShahrearMSf wants to merge 3 commits into
Open
Feat - Add a built-in MCP server for AI-assistant control in NotificationX#156ShahrearMSf wants to merge 3 commits into
ShahrearMSf wants to merge 3 commits into
Conversation
Introduce a self-contained Model Context Protocol (MCP) server so AI assistants such as Claude, ChatGPT and Cursor can manage NotificationX in natural language. It is off by default, administrator-only, and loads only on PHP 7.0+ so the plugin's stated 5.6 floor is unchanged. Abilities (includes/Abilities): a WordPress-Abilities-API-shaped registry exposing 6 read tools (list/get notifications, analytics, types, sources, settings) and 4 write tools (toggle, update, duplicate, delete), with the free single-active-notification cap enforced and secrets redacted. MCP module (includes/MCP): JSON-RPC 2.0 transport over a pretty /notificationx/mcp endpoint and the REST route, an abilities-to-tools bridge, pairing-token auth and a full OAuth 2.1 authorization server with PKCE (dynamic client registration, discovery, refresh-token rotation), per-request admin impersonation, a per-IP rate limiter, read/write scope gating and a loopback self-test. Adds a native NotificationX settings tab (status, connector URL, tokens, per-client setup, connected apps, health). Wire the module in via NotificationX::__construct and regenerate the Composer classmap for the new classes.
Keep the "Enable MCP access" label and switch on a single row instead of quickbuilder's fixed 200px label column, which left a large gap and floated the toggle far to the right with the help text indented beneath it. The help now spans full width, left-aligned with the label. CSS only, scoped to the enable_mcp field; no behaviour change.
Expose NotificationX form submissions (Popup / Exit Intent) over the MCP server. list-entries lists entries with notification/source/search filters and pagination; export-entries returns the feedback CSV. The submitter name and email are included only when Pro is active, mirroring the admin Feedback Entries export.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a built-in MCP server for AI-assistant control (#84280) in NotificationX
Summary
Adds a Model Context Protocol (MCP) server built directly into NotificationX (Free) so approved AI assistants — Claude, ChatGPT, Cursor, and any MCP-compatible client — can manage notifications and read analytics in plain language. It is fully self-contained: no companion plugin, no external service, no terminal.
The feature is off by default, administrator-only, and loads only on a capable PHP runtime, so nothing changes for existing installs until an admin turns it on.
What's included
10 tools (abilities) exposed over MCP
list-notifications,get-notification,list-types,list-sources,get-analytics,get-settingstoggle-notification,update-notification,duplicate-notification,delete-notification…/notificationx/mcp(plus the REST route) handlinginitialize/ping/tools/list/tools/call..well-knowndiscovery, refresh-token rotation, and a first-party consent page.How it works
tools/list/tools/call. Every request authenticates (pairing token or OAuth access token) and then runs as the granting administrator — each ability re-checks native WP capabilities.Security
enable_mcpsetting; when off, the endpoint returns403and discovery is inert.manage_options.get-settingsnever returns API keys/tokens.delete-notificationneedsconfirm:true).Compatibility & rollout
Screenshots
Free
1. Enable & status — top of the MCP tab
2. Connection & client setup
3. Connected apps
4. Connection health
With Pro active
Top of the MCP tab (Pro installed)
Testing
Verified on a local site and a live HTTPS site, Free only (and with Pro active for the settings-tab render).
Transport & discovery
401+WWW-Authenticatechallenge;initializereturns the correct protocol/server info;tools/list→ 10 tools; both.well-knownOAuth documents serve200.Tools
get-settingsredacts secrets (***redacted***).update(rename),toggle(correct state + free single-active cap honored),duplicate(creates disabled),delete(confirm-gate: no-confirm blocked, with-confirm deleted).OAuth 2.1 + PKCE (one-click path)
invalid_grant).Management actions
401, new →200), per-app revoke (token200→401, app removed), disconnect-all, and reconnect all verified.Connected apps
Free features + analytics accuracy (live site)
get-analyticstool, the dashboard Total Views, and the list row.Bugs found & fixed during testing
toggle-notificationreported a staleenabledvalue (read a memoized state) — now re-reads from storage.401instead of429when rate-limited (the auth header was reset after the status) — status is now asserted last.UI polish
Reviewer notes
vendor/composer/autoload_classmap.php+autoload_static.phpare committed alongside the new classes.