@solomonneas/adguard-mcp 0.1.1 → 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 +169 -34
- package/dist/cli.js +2825 -0
- package/dist/index.js +1148 -21
- package/dist/mcp-bin.js +1781 -0
- package/dist/mcp-server.js +1238 -84
- package/openclaw.plugin.json +8 -4
- package/package.json +40 -9
package/README.md
CHANGED
|
@@ -1,26 +1,129 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
6
|
+
<h1 align="center">adguardctrl</h1>
|
|
4
7
|
|
|
5
|
-
|
|
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
|
+
·
|
|
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
|
+
```
|
|
6
45
|
|
|
7
|
-
|
|
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):
|
|
8
47
|
|
|
9
|
-
|
|
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
|
+
```
|
|
10
63
|
|
|
11
|
-
|
|
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`.
|
|
65
|
+
|
|
66
|
+
## Tools
|
|
67
|
+
|
|
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`.
|
|
69
|
+
|
|
70
|
+
| Tool | Description |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `adguard_status` | Server status + protection state (`GET /control/status`). |
|
|
73
|
+
| `adguard_stats` | Stats window: top queries, blocked counts, clients (`GET /control/stats`). |
|
|
74
|
+
| `adguard_query_log` | DNS query log slice with filters (`GET /control/querylog`). |
|
|
75
|
+
| `adguard_list_filter_lists` | Subscribed blocklists + allowlists (`GET /control/filtering/status`). |
|
|
76
|
+
| `adguard_list_user_rules` | Custom user rules (`GET /control/filtering/status`). |
|
|
77
|
+
| `adguard_list_clients` | Configured named clients (`GET /control/clients`). |
|
|
78
|
+
| `adguard_list_blocked_services_catalog` | Available service IDs to block (`GET /control/blocked_services/services`). |
|
|
79
|
+
| `adguard_check_host` | Test what AGH would do with a hostname: filter decision, matched rules, CNAME chain, IPs (`GET /control/filtering/check_host`). |
|
|
80
|
+
| `adguard_get_blocked_services` | Global blocked-services list + weekly schedule (`GET /control/blocked_services/get`). |
|
|
81
|
+
| `adguard_get_dns_config` | DNS upstreams, bootstrap, cache, parallel resolution, blocking mode (`GET /control/dns_info`). |
|
|
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`). |
|
|
86
|
+
|
|
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`.
|
|
88
|
+
|
|
89
|
+
| Tool | Description |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `adguard_add_user_rule` | Append a single user filter rule (`POST /control/filtering/set_rules`). |
|
|
92
|
+
| `adguard_remove_user_rule` | Remove a single user filter rule by exact match (`POST /control/filtering/set_rules`). |
|
|
93
|
+
| `adguard_add_filter_list` | Subscribe to a new blocklist or allowlist URL (`POST /control/filtering/add_url`). |
|
|
94
|
+
| `adguard_remove_filter_list` | Unsubscribe from a filter list by URL (`POST /control/filtering/remove_url`). |
|
|
95
|
+
| `adguard_toggle_filter_list` | Enable or disable a subscribed filter list (`POST /control/filtering/set_url`). |
|
|
96
|
+
| `adguard_set_client_blocked_services` | Set per-client blocked services + schedule (`POST /control/clients/update`). |
|
|
97
|
+
| `adguard_refresh_filter_lists` | Force refresh subscribed filter lists immediately (`POST /control/filtering/refresh`). |
|
|
98
|
+
| `adguard_add_client` | Register a new named client with per-client settings (`POST /control/clients/add`). |
|
|
99
|
+
| `adguard_update_client` | Full update for an existing named client; body is nested `{name, data}` (`POST /control/clients/update`). |
|
|
100
|
+
| `adguard_set_blocked_services` | Set GLOBAL blocked services + optional weekly schedule; accepts HH:MM strings or ms (`PUT /control/blocked_services/update`). |
|
|
101
|
+
| `adguard_toggle_safesearch` | Enable or disable SafeSearch globally with per-engine flags (`PUT /control/safesearch/settings`). |
|
|
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`). |
|
|
104
|
+
|
|
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`.
|
|
106
|
+
|
|
107
|
+
| Tool | Description |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `adguard_replace_user_rules` | Wholesale replace the user rules block (`POST /control/filtering/set_rules`). |
|
|
110
|
+
| `adguard_toggle_protection` | Enable or disable global filtering; off stops ALL blocking (`POST /control/protection`). |
|
|
111
|
+
| `adguard_delete_client` | Remove a configured named client; per-client rules and stats are lost (`POST /control/clients/delete`). |
|
|
112
|
+
| `adguard_clear_query_log` | Wipe the DNS query log (`POST /control/querylog_clear`). |
|
|
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`). |
|
|
12
115
|
|
|
13
116
|
## Configuration
|
|
14
117
|
|
|
15
118
|
Set per-instance env vars. At least one instance is required.
|
|
16
119
|
|
|
17
120
|
```
|
|
18
|
-
ADGUARD_PRIMARY_URL=http://192.
|
|
121
|
+
ADGUARD_PRIMARY_URL=http://192.0.2.10
|
|
19
122
|
ADGUARD_PRIMARY_USERNAME=admin
|
|
20
123
|
ADGUARD_PRIMARY_PASSWORD=<password>
|
|
21
124
|
|
|
22
125
|
# Optional second instance:
|
|
23
|
-
ADGUARD_SECONDARY_URL=http://192.
|
|
126
|
+
ADGUARD_SECONDARY_URL=http://192.0.2.11
|
|
24
127
|
ADGUARD_SECONDARY_USERNAME=admin
|
|
25
128
|
ADGUARD_SECONDARY_PASSWORD=<password>
|
|
26
129
|
|
|
@@ -32,39 +135,52 @@ Instance names are derived from the env-var middle segment (case-insensitive). A
|
|
|
32
135
|
|
|
33
136
|
Every tool accepts optional `instance: "<name>"` to address a non-default box.
|
|
34
137
|
|
|
35
|
-
|
|
138
|
+
AdGuardHome Sync is optional and uses a separate env prefix so it does not collide with AdGuard Home instance names:
|
|
36
139
|
|
|
37
140
|
```
|
|
38
|
-
|
|
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>
|
|
39
146
|
```
|
|
40
147
|
|
|
41
|
-
|
|
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`.
|
|
42
149
|
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
45
171
|
```
|
|
46
172
|
|
|
47
|
-
|
|
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).
|
|
48
174
|
|
|
49
|
-
###
|
|
175
|
+
### Starting the MCP server
|
|
50
176
|
|
|
51
|
-
|
|
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.
|
|
52
178
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"args": ["-y", "@solomonneas/adguard-mcp"],
|
|
59
|
-
"env": {
|
|
60
|
-
"ADGUARD_PRIMARY_URL": "http://192.168.1.10",
|
|
61
|
-
"ADGUARD_PRIMARY_USERNAME": "admin",
|
|
62
|
-
"ADGUARD_PRIMARY_PASSWORD": "your-password"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
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).
|
|
68
184
|
|
|
69
185
|
### Claude Code
|
|
70
186
|
|
|
@@ -103,7 +219,7 @@ mcp_servers:
|
|
|
103
219
|
command: npx
|
|
104
220
|
args: ["-y", "@solomonneas/adguard-mcp"]
|
|
105
221
|
env:
|
|
106
|
-
ADGUARD_PRIMARY_URL: http://192.
|
|
222
|
+
ADGUARD_PRIMARY_URL: http://192.0.2.10
|
|
107
223
|
ADGUARD_PRIMARY_USERNAME: admin
|
|
108
224
|
ADGUARD_PRIMARY_PASSWORD: your-password
|
|
109
225
|
```
|
|
@@ -118,7 +234,7 @@ command = "npx"
|
|
|
118
234
|
args = ["-y", "@solomonneas/adguard-mcp"]
|
|
119
235
|
|
|
120
236
|
[mcp_servers.adguard.env]
|
|
121
|
-
ADGUARD_PRIMARY_URL = "http://192.
|
|
237
|
+
ADGUARD_PRIMARY_URL = "http://192.0.2.10"
|
|
122
238
|
ADGUARD_PRIMARY_USERNAME = "admin"
|
|
123
239
|
ADGUARD_PRIMARY_PASSWORD = "your-password"
|
|
124
240
|
```
|
|
@@ -129,6 +245,25 @@ ADGUARD_PRIMARY_PASSWORD = "your-password"
|
|
|
129
245
|
- Tier 2 writes require an explicit `confirm: true` arg; the JSON schema documents this on every write tool.
|
|
130
246
|
- Tier 3 destructive ops additionally require `destructive: true`. The model cannot disable protection or overwrite the rules block from a hallucinated tool call.
|
|
131
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
|
+
|
|
132
267
|
## License
|
|
133
268
|
|
|
134
|
-
MIT
|
|
269
|
+
MIT. See [LICENSE](LICENSE).
|