host-protection-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
host-protection-mcp
An MCP server for agents that run their tools inside a sandbox but still need to change a few files on the host, like their own config, or run a restart.
The agent can't touch those files from the sandbox. It asks this server instead, you approve the call in your MCP client, and the server does the write or runs the command on the host. Anything that isn't in your config file is refused.
I built this for Hermes Agent on my homelab, but nothing in the code is Hermes specific.
How it works
sequenceDiagram
participant A as Agent (sandbox)
participant C as MCP client
participant Y as You
participant S as host-protection-mcp (host)
A->>C: edit_file(config.yaml, edits, reason)
C->>Y: Approve?
Y->>C: Yes
C->>S: edit_file
S->>S: check allow list, validate, back up, write
S-->>A: done, run "restart" nextThe agent never sends a whole file. Each edit is an exact snippet and its replacement, like a small diff, so the approval prompt shows you only what changes. The snippet has to match exactly once.
Edits are refused when the path isn't in the allow list, when the result doesn't parse, or when a symlink is anywhere on the way. Every changed file gets a backup first.
Actions run without a shell, and every {placeholder} has to match the regex you declare for it.
Related MCP server: fs-mcp-server
Tools
Tool | Does |
| Lists the allowed files and actions |
| Reads an allowed file |
| Applies snippet edits to an allowed file, returns the actions to run after it |
| Runs a configured action |
Install
You need Node 22.18 or newer. It's written in TypeScript and Node runs the .ts files directly, so there's no build step.
git clone https://github.com/khaosdoctor/host-protection-mcp.git
cd host-protection-mcp
npm ci --omit=dev
mkdir -p ~/.config/host-protection-mcp
cp examples/hermes.yaml ~/.config/host-protection-mcp/config.yamlInstall it somewhere the agent can't write to. If the agent can edit this server or its config, the protection is gone.
Running
node src/server.ts [config-file]The server talks MCP over stdin and stdout, so you won't run it by hand. Your MCP client starts it with this command (see Connecting a client).
There are no flags. The only argument is the path to the config file, and you can leave it out. The server takes the first config it finds in this order.
The argument,
node src/server.ts /etc/my-agent/protection.yamlThe
HOST_PROTECTION_CONFIGenvironment variable~/.config/host-protection-mcp/config.yaml
If the config is missing or has no files in it, the server exits with an error.
To check that it starts, send it an MCP handshake and a tool listing.
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
| node src/server.tsConfiguration
The config is a YAML file with a list of files the agent can change and a list of actions it can run. Anything that isn't listed is refused.
files:
- path: ~/.hermes/config.yaml
validate: yaml
after: [restart]
- path: ~/.hermes/profiles/*/SOUL.md
actions:
restart:
description: Restart the gateway
command: [systemctl, --user, restart, hermes-gateway]
install_plugin:
description: Install a plugin from owner/repo
command: [hermes, plugins, install, "{source}"]
args:
source: '[\w.-]+/[\w.-]+'
timeoutSeconds: 300
backupDir: ~/.local/state/host-protection-mcp/backups
maxBytes: 1000000examples/hermes.yaml has a full Hermes setup.
files
Each entry allows one file, or a group of files with a glob. The agent can read these with read_file and change them with edit_file.
Key | Required | Default | What it does |
| yes | The file. | |
| no |
| Checks the file after the edit and refuses it if it doesn't parse. |
| no |
| Names of actions the agent is told to run after a successful edit, like a restart. The server doesn't run them, the agent asks for them with |
Paths are compared after .. is resolved, so ~/.hermes/profiles/../.env doesn't match ~/.hermes/profiles/*/SOUL.md.
actions
Each key under actions is a name the agent passes to run_action.
Key | Required | Default | What it does |
| yes | The program and its arguments as a list. It runs without a shell, so pipes, | |
| no | Shown to the agent in | |
| no |
| Placeholders the agent can fill. The key is the placeholder name used as |
| no |
| The command is killed after this long |
The agent gets the exit code and the last 8000 characters of output back.
Commands that restart the agent's own process will also kill this server before it can answer. For those, schedule the restart a few seconds later, like systemd-run --user --on-active=3 systemctl --user restart my-agent in the Hermes example.
Top-level keys
Key | Default | What it does |
|
| Where the old version of a file goes before every edit. The name is the full path with |
|
| Edits that would make a file bigger than this are refused |
To undo a change, copy the backup over the file.
ls ~/.local/state/host-protection-mcp/backups
cp ~/.local/state/host-protection-mcp/backups/_home_me_.hermes_config.yaml.1764430000000 ~/.hermes/config.yamlConnecting a client
The approval comes from your client, so set it to always ask for this server.
In Hermes, mark it as untrusted and you'll get Approve and Deny buttons for every call.
mcp_servers:
host_protection:
command: node
args: [/path/to/host-protection-mcp/src/server.ts]
trust: untrustedIn Claude Code, add it and leave its tools out of your allow list so every call prompts.
claude mcp add host-protection -- node /path/to/host-protection-mcp/src/server.tsRunning with Docker
The container only sees what you mount, so mount every file from your config. Inside the container ~ is /root.
docker build -t host-protection-mcp .
docker run -i --rm \
-v ~/.config/host-protection-mcp/config.yaml:/config/config.yaml:ro \
-v ~/.hermes/config.yaml:/root/.hermes/config.yaml \
host-protection-mcpActions run inside the container too, so host commands like systemctl --user won't work from there. If you need actions, run the server on the host.
Development
npm install
npm run typecheck
npm testLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Ask if an action is safe before your agent runs it: injection, shell, MCP installs. Free samples.
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Open-source MCP gateway with per-agent tool permissions, call approvals and tool-change review.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables MCP-compatible AI clients to securely access explicitly authorized local project files and run approved development commands with bounded execution and audit logging.1MIT
- AlicenseAqualityBmaintenanceEnables MCP clients to read, write, and edit files confined to directories you explicitly allow, including multi-file reads and diff-previewed text edits. An optional, unsandboxed shell tool can run commands when explicitly enabled.61,266 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible AI clients to interact with local filesystems, terminals, browsers, documents, processes, network, and system operations through controlled tools, with approval prompts for protected actions.MIT
- AlicenseNot gradedqualityCmaintenanceIt enables local MCP clients to perform file operations, directory searches, source editing, command and process handling, and file previews within privacy-hardened, development-scoped safeguards. Higher-risk filesystem writes, terminal/process tools, and URL reads require explicit operator opt-in.MIT