crab-hole-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@crab-hole-mcp Is example.com blocked on my Crab-hole right now?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Crab-hole MCP
An MCP server for inspecting and administering a Crab-hole DNS filter over SSH — so an AI assistant (Claude, or any MCP-compatible client) can check status, query blocklists, manage allow/block rules, and safely roll out config changes on your self-hosted instance.
It talks to a single root-owned helper script on the Crab-hole host over non-interactive SSH. It never reads or forwards SSH keys, and it never gives the model an arbitrary shell — only the fixed set of operations described below.
Tools
Read-only tools are enabled by default:
get_crab_hole_config— read the complete active TOML plus its SHA-256 revisionvalidate_crab_hole— run Crab-hole's native config and blocklist validatorsvalidate_proposed_config— validate proposed TOML without installing itlist_config_backups— list configuration and custom-rule safety backupscrab_hole_status— service state, version, block count, rule counts, refresh time, and memorycheck_domain— resolve a domain through the live filter and report whether it is blockedlist_custom_rules— list custom allow or block entrieslist_blocklists— list configured remote and local sourcesrecent_logs— read recent service logs, optionally errors only
Set CRAB_HOLE_MUTATIONS_ENABLED=true to additionally expose:
replace_crab_hole_config— atomically replace the entire validated TOML configurationrestore_crab_hole_config— restore a validated configuration backupcontrol_crab_hole_service— start, stop, or restart Crab-holeadd_custom_rule— requiresADD ALLOW domainorADD BLOCK domainremove_custom_rule— requiresREMOVE ALLOW domainorREMOVE BLOCK domainrestart_crab_hole— backward-compatible restart shortcut
Because replace_crab_hole_config replaces the complete TOML, it can add, remove, or
modify blocklist and allow-list sources, blocking mode, subdomain behavior, downstream
listeners, upstream resolvers, TLS settings, timeouts, and any other option supported by
the installed binary. The safe workflow is:
Read
get_crab_hole_configand retain itssha256.Edit the returned TOML.
Call
validate_proposed_config.Call
replace_crab_hole_configwith the original hash and exact confirmationREPLACE CRAB-HOLE CONFIG <sha256>.
The expected hash rejects stale edits. Configuration and rule writes are serialized,
backed up under /var/backups/crab-hole-mcp/ on the remote host, and installed
atomically. With applyNow=false, changes wait for a later restart. With
applyNow=true, the MCP restarts Crab-hole, verifies its localhost DNS listener, and
automatically restores the backup if readiness fails. Restores make an additional
safety backup first.
Service confirmations are exact: START CRAB-HOLE, STOP CRAB-HOLE, or
RESTART CRAB-HOLE. Stopping or restarting can interrupt filtered DNS briefly.
Related MCP server: ssh-mcp-server
Requirements
A Crab-hole instance running on a Linux host you can SSH into.
jqandpython3(withtomllib, stdlib on 3.11+) installed on that host.A non-interactive SSH key set up from wherever this MCP server runs to that host, authorized for a user with passwordless
sudoaccess to the helper script (see below) — not to anything else.Bun to build/run this project locally.
Install
See SETUP.md for a full walkthrough. Quick version:
git clone https://github.com/papacasper/crab-hole-mcp.git
cd crab-hole-mcp
bun install
bun run typecheck
bun test
bun run buildRemote helper
Copy remote/crab-hole-admin to the Crab-hole host, root-owned and not writable by
anyone else:
sudo install -o root -g root -m 0750 remote/crab-hole-admin /usr/local/sbin/crab-hole-adminIt only accepts a fixed set of subcommands (status, get-config,
validate-proposed, replace-config, add-rule, ...) — it is not an arbitrary shell
interface. Grant your SSH user passwordless sudo scoped to exactly this binary, e.g. in
/etc/sudoers.d/crab-hole-mcp:
your_ssh_user ALL=(root) NOPASSWD: /usr/local/sbin/crab-hole-adminThe helper assumes Crab-hole's config lives at /etc/crab-hole/config.toml, custom
rules at /etc/crab-hole/allowed-custom.txt / blocked-custom.txt, the systemd unit is
crab-hole.service, and the binary is /usr/local/bin/crab-hole listening on localhost
UDP 5354 — adjust the constants at the top of remote/crab-hole-admin if your install
differs.
Configuration
Copy .env.example to .env and set at minimum CRAB_HOLE_SSH_HOST:
cp .env.example .envNo SSH keys, DNS credentials, or server secrets are stored in this project — SSH
authentication is handled by your normal ssh/agent setup on the machine running the
MCP server.
Connect
Use mcp-config.example.json as a starting point for any client that accepts the
common mcpServers format:
{
"mcpServers": {
"crab-hole": {
"command": "crab-hole-mcp",
"env": {
"CRAB_HOLE_SSH_HOST": "your-server-ip-or-hostname"
}
}
}
}If you installed via bun run build in a cloned checkout instead of a package
manager, point command at the generated bin/crab-hole-mcp script instead. Rebuild
after source changes and restart the MCP client after configuration changes.
Safety boundaries
This MCP fully administers Crab-hole itself, but deliberately does not provide
arbitrary server-file or shell access. Anything outside Crab-hole itself — DNS
forwarders/edges like dnsdist, firewalls, OS packages, certificates, and unrelated
services — is out of scope for its mutation tools. Certificate and private-key paths
may be configured in Crab-hole's TOML, but private-key contents are never returned.
License
MIT. Crab-hole itself is AGPL-3.0-licensed; this project only talks to it over SSH/CLI and does not link against or embed its code.
Available Tools
9 toolscheck_domainCheck DomainARead-onlyIdempotent
Resolve a domain through the live Crab-hole backend and report whether it is blocked.
Inputs: domain (required).
crab_hole_statusCrab-hole StatusARead-onlyIdempotent
Inspect service health, version, current block count, rule counts, memory, and the latest blocklist refresh.
Inputs: no named parameters.
get_crab_hole_configGet Crab-hole ConfigurationARead-onlyIdempotent
Read the complete active Crab-hole TOML configuration and its SHA-256 revision.
Inputs: no named parameters.
list_blocklistsList BlocklistsARead-onlyIdempotent
List the live and local blocklist sources configured in Crab-hole.
Inputs: no named parameters.
list_config_backupsList Crab-hole BackupsARead-onlyIdempotent
List configuration and custom-rule backups created by this MCP.
Inputs: limit.
list_custom_rulesList Custom RulesARead-onlyIdempotent
List custom allow or block entries currently stored on the DNS server.
Inputs: kind (required), limit.
recent_logsRecent Crab-hole LogsARead-onlyIdempotent
Read recent Crab-hole service logs, optionally restricted to errors.
Inputs: lines, errorsOnly.
validate_crab_holeValidate Active Crab-hole StateARead-onlyIdempotent
Run Crab-hole's native configuration and list validators without changing anything.
Inputs: no named parameters.
validate_proposed_configValidate Proposed ConfigurationARead-onlyIdempotent
Validate complete proposed Crab-hole TOML without installing or activating it.
Inputs: toml (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct resource or action: config reading, validation, backups, status, domain lookup, custom rules, blocklists, and logs. The only overlapping pair is validate_crab_hole and validate_proposed_config, but the descriptions clearly separate native validators from proposed TOML validation.
Most tools use snake_case with verb prefixes like get_, validate_, list_, and check_, but crab_hole_status and recnt_logs are noun phrases without verbs. The mixed conventions are readable but not fully consistent.
Nine tools is a well-scoped size for a DNS configuration and observability server. Each tool serves a distinct purpose without creating reduntant bloat or leaving the surface feeling too thin.
The read, validate, and inspect capabilities are well covered, but there are no tools to apply config, restore backups, add or remove custom rules/blocklists, or toggle blocking. These are notable lifecycle gaps for a tool named as a Crap-hole management server.
Related MCP Connectors
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Manage Koru Shield DNS filtering: profiles, rules, categories, schedules, and logs.
Approval-gated Cloudflare ops for agents: DNS, email auth, Pages, cache, Turnstile, tokens.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Related MCP Servers
- AlicenseAqualityDmaintenanceConnects AI assistants to Pi-hole network-wide ad blocker, enabling monitoring of DNS traffic statistics, controlling blocking settings, managing whitelist/blacklist domains, viewing query logs, and performing maintenance tasks through natural language.1681 npm8MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to securely execute remote SSH commands, perform file transfers, and monitor system status through a standardized interface. It features robust security controls including command whitelisting, blacklisting, and credential isolation to prevent unauthorized operations.1023 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to securely execute commands, transfer files, and manage port forwarding on remote servers via SSH.114 npm38Apache 2.0
- AlicenseAqualityDmaintenanceEnables AI agents to execute SSH commands, read files, and list directories on remote hosts with a configurable command-safety policy.5MIT