227 lines
11 KiB
PHP
227 lines
11 KiB
PHP
<?php
|
|
/**
|
|
* MUA — Mikes Unraid Agent
|
|
* Tool-Definitionen (21 Tools)
|
|
*
|
|
* Schema: unraid_<kategorie>_<aktion>
|
|
* Kategorien: docker (14), network (6), system (1)
|
|
*
|
|
* Identisch zu /opt/mike-ai/unraid-agent/unraid_mcp.py (Python).
|
|
*/
|
|
|
|
function mua_tools(): array {
|
|
return [
|
|
// ── Docker (14) ──────────────────────────────────────────────────
|
|
[
|
|
'name' => 'unraid_docker_list',
|
|
'description' => "List Docker containers with authoritative server-side counts. For active containers always use state='running'. Stats are optional to keep output compact.",
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'state' => ['type' => 'string', 'enum' => ['all', 'running', 'stopped', 'created', 'exited'], 'description' => "Use 'running' for active containers. Default: all."],
|
|
'include_stats' => ['type' => 'boolean', 'description' => 'Include live CPU, RAM and I/O statistics. Default: false.'],
|
|
'detail' => ['type' => 'string', 'enum' => ['compact', 'full'], 'description' => 'compact returns name/status/state; full also returns ID/image/ports.'],
|
|
],
|
|
'additionalProperties' => false,
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_inspect',
|
|
'description' => 'Inspect a single Docker container in detail (state, image, ports, env, mounts).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_logs',
|
|
'description' => 'Get recent logs from a Docker container (with timestamps).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
'tail' => ['type' => 'integer', 'description' => 'Number of lines (1-2000, default 200)'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_analyze_logs',
|
|
'description' => 'Analyze container logs server-side for errors/warnings. Returns pattern counts and sample matches.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'severity' => ['type' => 'string', 'enum' => ['error', 'warn', 'info'], 'description' => 'Log severity to scan for'],
|
|
'container' => ['type' => 'string', 'description' => 'Container name (optional, scans all if omitted)'],
|
|
'since' => ['type' => 'string', 'description' => 'Time filter (default 24h)'],
|
|
'scan_tail' => ['type' => 'integer', 'description' => 'Max lines to scan (default 1000)'],
|
|
'max_results' => ['type' => 'integer', 'description' => 'Max sample matches (default 50)'],
|
|
],
|
|
'required' => ['severity'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_processes',
|
|
'description' => 'List processes running inside a Docker container (docker top).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_stats',
|
|
'description' => 'Get live CPU/memory/network/block I/O stats for all running containers.',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_info',
|
|
'description' => 'Get Docker daemon information (version, storage driver, container counts, etc.).',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_start',
|
|
'description' => 'Start a Docker container.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_stop',
|
|
'description' => 'Stop a Docker container.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_restart',
|
|
'description' => 'Restart a Docker container.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container name or ID'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_create',
|
|
'description' => 'Create a Docker container from a template (pulls image, creates container).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'template_name' => ['type' => 'string', 'description' => 'Template name (e.g. "linuxserver/sonarr")'],
|
|
],
|
|
'required' => ['template_name'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_modify',
|
|
'description' => 'Modify a container template (port, env, volume, network, privileged) and rebuild.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container/template name'],
|
|
'field' => ['type' => 'string', 'enum' => ['port', 'env', 'volume', 'network', 'privileged']],
|
|
'value' => ['type' => 'string', 'description' => 'New value (format depends on field)'],
|
|
],
|
|
'required' => ['container', 'field', 'value'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_update',
|
|
'description' => 'Update a container (pull latest image, rebuild).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container/template name'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_docker_rebuild',
|
|
'description' => 'Rebuild a container from its template (without pulling new image).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'container' => ['type' => 'string', 'description' => 'Container/template name'],
|
|
],
|
|
'required' => ['container'],
|
|
],
|
|
],
|
|
|
|
// ── Netzwerk (6) ─────────────────────────────────────────────────
|
|
[
|
|
'name' => 'unraid_network_inventory',
|
|
'description' => 'Compact Docker network inventory (all networks with container counts).',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
[
|
|
'name' => 'unraid_network_list',
|
|
'description' => 'List all Docker networks.',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
[
|
|
'name' => 'unraid_network_inspect',
|
|
'description' => 'Inspect a Docker network in detail.',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'network' => ['type' => 'string', 'description' => 'Network name or ID'],
|
|
],
|
|
'required' => ['network'],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_network_host_state',
|
|
'description' => 'Get host network state (IPv4/IPv6 addresses, routes, listening sockets).',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
[
|
|
'name' => 'unraid_network_audit_tcp',
|
|
'description' => 'Audit all TCP endpoints: probe IPv4/IPv6 reachability for every published port. Returns classification (dualstack/ipv4-only/ipv6-only/unreachable).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'timeout_seconds' => ['type' => 'number', 'description' => 'Probe timeout (0.2-10, default 2)'],
|
|
'include_all_endpoints' => ['type' => 'boolean', 'description' => 'Include all endpoints (default false, only problems)'],
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'name' => 'unraid_network_lan_probe',
|
|
'description' => 'Probe a specific host:port for IPv4 and IPv6 reachability (dualstack test).',
|
|
'inputSchema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'host' => ['type' => 'string', 'description' => 'Hostname or IP'],
|
|
'port' => ['type' => 'integer', 'description' => 'Port (1-65535)'],
|
|
'timeout_seconds' => ['type' => 'number', 'description' => 'Timeout (0.2-10, default 3)'],
|
|
],
|
|
'required' => ['host', 'port'],
|
|
],
|
|
],
|
|
|
|
// ── System (1) ───────────────────────────────────────────────────
|
|
[
|
|
'name' => 'unraid_system_connection_test',
|
|
'description' => 'Test connection to the Unraid host (hostname, kernel, Unraid version).',
|
|
'inputSchema' => ['type' => 'object', 'properties' => new stdClass(), 'additionalProperties' => false],
|
|
],
|
|
];
|
|
}
|