safe-autonomy
Provides MCP tools for AI agents to classify changes into autonomous or human review lanes, and to run shadow simulations over backlogs without shipping anything.
README
safe-autonomy
A fence and a shadow for autonomous coding agents. Decide what an AI is allowed to ship without a human, watch it reason before you trust it, and keep the dangerous stuff in your hands.
The hard problem in AI operations isn't making the agent smarter. It's being disciplined about what it is never allowed to touch. safe-autonomy is that discipline as ~150 lines of pure, dependency-free, unit-tested code you can drop into any agent pipeline.
The idea
Autonomy is only safe where "the AI was wrong" cannot hurt anyone. Additive observability is worst-case noise. A revert goes to a known-good state. The changes that matter most — money, product, user-facing truth, the database — are exactly the ones that stay human. Not from fear, from fallibility: agents make real mistakes, and the value of a human in the loop is catching them.
So this library does two small things:
- The fence (
classifyChange) — one pure function that routes a proposed change toautoorhuman. Default ishuman.autoonly when the change touches no sensitive path, is reversible, and is an additive/reversible kind (a monitor, a test, a revert). One sensitive file drags the whole change tohuman. - Shadow mode (
shadowClassify) — run the fence over your real backlog and log exactly how each change would be routed, shipping nothing. You read the shadow log for as long as you want before enabling any autonomy.
Use it
import { classifyChange } from "safe-autonomy/gate";
classifyChange({ files: ["src/lib/metrics.ts"], kind: "add_monitor", reversible: true });
// → { lane: "auto", reasons: ["additive/reversible \"add_monitor\", no sensitive paths"] }
classifyChange({ files: ["src/api/stripe/webhook.ts"], kind: "add_monitor", reversible: true });
// → { lane: "human", reasons: ["touches human-only path(s): src/api/stripe/webhook.ts"] }
Bring your own denylist and allowlist; the defaults cover money, auth, schema, sending, deletion, webhooks, and secrets:
import { classifyChange, DEFAULT_CONFIG } from "safe-autonomy/gate";
const config = {
...DEFAULT_CONFIG,
humanOnlyPaths: [...DEFAULT_CONFIG.humanOnlyPaths, /\/pricing\//],
};
classifyChange(change, config);
Shadow a whole backlog before you enable anything:
import { shadowClassify, formatShadowLog } from "safe-autonomy/shadow";
const report = shadowClassify(proposals, deriveChange); // deriveChange: your proposal → a ChangeDescriptor
console.log(formatShadowLog(report, (p) => p.title));
// Autonomous shadow — 3 proposal(s): 1 would auto-ship (SHADOW ONLY, nothing shipped), 2 stay human.
// [AUTO ] watch publish_verify_missing_field — AUTO once enabled → branch, full CI, verify, auto-rollback...
// [HUMAN] Scanner → connect gate — HUMAN review → no files listed — cannot verify blast radius...
The rollout it's built for
proposal → classifyChange → [human] land as a PR for review
→ [auto] implement on a branch
→ FULL CI (tsc + lint + tests + build); red = stop
→ SHADOW: log the diff + intended action, ship nothing
→ (only when enabled) auto-merge + deploy
→ verify on REAL metrics + error rate for a watch window
→ auto-rollback on regression
→ immutable audit log of every step
Ship the fence first (inert). Run it in shadow for as long as you like. Enable it narrowly — one surface, add_monitor / add_test only — with a kill switch, a veto window, and auto-rollback. Widen it an inch at a time, and never widen the allowlist or shrink the denylist without an explicit human decision.
Use it from any agent (MCP)
The same fence is an MCP server, so an agent can ask it before it acts. Two tools:
classify_change (route one change) and shadow_run (route a whole backlog, ship nothing).
npm run mcp # stdio server: npx tsx mcp/server.ts
Point an MCP client at it:
{
"mcpServers": {
"safe-autonomy": { "command": "npx", "args": ["tsx", "/path/to/safe-autonomy/mcp/server.ts"] }
}
}
Then the agent calls, in its own words, "classify this change" and gets back a lane:
// classify_change { "files": ["src/api/stripe/charge.ts"], "kind": "add_monitor", "reversible": true }
// → HUMAN — touches human-only path(s): src/api/stripe/charge.ts
Bring your own denylist/allowlist over the wire (regex source strings, so JSON-safe):
// classify_change { ..., "config": { "humanOnlyPaths": ["/pricing/"], "autoKinds": ["add_test"] } }
Why it's tight (the honest reason)
Verify on real metrics, not just green tests — subtly-wrong changes pass tests. This whole library exists because the AI is fallible, and the point of a boundary is that "the AI was wrong" stays cheap.
Extracted from the autonomous-maintenance system running a production SaaS. Tests: npx vitest run.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。