This repository has been archived on 2026-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
php-agentic/Mcp/Tools/Agent/Plan/PlanGet.php
Snider 6f0618692a
Some checks failed
CI / PHP 8.3 (push) Failing after 2s
CI / PHP 8.4 (push) Failing after 2s
feat: add plan/session/phase/task Actions + slim MCP tools
Extract business logic from MCP tool handlers into 15 Action classes
(Plan 5, Session 5, Phase 3, Task 2) following the Brain pattern.
MCP tools become thin wrappers calling Action::run(). Add framework-level
REST controllers and routes as sensible defaults for consumers.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-04 13:58:45 +00:00

84 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Plan;
use Core\Mcp\Dependencies\ToolDependency;
use Core\Mod\Agentic\Actions\Plan\GetPlan;
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
/**
* Get detailed information about a specific plan.
*/
class PlanGet extends AgentTool
{
protected string $category = 'plan';
protected array $scopes = ['read'];
/**
* Get the dependencies for this tool.
*
* Workspace context is required to ensure tenant isolation.
*
* @return array<ToolDependency>
*/
public function dependencies(): array
{
return [
ToolDependency::contextExists('workspace_id', 'Workspace context required for plan operations'),
];
}
public function name(): string
{
return 'plan_get';
}
public function description(): string
{
return 'Get detailed information about a specific plan';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'slug' => [
'type' => 'string',
'description' => 'Plan slug identifier',
],
'format' => [
'type' => 'string',
'description' => 'Output format: json or markdown',
'enum' => ['json', 'markdown'],
],
],
'required' => ['slug'],
];
}
public function handle(array $args, array $context = []): array
{
$workspaceId = $context['workspace_id'] ?? null;
if ($workspaceId === null) {
return $this->error('workspace_id is required. Ensure you have authenticated with a valid API key and started a session. See: https://host.uk.com/ai');
}
try {
$plan = GetPlan::run($args['slug'] ?? '', (int) $workspaceId);
} catch (\InvalidArgumentException $e) {
return $this->error($e->getMessage());
}
$format = $args['format'] ?? 'json';
if ($format === 'markdown') {
return $this->success(['markdown' => $plan->toMarkdown()]);
}
return $this->success(['plan' => $plan->toMcpContext()]);
}
}