@solomonneas/adguard-mcp 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,71 @@
1
- # adguard-mcp
1
+ <!-- content-guard: allow private-ipv4 file -->
2
+ <p align="center">
3
+ <img src="docs/assets/adguardctrl-social-preview.jpg" alt="adguardctrl banner" width="900">
4
+ </p>
2
5
 
3
- MCP server exposing AdGuard Home read/write tools across one or more instances. 28 tools (11 reads / 12 safe-writes / 5 destructive). Three-tier write gating: reads are open, writes require `confirm: true`, destructive ops require `confirm: true` + `destructive: true`.
6
+ <h1 align="center">adguardctrl</h1>
7
+
8
+ <p align="center">
9
+ <strong>An operator control CLI for AdGuard Home, with an MCP adapter for assistant workflows and back-compatible launchers.</strong>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://lidless.dev/adguard-mcp"><strong>Website</strong></a>
14
+ &nbsp;&middot;&nbsp;
15
+ <a href="#quickstart"><strong>Quickstart</strong></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <img src="https://shieldcn.dev/github/ci/lidless-labs/adguardctrl.svg?branch=main&workflow=ci.yml" alt="CI status">
20
+ <img src="https://shieldcn.dev/npm/@solomonneas/adguard-mcp.svg" alt="npm version">
21
+ <img src="https://shieldcn.dev/badge/license-MIT-green.svg" alt="MIT license">
22
+ </p>
23
+
24
+ `adguardctrl` is an operator control CLI for AdGuard Home, the self-hosted DNS sinkhole. It gives shell, cron, CI, and assistant workflows one typed control surface for inspecting network-wide DNS filtering across one or more boxes. The npm package remains `@solomonneas/adguard-mcp` for compatibility and still ships the back-compatible `adguard-mcp` bin; new MCP launchers can start the adapter with `adguardctrl mcp`.
25
+
26
+ ## What it does
27
+
28
+ `adguardctrl` speaks the AdGuard Home API across one or more instances, plus optional AdGuardHome Sync status and control. The direct CLI is read-only today, covering server status, stats, the DNS query log, filter lists, named clients, DNS rewrites, DNS and TLS config, DHCP status, and a `check-host` lookup that shows exactly what AdGuard would do with a hostname.
29
+
30
+ For assistant clients, `adguardctrl mcp` starts the stdio MCP adapter used by Claude Desktop, Claude Code, Codex CLI, OpenClaw, Hermes, and other Model Context Protocol clients. That adapter keeps the original `adguard-mcp` tool surface and safety model: reads are open, writes require an explicit `confirm: true`, and destructive operations additionally require `destructive: true`, so an agent cannot disable filtering or wipe rules on a hallucinated call.
31
+
32
+ ## Quickstart
33
+
34
+ Install globally:
35
+
36
+ ```
37
+ npm install -g @solomonneas/adguard-mcp
38
+ ```
39
+
40
+ Or run via npx with no install:
41
+
42
+ ```
43
+ npx -y @solomonneas/adguard-mcp
44
+ ```
45
+
46
+ Then use `adguardctrl` from your shell, or wire the package into an MCP client. The minimal config for any client that speaks the standard `mcpServers` shape (Claude Desktop, Claude Code):
47
+
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "adguard": {
52
+ "command": "npx",
53
+ "args": ["-y", "@solomonneas/adguard-mcp"],
54
+ "env": {
55
+ "ADGUARD_PRIMARY_URL": "http://192.0.2.10",
56
+ "ADGUARD_PRIMARY_USERNAME": "admin",
57
+ "ADGUARD_PRIMARY_PASSWORD": "your-password"
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ Once connected, ask your client to call `adguard_status` to confirm it can reach the box. Reads work immediately; writes need the `confirm: true` flag and destructive ops also need `destructive: true`.
4
65
 
5
66
  ## Tools
6
67
 
7
- **Reads (11):** `adguard_status`, `adguard_stats`, `adguard_query_log`, `adguard_list_filter_lists`, `adguard_list_user_rules`, `adguard_list_clients`, `adguard_list_blocked_services_catalog`, `adguard_check_host`, `adguard_get_blocked_services`, `adguard_get_dns_config`, `adguard_get_safesearch_settings`.
68
+ **Reads (14):** `adguard_status`, `adguard_stats`, `adguard_query_log`, `adguard_list_filter_lists`, `adguard_list_user_rules`, `adguard_list_clients`, `adguard_list_blocked_services_catalog`, `adguard_check_host`, `adguard_get_blocked_services`, `adguard_get_dns_config`, `adguard_get_safesearch_settings`, `adguard_sync_status`, `adguard_sync_health`, `adguard_sync_logs`.
8
69
 
9
70
  | Tool | Description |
10
71
  |---|---|
@@ -19,8 +80,11 @@ MCP server exposing AdGuard Home read/write tools across one or more instances.
19
80
  | `adguard_get_blocked_services` | Global blocked-services list + weekly schedule (`GET /control/blocked_services/get`). |
20
81
  | `adguard_get_dns_config` | DNS upstreams, bootstrap, cache, parallel resolution, blocking mode (`GET /control/dns_info`). |
21
82
  | `adguard_get_safesearch_settings` | SafeSearch enabled state + per-engine flags (`GET /control/safesearch/status`). |
83
+ | `adguard_sync_status` | AdGuardHome Sync origin/replica status (`GET /api/v1/status`). |
84
+ | `adguard_sync_health` | AdGuardHome Sync health check (`HEAD /healthz`). |
85
+ | `adguard_sync_logs` | AdGuardHome Sync in-memory logs (`GET /api/v1/logs`). |
22
86
 
23
- **Safe writes (12, require `confirm: true`):** `adguard_add_user_rule`, `adguard_remove_user_rule`, `adguard_add_filter_list`, `adguard_remove_filter_list`, `adguard_toggle_filter_list`, `adguard_set_client_blocked_services`, `adguard_refresh_filter_lists`, `adguard_add_client`, `adguard_update_client`, `adguard_set_blocked_services`, `adguard_toggle_safesearch`, `adguard_toggle_safebrowsing`.
87
+ **Safe writes (13, require `confirm: true`):** `adguard_add_user_rule`, `adguard_remove_user_rule`, `adguard_add_filter_list`, `adguard_remove_filter_list`, `adguard_toggle_filter_list`, `adguard_set_client_blocked_services`, `adguard_refresh_filter_lists`, `adguard_add_client`, `adguard_update_client`, `adguard_set_blocked_services`, `adguard_toggle_safesearch`, `adguard_toggle_safebrowsing`, `adguard_sync_run`.
24
88
 
25
89
  | Tool | Description |
26
90
  |---|---|
@@ -36,8 +100,9 @@ MCP server exposing AdGuard Home read/write tools across one or more instances.
36
100
  | `adguard_set_blocked_services` | Set GLOBAL blocked services + optional weekly schedule; accepts HH:MM strings or ms (`PUT /control/blocked_services/update`). |
37
101
  | `adguard_toggle_safesearch` | Enable or disable SafeSearch globally with per-engine flags (`PUT /control/safesearch/settings`). |
38
102
  | `adguard_toggle_safebrowsing` | Enable or disable AGH SafeBrowsing (`POST /control/safebrowsing/enable` or `/disable`). |
103
+ | `adguard_sync_run` | Trigger AdGuardHome Sync immediately (`POST /api/v1/sync`). |
39
104
 
40
- **Destructive (5, require `confirm: true` + `destructive: true`):** `adguard_replace_user_rules`, `adguard_toggle_protection`, `adguard_delete_client`, `adguard_clear_query_log`, `adguard_reset_stats`.
105
+ **Destructive (6, require `confirm: true` + `destructive: true`):** `adguard_replace_user_rules`, `adguard_toggle_protection`, `adguard_delete_client`, `adguard_clear_query_log`, `adguard_reset_stats`, `adguard_sync_clear_logs`.
41
106
 
42
107
  | Tool | Description |
43
108
  |---|---|
@@ -46,18 +111,19 @@ MCP server exposing AdGuard Home read/write tools across one or more instances.
46
111
  | `adguard_delete_client` | Remove a configured named client; per-client rules and stats are lost (`POST /control/clients/delete`). |
47
112
  | `adguard_clear_query_log` | Wipe the DNS query log (`POST /control/querylog_clear`). |
48
113
  | `adguard_reset_stats` | Zero the stats window (`POST /control/stats_reset`). |
114
+ | `adguard_sync_clear_logs` | Clear AdGuardHome Sync in-memory logs (`POST /api/v1/clear-logs`). |
49
115
 
50
116
  ## Configuration
51
117
 
52
118
  Set per-instance env vars. At least one instance is required.
53
119
 
54
120
  ```
55
- ADGUARD_PRIMARY_URL=http://192.168.1.10
121
+ ADGUARD_PRIMARY_URL=http://192.0.2.10
56
122
  ADGUARD_PRIMARY_USERNAME=admin
57
123
  ADGUARD_PRIMARY_PASSWORD=<password>
58
124
 
59
125
  # Optional second instance:
60
- ADGUARD_SECONDARY_URL=http://192.168.1.11
126
+ ADGUARD_SECONDARY_URL=http://192.0.2.11
61
127
  ADGUARD_SECONDARY_USERNAME=admin
62
128
  ADGUARD_SECONDARY_PASSWORD=<password>
63
129
 
@@ -69,39 +135,52 @@ Instance names are derived from the env-var middle segment (case-insensitive). A
69
135
 
70
136
  Every tool accepts optional `instance: "<name>"` to address a non-default box.
71
137
 
72
- ## Install
138
+ AdGuardHome Sync is optional and uses a separate env prefix so it does not collide with AdGuard Home instance names:
73
139
 
74
140
  ```
75
- npm install -g @solomonneas/adguard-mcp
141
+ ADGUARDHOME_SYNC_URL=http://192.0.2.10:8080
142
+
143
+ # Optional, only when the Sync API is configured with Basic auth:
144
+ ADGUARDHOME_SYNC_USERNAME=sync
145
+ ADGUARDHOME_SYNC_PASSWORD=<password>
76
146
  ```
77
147
 
78
- Or run via npx:
148
+ `ADGUARD_SYNC_URL/USERNAME/PASSWORD` is also accepted as an alias and is reserved for the Sync server, not an AdGuard Home instance named `sync`.
79
149
 
80
- ```
81
- npx -y @solomonneas/adguard-mcp
150
+ If neither Sync URL env var is set, Sync tools remain listed but return a clear config error when called.
151
+
152
+ ## CLI
153
+
154
+ `adguardctrl` is the package's primary operator entry point for shells, cron, and CI. It shares the `AdGuardClient` / `AdGuardSyncClient` core with the MCP adapter and reads the same env config. It exposes only the Tier-1 read tools; writes stay in the MCP/plugin surface behind the tier gates.
155
+
156
+ ```bash
157
+ npx @solomonneas/adguard-mcp@latest status
158
+ # or, installed globally:
159
+ adguardctrl status
160
+ adguardctrl stats
161
+ adguardctrl querylog --limit 20 --blocked-only
162
+ adguardctrl check-host youtube.com --client kid-tablet
163
+ adguardctrl clients list
164
+ adguardctrl filters list
165
+ adguardctrl rewrites list
166
+ adguardctrl dns-config
167
+ adguardctrl tls status # private key is redacted
168
+ adguardctrl sync health # exit 1 if Sync is not healthy (cron-friendly)
169
+ adguardctrl status --json # raw JSON for piping
170
+ adguardctrl status --instance secondary
82
171
  ```
83
172
 
84
- ## Setup
173
+ Run `adguardctrl help` for the full command and flag list. `--instance <name>` targets a non-default AdGuard Home box; `--json` emits raw JSON instead of the concise human-readable summary. Exit codes: `0` success, `1` runtime error (backend unreachable / call failed, and `sync health` when not healthy), `2` usage error (unknown command/flag or bad value).
85
174
 
86
- ### Claude Desktop
175
+ ### Starting the MCP server
87
176
 
88
- `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
177
+ `adguardctrl mcp` (or the back-compat `adguard-mcp` bin) starts the stdio MCP adapter. If a launcher referenced the file path `dist/mcp-server.js` directly, it keeps working; new launchers can point at `dist/mcp-bin.js` (or `dist/cli.js mcp`). Launchers that use the `adguard-mcp` bin name need no change.
89
178
 
90
- ```json
91
- {
92
- "mcpServers": {
93
- "adguard": {
94
- "command": "npx",
95
- "args": ["-y", "@solomonneas/adguard-mcp"],
96
- "env": {
97
- "ADGUARD_PRIMARY_URL": "http://192.168.1.10",
98
- "ADGUARD_PRIMARY_USERNAME": "admin",
99
- "ADGUARD_PRIMARY_PASSWORD": "your-password"
100
- }
101
- }
102
- }
103
- }
104
- ```
179
+ ## Setup per client
180
+
181
+ ### Claude Desktop
182
+
183
+ `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows): use the `mcpServers` block from [Quickstart](#quickstart).
105
184
 
106
185
  ### Claude Code
107
186
 
@@ -140,7 +219,7 @@ mcp_servers:
140
219
  command: npx
141
220
  args: ["-y", "@solomonneas/adguard-mcp"]
142
221
  env:
143
- ADGUARD_PRIMARY_URL: http://192.168.1.10
222
+ ADGUARD_PRIMARY_URL: http://192.0.2.10
144
223
  ADGUARD_PRIMARY_USERNAME: admin
145
224
  ADGUARD_PRIMARY_PASSWORD: your-password
146
225
  ```
@@ -155,7 +234,7 @@ command = "npx"
155
234
  args = ["-y", "@solomonneas/adguard-mcp"]
156
235
 
157
236
  [mcp_servers.adguard.env]
158
- ADGUARD_PRIMARY_URL = "http://192.168.1.10"
237
+ ADGUARD_PRIMARY_URL = "http://192.0.2.10"
159
238
  ADGUARD_PRIMARY_USERNAME = "admin"
160
239
  ADGUARD_PRIMARY_PASSWORD = "your-password"
161
240
  ```
@@ -166,6 +245,25 @@ ADGUARD_PRIMARY_PASSWORD = "your-password"
166
245
  - Tier 2 writes require an explicit `confirm: true` arg; the JSON schema documents this on every write tool.
167
246
  - Tier 3 destructive ops additionally require `destructive: true`. The model cannot disable protection or overwrite the rules block from a hallucinated tool call.
168
247
 
248
+ ## Why not just give the agent the AdGuard Home API?
249
+
250
+ - **The raw AdGuard Home API has no agent-safety layer.** Every endpoint is one call away, including the ones that disable all blocking or wipe your rules. The MCP adapter keeps reads open and gates writes behind `confirm: true` and destructive ops behind `destructive: true`, so a hallucinated tool call cannot silently break your network.
251
+ - **`curl` or a generic HTTP MCP server** would mean the model hand-builds request bodies, handles Basic auth, and remembers which AdGuard quirk applies (the nested `{name, data}` client body, milliseconds-from-midnight schedules, the `PUT` vs `POST` split). `adguardctrl` and its MCP adapter encode those as typed commands and tools, so the caller picks an intent, not an HTTP shape.
252
+ - **A single-instance integration** does not match a real homelab. `adguardctrl` resolves any number of instances from env vars by name and lets commands or MCP tools target a non-default box with one `instance` arg, plus optional AdGuardHome Sync control alongside.
253
+ - **Clicking the web dashboard** works, but not from inside an assistant and not across several boxes at once. This is the same control surface, available to the agent you already have open.
254
+
255
+ ## What adguardctrl is not
256
+
257
+ `adguardctrl` is not a hosted service, a replacement for the AdGuard Home dashboard, or an autonomous network manager.
258
+
259
+ It does not:
260
+
261
+ - run a daemon, scheduler, or background process
262
+ - store or proxy your DNS traffic
263
+ - make any write without an explicit `confirm: true` flag from the caller
264
+ - perform a destructive operation without `confirm: true` and `destructive: true` together
265
+ - talk to AdGuard's hosted DNS product; it targets self-hosted AdGuard Home instances you run
266
+
169
267
  ## License
170
268
 
171
- MIT
269
+ MIT. See [LICENSE](LICENSE).