- Autoloader: add automattic/jetpack-autoloader and load
vendor/autoload_packages.php; require wordpress/mcp-adapter directly (^0.5).
- ServerRegistrar: make the adapter create_server() call and the
OAuthServerRegistrar class_exists() check injectable so createServer()'s
unhook-before-create ordering and the "mcp-oauth absent" branch are unit
tested; add a smoke-test check that booting REST triggers no
_doing_it_wrong().
- mcp-smoke.sh: assert mcp-adapter's default server route 404s, and that the
subscriber role-gate denial actually carries our/the adapter's denial text
(not just any isError/error).
- Guard tests/Integration/mint-token.php and tec-probe.php with
`defined('WP_CLI') && WP_CLI || exit;`; add .gitattributes export-ignore
for tests/docs-superpowers/.superpowers/phpunit/phpcs config.
- Security: add Server/RequestContext, tracking via
rest_request_before_callbacks whether the current REST dispatch is our
OAuth-protected /mcp/mcp-oauth-server route; AbilityRegistrar's
permission_callback now denies (after the role gate) when abilities are
invoked outside that route. Wired in Plugin::boot().
- Minors: single Plugin::VERSION constant used by ServerRegistrar;
IntegrationRegistry caches its computed abilities list; tec-probe.php
checks wp_insert_post's result and cleans up its probe post in a
try/finally.
composer test: 47/47 green. composer lint: clean. Full mcp-smoke.sh run ends
ALL CHECKS PASSED (plus the expected /.well-known WARN).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Mints an MCP access token for a user, exactly like mcp-oauth's TokenEndpoint
|
|
* does after a completed OAuth flow. For local integration tests only.
|
|
*
|
|
* Usage: wp eval-file tests/Integration/mint-token.php <user_login>
|
|
*
|
|
* Note: no `declare(strict_types=1);` here — PHP forbids that declaration
|
|
* inside eval()'d code, and `wp eval-file` runs this file through eval().
|
|
* Confirmed with a minimal repro during Task 7 (see task-7-report.md).
|
|
*/
|
|
|
|
defined('WP_CLI') && WP_CLI || exit;
|
|
|
|
use WPMedia\MCP\OAuth\Auth\JWT;
|
|
use WPMedia\MCP\OAuth\Auth\SecretManager;
|
|
|
|
$login = $args[0] ?? '';
|
|
$user = get_user_by('login', $login);
|
|
if (! $user) {
|
|
fwrite(STDERR, "unknown user {$login}\n");
|
|
exit(1);
|
|
}
|
|
|
|
[, $item] = WP_Application_Passwords::create_new_application_password(
|
|
$user->ID,
|
|
['name' => 'lit-mcp-integration-test', 'app_id' => 'lit-mcp-integration-test']
|
|
);
|
|
|
|
$now = time();
|
|
echo JWT::encode([
|
|
'iss' => home_url(),
|
|
'aud' => get_rest_url(null, 'mcp/mcp-oauth-server'),
|
|
'sub' => (string) $user->ID,
|
|
'app_pass_id' => $item['uuid'],
|
|
'client_id' => 'lit-mcp-integration-test',
|
|
'scope' => 'mcp',
|
|
'iat' => $now,
|
|
'exp' => $now + 600,
|
|
], SecretManager::get_secret());
|