lameco / craft-mcp-activity
Logs the calls made on Craft CMS's native authenticated MCP server and shows them in the control panel
Package info
github.com/Lameco-Development/craft-mcp-activity
Type:craft-plugin
pkg:composer/lameco/craft-mcp-activity
Requires
- php: ^8.2
- craftcms/cms: ^5.12
Requires (Dev)
- craftcms/phpstan: dev-main
- markhuot/craft-pest-core: ^3.2
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1
- symplify/easy-coding-standard: ^13.3.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 07:59:38 UTC
README
Logs the calls made on Craft CMS 5.12's native authenticated MCP server and shows them in the control panel.
Requires Craft CMS 5.12 or later and PHP 8.2 or later.
Installation
composer require lameco/craft-mcp-activity php craft plugin/install mcp-activity
Logging starts as soon as the plugin is installed and Craft's authenticated MCP server is enabled. Installing creates one table, mcpactivity_calls.
Configuration
Copy the settings you want to change into config/mcp-activity.php:
<?php return [ // Log read-only calls (resources/read, prompts/get and tools whose readOnlyHint is true). // Failed reads are always logged. 'logReads' => true, // Days a logged call is kept; Craft's garbage collection removes older calls. // 0 keeps every call forever. 'retentionDays' => 90, ];
Permission
The screens use Craft's own plugin permission Access MCP Activity (accessPlugin-mcp-activity), under General in a user's or group's permissions. Admins always have it. It shows:
- MCP activity in the control panel navigation: every logged call, with filters and a detail screen per call;
- an MCP activity panel in the sidebar of each entry the calls changed.
Elements the viewer may not view in Craft are shown by type and ID only; a user they may not view is shown by the username stored with the call, without a link to the account.
What is logged
One row per call of the methods initialize, tools/call, resources/read and prompts/get, and only for requests Craft authenticated with an MCP access token:
- the user, the app (the OAuth client's name, and the name and version the app reports about itself), the MCP session ID;
- the method, the tool or prompt name, or the resource URI without credentials, query string or fragment;
- the outcome (success, tool error or protocol error) and the error message, cut to 500 characters;
- a summary of the arguments: IDs, UIDs, handles, types, booleans and numbers as sent, every other string as its length only;
- an HMAC of the full arguments, so identical calls can be recognised without storing them;
- the elements the request saved, deleted or restored, with their drafts and revisions;
- the duration of the HTTP request.
A revision created by an MCP call without notes of its own gets the note Via MCP (<app>).
The app names are reported by the apps themselves, so the screens mark them "(reported by the app)".
What is never logged
- IP addresses, access tokens and the
Authorizationheader; - argument text, content bodies and responses;
- values under sensitive keys (such as passwords, tokens and keys), stored as
••••••••; - tool or prompt names, session IDs and argument keys that do not read as names or IDs;
- pings, notifications and list calls;
- requests Craft refuses or did not authenticate, and request bodies larger than the 4 MiB the MCP server reads.
Development
Development needs PHP 8.3 or later (Pest 4); the plugin itself runs on PHP 8.2.
composer install cp .env.example .env # fill in a dedicated, empty test database and a security key composer test # Pest on craft-pest; installs Craft into the test database on the first run composer check-cs # ECS composer phpstan # PHPStan
Every test runs inside a transaction that is rolled back, so the test database stays empty. Arguments after -- go to Pest, for example composer test -- tests/Feature/ActivityFilterTest.php or composer test -- --order-by=random.
Releases
Versions follow Conventional Commits: on every push to main, release-please keeps a release pull request open with the next version and its CHANGELOG.md entry (fix: raises the patch version, feat: the minor version while below 1.0, and a breaking change goes to 1.0.0). Merging that pull request tags the release (without a v, for example 0.1.0) and publishes a GitHub release; Packagist picks up the tag.
When a release adds a migration, set or raise public string $schemaVersion in src/Plugin.php (Craft's default is 1.0.0) in the same change: release-please does not touch it, and Craft only runs a plugin's new migrations when its schema version changes.