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\Server;
|
|
|
|
|
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
|
|
|
|
use Laravel\Mcp\Request;
|
|
|
|
|
use Laravel\Mcp\Response;
|
|
|
|
|
use Laravel\Mcp\Server\Tool;
|
|
|
|
|
|
|
|
|
|
class GetServer extends Tool
|
|
|
|
|
{
|
2026-06-04 09:03:06 +00:00
|
|
|
protected string $name = 'get_server';
|
|
|
|
|
|
|
|
|
|
protected string $description = 'Get full details for a single server 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$server = Server::whereTeamId($teamId)->where('uuid', $uuid)->with('settings')->first();
|
|
|
|
|
if (! $server) {
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpError($request, "Server [{$uuid}] not found.", ['resource_uuid' => $uuid]);
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = $this->scrubSensitive($server->toArray());
|
|
|
|
|
$data['is_reachable'] = $server->settings?->is_reachable;
|
|
|
|
|
$data['is_usable'] = $server->settings?->is_usable;
|
|
|
|
|
$data['connection_timeout'] = $server->settings?->connection_timeout;
|
|
|
|
|
|
2026-06-04 09:03:06 +00:00
|
|
|
return $this->mcpSuccess($request, $this->respond($data, $this->actionsForServer($uuid)), ['resource_uuid' => $uuid]);
|
2026-04-29 08:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function schema(JsonSchema $schema): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'uuid' => $schema->string()->description('Server UUID.')->required(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|