I built an MCP server that stops AI agents from running commands they shouldn't
Description and use
The MCP server agent-exec-guard parses AI agent commands, classifying them as SAFE, BLOCKED, or UNCERTAIN, preventing malicious execution while allowing legitimate commands to run.
Problem
AI agents that execute shell commands often rely on simple allowlists that only check the first token, enabling malicious payloads to be hidden inside seemingly safe commands.
Outcome
The MCP server prevents malicious commands from executing while allowing legitimate commands to run without interruption, enhancing security for AI agents.
Workflow
- 1. Install agent-exec-guard via npm or run directly.
- 2. Configure the agent to use the MCP server as a proxy.
- 3. Agent sends command to MCP server.
- 4. MCP server parses command into AST.
- 5. MCP server classifies command: SAFE runs immediately; BLOCKED is rejected; UNCERTAIN is sent to a human for approval.
- 6. Human approves by generating a signed HMAC token tied to the command checksum.
- 7. Agent receives token and executes the command.
- 8. Log and audit all decisions.
Evidence
Instead of string matching, it fully parses the command into a real AST and classifies it: SAFE, BLOCKED, UNCERTAIN
- Record date: 2026-09-08T04:14:37.415Z