2026-04-29 08:30:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Mcp\Tools;
|
|
|
|
|
|
|
|
|
|
use App\Mcp\Concerns\BuildsResponse;
|
|
|
|
|
use App\Mcp\Concerns\ResolvesTeam;
|
|
|
|
|
use App\Models\Application;
|
|
|
|
|
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
|
|
|
|
use Laravel\Mcp\Request;
|
|
|
|
|
use Laravel\Mcp\Response;
|
|
|
|
|
use Laravel\Mcp\Server\Tool;
|
|
|
|
|
|
|
|
|
|
class GetApplication extends Tool
|
|
|
|
|
{
|
2026-06-04 09:03:06 +00:00
|
|
|
protected string $name = 'get_application';
|
|
|
|
|
|
|
|
|
|
protected string $description = 'Get full details for a single application by UUID.';
|
|
|
|
|
|
2026-04-29 08:30:43 +00:00
|
|
|
use BuildsResponse;
|
|
|
|
|
use ResolvesTeam;
|
|
|
|
|
|
|
|
|
|
public function handle(Request $request): Response
|
|
|
|
|
{
|
2026-06-04 09:03:06 +00:00
|
|
|
if ($error = $this->ensureAbility($request, 'read', $this->name)) {
|
2026-04-29 08:30:43 +00:00
|
|
|
return $error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$teamId = $this->resolveTeamId($request);
|
|
|
|
|
if (is_null($teamId)) {
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpError($request, 'Invalid token.');
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$uuid = $request->get('uuid');
|
|
|
|
|
if (! is_string($uuid) || $uuid === '') {
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpError($request, 'uuid argument is required.');
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$application = Application::ownedByCurrentTeamAPI($teamId)->where('uuid', $uuid)->first();
|
|
|
|
|
if (! $application) {
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpError($request, "Application [{$uuid}] not found.", ['resource_uuid' => $uuid]);
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drop relations that the server_status accessor lazy-loads — they
|
|
|
|
|
// pull in sensitive nested data (server.settings.sentinel_token, etc.)
|
|
|
|
|
$application->setRelations([]);
|
|
|
|
|
$application->makeHidden(['destination', 'source', 'additional_servers', 'environment', 'tags', 'environmentVariables']);
|
|
|
|
|
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpSuccess($request, $this->respond(
|
2026-04-29 08:30:43 +00:00
|
|
|
$this->scrubSensitive($application->toArray()),
|
|
|
|
|
$this->actionsForApplication($uuid, $application->status),
|
2026-06-04 09:03:06 +00:00
|
|
|
), ['resource_uuid' => $uuid]);
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function schema(JsonSchema $schema): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'uuid' => $schema->string()->description('Application UUID.')->required(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|