I built an MCP server that stops AI agents from running commands they shouldn't
说明与用途
MCP 服务器 agent-exec-guard 解析 AI 代理的命令,将其分类为安全、阻止或需要人工批准,从而防止恶意执行,同时允许合法命令运行。
问题
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.
结果
The MCP server prevents malicious commands from executing while allowing legitimate commands to run without interruption, enhancing security for AI agents.
工作流
- 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.
证据
Instead of string matching, it fully parses the command into a real AST and classifies it: SAFE, BLOCKED, UNCERTAIN
- 记录日期: 2026-09-08T04:14:37.415Z