winzik/tools/plugin-check.php
David Nurdin d64b0ac193 JumPHP IDE 0.1.26: plugins give Claude tools (the IDE's MCP server)
- Api::mcpTool($name, $description, fn (array $args), $properties, $required): offered on jumphp-ide beside the
  IDE's own tools as plugin_<id>_<name> (mcp__jumphp-ide__plugin_<id>_<name>), run in PHP (not in the interface),
  a string / array / MCP result / Deferred; an exception is the tool's error; gone when the plugin is disabled
- McpServer: its tools may come from a closure (asked at each tools/list); IdeAgent::setExtraTools()
- PluginTestCase: mcp(), mcpTools(); hello-plugin / skeleton-plugin: list_todos and its test
- the Plugins window lists each plugin's tools for Claude; Claude's instructions name them
- docs/ide-plugins.md (Tools for Claude), docs/ide.md, docs/ide.fr.md, AGENTS.md §19

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X3cUrpEPheHAT512jkSvAK
2026-11-03 00:01:37 +01:00

33 lines
1.4 KiB
PHP

<?php
// bin/jumphp test <plugin>: loads the plugin in the IDE's core on an empty project, as the IDE does; fails on an
// error or a PHP warning. Run in the plugin's folder (its vendor/ has jumphp/ide).
use JumPHP\Ide\Ide;
use JumPHP\Ide\Workspace\LocalWorkspace;
$dir = realpath($argv[1] ?? '.');
require "$dir/vendor/autoload.php";
set_error_handler(function (int $no, string $message, string $file, int $line): bool {
fwrite(STDERR, "PHP warning: $message ($file:$line)\n");
exit(1);
});
$project = sys_get_temp_dir() . '/plugin-check-' . getmypid();
@mkdir($project, 0777, true);
$errors = [];
$ide = new Ide(new LocalWorkspace($project), null, function (string $event, array $payload) use (&$errors): void {
if ($event === 'ide.error') {
$errors[] = "{$payload['where']}: {$payload['message']} ({$payload['at']})";
}
});
$loaded = $ide->enablePlugins(null)->load($dir, 'dev');
$c = $ide->plugins->contributions();
foreach ($c['tools'] as $tool) {
$ide->plugins->view($tool['id']);
}
exec('rm -rf ' . escapeshellarg($project));
if (($loaded['status'] ?? '') !== 'active' || $errors) {
fwrite(STDERR, ($loaded['error'] ?? '') . "\n" . implode("\n", $errors) . "\n");
exit(1);
}
printf("%s %s: %d action(s), %d tool window(s), %d run configuration(s), %d provider(s), %d tool(s) for Claude\n", $loaded['name'], $loaded['version'],
count($c['actions']), count($c['tools']), count($c['run']), count($c['providers']), count($c['mcp']));