mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 12:39:24 -07:00
chore: reorganize test scripts, add destructive action tests, fix rclone bug
- Move scripts/test-tools.sh and scripts/test-actions.sh → tests/mcporter/ - Fix PROJECT_DIR path in test-tools.sh (SCRIPT_DIR/.. → SCRIPT_DIR/../..) - Add tests/mcporter/test-destructive.sh: 2 live + 13 skipped destructive tests - stdio transport (no running server required) - notifications:delete (create→list→delete), keys:delete (create→delete→verify) - 3 new skips: createDockerFolder/updateSshSettings/createRCloneRemote not in API - Requires --confirm flag; dry-run by default - Add tests/mcporter/README.md documenting both scripts and coverage - Rewrite docs/DESTRUCTIVE_ACTIONS.md: merge test guide, all 15 actions with commands - Delete docs/test-actions.md (merged into tests/mcporter/README.md) - Fix rclone.py create_remote: send "parameters" not "config" (API field name) - Update README.md and CLAUDE.md: 11 tools/~104 actions, new script paths - Add AGENTS.md and GEMINI.md symlinks to CLAUDE.md - Bump version 0.4.3 → 0.4.4 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
70
CLAUDE.md
70
CLAUDE.md
@@ -84,17 +84,27 @@ docker compose down
|
||||
- **Health Monitoring**: Comprehensive health check tool for system monitoring
|
||||
- **Real-time Subscriptions**: WebSocket-based live data streaming
|
||||
|
||||
### Tool Categories (10 Tools, 76 Actions)
|
||||
1. **`unraid_info`** (19 actions): overview, array, network, registration, connect, variables, metrics, services, display, config, online, owner, settings, server, servers, flash, ups_devices, ups_device, ups_config
|
||||
### Tool Categories (11 Tools, ~104 Actions)
|
||||
1. **`unraid_info`** (21 actions): overview, array, network, registration, connect, variables, metrics, services, display, config, online, owner, settings, server, servers, flash, ups_devices, ups_device, ups_config, update_server, update_ssh
|
||||
2. **`unraid_array`** (5 actions): parity_start, parity_pause, parity_resume, parity_cancel, parity_status
|
||||
3. **`unraid_storage`** (6 actions): shares, disks, disk_details, unassigned, log_files, logs
|
||||
4. **`unraid_docker`** (15 actions): list, details, start, stop, restart, pause, unpause, remove, update, update_all, logs, networks, network_details, port_conflicts, check_updates
|
||||
3. **`unraid_storage`** (7 actions): shares, disks, disk_details, unassigned, log_files, logs, flash_backup
|
||||
4. **`unraid_docker`** (26 actions): list, details, start, stop, restart, pause, unpause, remove, update, update_all, logs, networks, network_details, port_conflicts, check_updates, create_folder, set_folder_children, delete_entries, move_to_folder, move_to_position, rename_folder, create_folder_with_items, update_view_prefs, sync_templates, reset_template_mappings, refresh_digests
|
||||
5. **`unraid_vm`** (9 actions): list, details, start, stop, pause, resume, force_stop, reboot, reset
|
||||
6. **`unraid_notifications`** (9 actions): overview, list, warnings, create, archive, unread, delete, delete_archived, archive_all
|
||||
7. **`unraid_rclone`** (4 actions): list_remotes, config_form, create_remote, delete_remote
|
||||
8. **`unraid_users`** (1 action): me
|
||||
9. **`unraid_keys`** (5 actions): list, get, create, update, delete
|
||||
10. **`unraid_health`** (3 actions): check, test_connection, diagnose
|
||||
11. **`unraid_settings`** (9 actions): update, update_temperature, update_time, configure_ups, update_api, connect_sign_in, connect_sign_out, setup_remote_access, enable_dynamic_remote_access
|
||||
|
||||
### Destructive Actions (require `confirm=True`)
|
||||
- **docker**: remove, update_all, delete_entries, reset_template_mappings
|
||||
- **vm**: force_stop, reset
|
||||
- **notifications**: delete, delete_archived
|
||||
- **rclone**: delete_remote
|
||||
- **keys**: delete
|
||||
- **storage**: flash_backup
|
||||
- **settings**: configure_ups, setup_remote_access, enable_dynamic_remote_access
|
||||
|
||||
### Environment Variable Hierarchy
|
||||
The server loads environment variables from multiple locations in order:
|
||||
@@ -119,3 +129,55 @@ The server loads environment variables from multiple locations in order:
|
||||
- Selective queries to avoid GraphQL type overflow issues
|
||||
- Optional caching controls for Docker container queries
|
||||
- Log file overwrite at 10MB cap to prevent disk space issues
|
||||
|
||||
## Critical Gotchas
|
||||
|
||||
### Mutation Handler Ordering
|
||||
**Mutation handlers MUST return before the `QUERIES[action]` lookup.** Mutations are not in the `QUERIES` dict — reaching that line for a mutation action causes a `KeyError`. Always add early-return `if action == "mutation_name": ... return` blocks BEFORE the `QUERIES` lookup.
|
||||
|
||||
### Test Patching
|
||||
- Patch at the **tool module level**: `unraid_mcp.tools.info.make_graphql_request` (not core)
|
||||
- `conftest.py`'s `mock_graphql_request` patches the core module — wrong for tool-level tests
|
||||
- Use `conftest.py`'s `make_tool_fn()` helper or local `_make_tool()` pattern
|
||||
|
||||
### Test Suite Structure
|
||||
```
|
||||
tests/
|
||||
├── conftest.py # Shared fixtures + make_tool_fn() helper
|
||||
├── test_*.py # Unit tests (mock at tool module level)
|
||||
├── http_layer/ # httpx-level request/response tests (respx)
|
||||
├── integration/ # WebSocket subscription lifecycle tests (slow)
|
||||
├── safety/ # Destructive action guard tests
|
||||
└── schema/ # GraphQL query validation (99 tests, all passing)
|
||||
```
|
||||
|
||||
### Running Targeted Tests
|
||||
```bash
|
||||
uv run pytest tests/safety/ # Destructive action guards only
|
||||
uv run pytest tests/schema/ # GraphQL query validation only
|
||||
uv run pytest tests/http_layer/ # HTTP/httpx layer only
|
||||
uv run pytest tests/test_docker.py # Single tool only
|
||||
uv run pytest -x # Fail fast on first error
|
||||
```
|
||||
|
||||
### Scripts
|
||||
```bash
|
||||
# HTTP smoke-test against a live server (11 tools, all non-destructive actions)
|
||||
./tests/mcporter/test-actions.sh [MCP_URL] # default: http://localhost:6970/mcp
|
||||
|
||||
# stdio smoke-test, no running server needed (good for CI)
|
||||
./tests/mcporter/test-tools.sh [--parallel] [--timeout-ms N] [--verbose]
|
||||
```
|
||||
See `tests/mcporter/README.md` for transport differences and `docs/DESTRUCTIVE_ACTIONS.md` for exact destructive-action test commands.
|
||||
|
||||
### API Reference Docs
|
||||
- `docs/UNRAID_API_COMPLETE_REFERENCE.md` — Full GraphQL schema reference
|
||||
- `docs/UNRAID_API_OPERATIONS.md` — All supported operations with examples
|
||||
|
||||
Use these when adding new queries/mutations.
|
||||
|
||||
### Symlinks
|
||||
`AGENTS.md` and `GEMINI.md` are symlinks to `CLAUDE.md` for Codex/Gemini compatibility:
|
||||
```bash
|
||||
ln -sf CLAUDE.md AGENTS.md && ln -sf CLAUDE.md GEMINI.md
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user