agent-security-gateway
Agent Security Gateway
MCP‑слой безопасности для AI‑агентов: каждый вызов tool проходит через allow / confirm / deny и пишется в audit.
Cursor / Claude
↓
Agent Security Gateway ← политики + очередь confirm
↓ + UI аппрувов (:8787)
sandbox tools + SQLite auditБыстрый старт
npm install
npm test
npm run demo # демо (UI + allow/deny/confirm)
# или
npm run dev # MCP по stdio + UI для CursorUI аппрувов и аудита: http://127.0.0.1:8787
MCP работает по stdio (логи только в stderr)
Подключение в Cursor
{
"mcpServers": {
"agent-security-gateway": {
"command": "npm",
"args": ["run", "dev", "-w", "@agent-security/gateway"],
"cwd": "/Users/daniildudarev/Downloads/agent-security-gateway"
}
}
}Сценарий confirm
Агент вызывает
write_file→safe/hello.txtОткрываешь UI → Approve
Агент смотрит результат через
get_pending/list_audit
Зачем это нужно
Агенту дают «руки» (tools): файлы, API, БД. Без ограничений он может удалить не то, уйти в цикл или сделать необратимое действие.
Этот gateway стоит между IDE‑агентом и tools:
Решение | Что происходит |
allow | действие выполняется сразу |
deny | блокируется, пишется в audit |
confirm | ждёт человека в UI, потом execute / reject |
По умолчанию — fail‑closed: неизвестный tool запрещён.
Docker
docker compose up --buildПеременные окружения
Переменная | По умолчанию | Назначение |
|
| Файл политик |
|
| Адрес bind ( |
|
| Порт UI |
| вычисляется | URL, который видит агент |
|
| Каталог SQLite |
Политики
Файл policies/default.yaml — первое совпадение побеждает, иначе deny.
Действие | Путь | Решение |
list/read | sandbox | allow |
write/delete |
| deny |
write/delete |
| confirm → UI |
неизвестный tool | — | deny |
Sandbox
sandbox/
safe/notes.txt # безопасный демо‑файл
prod/users.db # «прод» — мутации запрещеныВсе файловые tools работают только внутри sandbox/, выход через .. режется.
Tools
Tool | Назначение |
| статус, пути, URL UI |
| чтение sandbox |
| мутации (под политикой) |
| очередь confirm |
| история решений |
Демо
npm run demoПодробнее: docs/DEMO.md
Агентам нужны руки (tools). Руки без ограждения опасны. Этот MCP‑gateway стоит между IDE‑агентом и tools, решает allow/confirm/deny и для рискованных действий ждёт человека — с полным audit trail.
Agent Security Gateway (English)
MCP security layer for AI agents: every tool call goes through allow / confirm / deny + audit.
Cursor / Claude
↓
Agent Security Gateway ← policy + pending queue
↓ + approve UI (:8787)
sandbox tools + SQLite auditQuick start
npm install
npm test
npm run demo # demo (UI + allow/deny/confirm)
# or
npm run dev # MCP stdio + UI for CursorApprove / Audit UI: http://127.0.0.1:8787
MCP on stdio (logs on stderr)
Connect from Cursor
{
"mcpServers": {
"agent-security-gateway": {
"command": "npm",
"args": ["run", "dev", "-w", "@agent-security/gateway"],
"cwd": "/Users/daniildudarev/Downloads/agent-security-gateway"
}
}
}Confirm flow
Agent:
write_file→safe/hello.txtOpen UI → Approve
Agent:
get_pending/list_audit
Why it exists
Agents get hands (tools): files, APIs, databases. Without guardrails they can delete the wrong thing, loop on expensive calls, or take irreversible actions.
This gateway sits between the IDE agent and tools:
Decision | What happens |
allow | execute immediately |
deny | block + write audit |
confirm | wait for a human in the UI, then execute / reject |
Default is fail-closed: unknown tools are denied.
Docker
docker compose up --buildEnv
Variable | Default | Meaning |
|
| Policy file |
|
| Bind address ( |
|
| Approve UI port |
| derived | URL shown to agents |
|
| SQLite DB directory |
Policy model
policies/default.yaml — first match wins, default fail-closed deny.
Action | Path | Decision |
list/read | sandbox | allow |
write/delete |
| deny |
write/delete |
| confirm → human UI |
unknown tool | — | deny |
Sandbox
sandbox/
safe/notes.txt # harmless demo file
prod/users.db # fake "prod" — mutations deniedAll filesystem tools are rooted at sandbox/ and reject .. escapes.
Tools
Tool | Purpose |
| status, paths, UI URL |
| read sandbox |
| mutations (policy-gated) |
| confirm queue |
| decision history |
Demo
npm run demoDetails: docs/DEMO.md
Agents need hands (tools). Hands without a guardrail are dangerous. This MCP gateway sits between the IDE agent and tools, decides allow/confirm/deny, and for risky actions waits for a human — with a full audit trail.