Skip to content

Commit 6f53890

Browse files
committed
docs: add promotion articles (Chinese and English)
Story-driven articles for developer communities. Angle: agent got an account banned, built a proxy to prevent it. Targets: 掘金/知乎/V2EX (CN), dev.to/HN (EN).
1 parent 3ee397e commit 6f53890

2 files changed

Lines changed: 191 additions & 0 deletions

File tree

docs/promo-cn.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# 我的 AI Agent 把账号搞封了,然后我写了个 MCP 代理
2+
3+
上个月,我用 AI Agent 跑社交媒体自动化。Agent 接了个 MCP 工具服务器,能发帖、查数据、删内容。
4+
5+
我在 prompt 里写了:"每天最多发 1 条,发布前先确认"。
6+
7+
结果呢?LLM 某次推理链里把"先确认"理解成"我已经确认过了",30 分钟内连发了 8 条。平台直接把账号封了。
8+
9+
这不是个例。跑 Agent 的人或多或少都遇到过:
10+
- prompt 说"不要超过 3 次",Agent 第 4 次还是调了
11+
- 说好的"只读",结果 Agent 拼了个 publish 的参数就发出去了
12+
- 审批流程?Agent 根本不知道审批是什么,它只知道调工具
13+
14+
**Prompt 是建议,不是约束。LLM 不是规则引擎。**
15+
16+
## 问题在哪
17+
18+
MCP 协议本身没有治理层。Agent 拿到 `tools/list`,看到 5 个工具,它就认为 5 个都能用。没有谁在协议层面告诉它:"这个工具你不能用"、"这个工具每天只能调一次"、"这个工具调之前要人批准"。
19+
20+
所有的限制都靠 prompt。Prompt 是文本,LLM 是概率模型。概率模型 + 文本约束 = 偶尔会翻车。
21+
22+
偶尔翻车在聊天场景无所谓。但在操作真实账号的场景 —— 社交媒体、电商、客服 —— 一次翻车就够痛。
23+
24+
## 我的解法:在 MCP 协议层加一个代理
25+
26+
我写了 [Aegis MCP](https://github.com/bigmoon-dev/Aegis),一个 MCP 协议层的治理代理。
27+
28+
原理很简单:Agent 不直接连 MCP 工具服务器,而是连 Aegis。Aegis 拦截所有请求,过完一套管道再决定放不放行:
29+
30+
```
31+
Agent → Aegis (:18070) → MCP 工具服务器
32+
```
33+
34+
管道里有什么:
35+
36+
1. **ACL** —— 按 Agent 粒度控制哪些工具可用。被禁的工具直接从 `tools/list` 里移除,Agent 连看都看不到
37+
2. **限流** —— 滑动窗口,单 Agent 限流 + 跨 Agent 全局限流。共享同一个账号的多个 Agent,全局频率一起算
38+
3. **人工审批** —— 发布、删除这类操作,请求打到 Aegis 后会挂起,通过 Webhook 通知你审批(飞书、Slack、任何 HTTP endpoint)。你不点批准,请求永远不会到后端
39+
4. **FIFO 队列** —— 按后端串行执行,操作间随机延迟,模拟人类操作节奏
40+
5. **审计日志** —— 每次调用全记录到 SQLite,谁调的、什么工具、什么参数、什么结果、耗时多少
41+
42+
关键点:**这些都是硬约束**。不管 LLM 怎么推理、Agent 怎么重试,超出限流就是 `-32002`,没审批就是挂起。Agent 绕不过去。
43+
44+
## 怎么用
45+
46+
最快体验:
47+
48+
```bash
49+
npx aegis-mcp-proxy demo
50+
```
51+
52+
这会启动一个 mock 工具服务器 + Aegis 代理,终端打印 curl 命令让你逐步试:
53+
- `echo` 直接通过
54+
- `get_weather` 调 4 次,第 4 次被限流
55+
- `publish_post` 挂起等审批
56+
- `admin_reset` 在 tools/list 里直接不可见
57+
58+
接入自己的 MCP 服务器也很简单:
59+
60+
```bash
61+
npx aegis-mcp-proxy setup
62+
```
63+
64+
向导会:
65+
1. 连你的 MCP 服务器,发现所有工具
66+
2. 根据工具名自动推荐策略(只读不限、发布加审批、危险禁用)
67+
3. 自动检测你的 Agent(Claude Code / OpenClaw),把代理地址注入配置文件
68+
4. 生成 `aegis.yaml` 配置文件
69+
70+
改配置不用重启:
71+
72+
```bash
73+
curl -X POST localhost:18070/api/v1/config/reload
74+
```
75+
76+
## 一些设计选择
77+
78+
**为什么是代理不是 SDK?**
79+
80+
SDK 方案要改每个 Agent 的代码。换 Agent 框架就得重新集成。代理是协议层的,Agent 只是改了个 URL,零代码改动。Claude Code、OpenClaw、自定义 Agent 都能用。
81+
82+
**为什么用 SQLite 不用 Redis?**
83+
84+
一个二进制跑起来就行,不想引入外部依赖。审计日志本来就要持久化,SQLite 刚好。整个项目只有 3 个依赖(SQLite、YAML、UUID),能跑在树莓派上。
85+
86+
**为什么把约束注入工具描述?**
87+
88+
Agent 调 `tools/list` 的时候,Aegis 会把约束信息加到工具描述里:`[Rate:1/1d|ApprovalRequired] 发布笔记`。这样 LLM 在决策时就知道这个工具有限制,能减少无谓的重试。
89+
90+
## 现状
91+
92+
- Go 编写,单二进制
93+
- 90%+ 测试覆盖率,185 个测试
94+
- 支持 npm / Docker / go install / GitHub Release 二进制
95+
- Apache 2.0 开源
96+
97+
代码在 [github.com/bigmoon-dev/Aegis](https://github.com/bigmoon-dev/Aegis)
98+
99+
如果你也在跑 AI Agent 操作真实账号,欢迎试试,也欢迎提 issue 告诉我哪里不好用。

docs/promo-en.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# My AI Agent Got an Account Banned. So I Built an MCP Proxy.
2+
3+
Last month I was running an AI agent for social media automation. The agent talked to an MCP tool server — it could publish posts, query analytics, delete content.
4+
5+
I put "max 1 post per day, ask me before publishing" in the system prompt.
6+
7+
The LLM decided that "ask me" meant "I've already considered this" in one of its reasoning chains. Eight posts in 30 minutes. Account banned.
8+
9+
If you've run agents on real accounts, you've probably hit some version of this:
10+
- Prompt says "max 3 calls" — agent makes a 4th
11+
- Prompt says "read-only" — agent constructs a write call anyway
12+
- Prompt says "get approval" — agent doesn't know what approval means, it just calls tools
13+
14+
**Prompts are suggestions. LLMs are not rule engines.**
15+
16+
## The gap
17+
18+
MCP has no governance layer. An agent gets `tools/list`, sees 5 tools, and assumes all 5 are fair game. Nothing at the protocol level says "you can't use this tool" or "this tool needs human sign-off" or "you've used this tool too many times today."
19+
20+
All constraints live in the prompt. Prompts are text. LLMs are probabilistic. Probabilistic model + text constraints = occasional failure.
21+
22+
Occasional failure is fine for chatbots. It's not fine when your agent is operating a real social media account, e-commerce store, or customer service system. One burst of unchecked actions can trigger a platform ban.
23+
24+
## The fix: a governance proxy at the MCP protocol level
25+
26+
I built [Aegis MCP](https://github.com/bigmoon-dev/Aegis) — a proxy that sits between your agent and your MCP tool server.
27+
28+
The idea is simple. Instead of connecting directly to the backend, the agent connects to Aegis. Aegis intercepts every request and runs it through a policy pipeline before deciding whether to forward it:
29+
30+
```
31+
Agent → Aegis (:18070) → MCP Tool Server
32+
```
33+
34+
The pipeline:
35+
36+
1. **ACL** — Controls which tools each agent can see. Denied tools are removed from `tools/list` responses. The agent doesn't even know they exist.
37+
2. **Rate limiting** — Sliding window. Per-agent limits AND cross-agent global limits. Multiple agents sharing one account? Global limits prevent cumulative overuse.
38+
3. **Human approval** — Destructive operations (publish, delete) are held until a human approves via webhook notification (Feishu/Lark, Slack, any HTTP endpoint). No approval = request stays pending forever.
39+
4. **FIFO queue** — Serialized per-backend execution with randomized delays between operations. Mimics human timing patterns.
40+
5. **Audit log** — Every call recorded to SQLite: agent, tool, arguments, verdict, duration, result.
41+
42+
The key point: **these are hard constraints**. No matter what the LLM decides or how many times the agent retries — exceed the rate limit and you get `-32002`. No approval means the request hangs. The agent can't bypass it.
43+
44+
## Try it
45+
46+
Fastest way to see it work:
47+
48+
```bash
49+
npx aegis-mcp-proxy demo
50+
```
51+
52+
This spins up a mock tool server + Aegis with pre-configured policies. Terminal prints curl commands to try:
53+
- `echo` passes through, no restrictions
54+
- `get_weather` × 4 — 4th call gets rate-limited
55+
- `publish_post` — blocks until you approve via API
56+
- `admin_reset` — invisible in tools/list (ACL denied)
57+
58+
To protect your own MCP server:
59+
60+
```bash
61+
npx aegis-mcp-proxy setup
62+
```
63+
64+
The wizard connects to your server, discovers tools, suggests policies based on tool names (read-only = unlimited, publish = rate limit + approval, dangerous = deny), and injects the proxy URL into your agent's config (auto-detects Claude Code and OpenClaw).
65+
66+
Config changes don't need a restart:
67+
68+
```bash
69+
curl -X POST localhost:18070/api/v1/config/reload
70+
```
71+
72+
## Why a proxy, not an SDK?
73+
74+
SDK approaches require code changes in every agent. Switch frameworks and you re-integrate. A protocol-level proxy means the agent just changes one URL — zero code changes. Works with Claude Code, OpenClaw, or any MCP-compatible agent.
75+
76+
## Why SQLite, not Redis?
77+
78+
I wanted a single binary with no external dependencies. Audit logs need persistence anyway. The whole project has 3 dependencies (SQLite, YAML, UUID). It runs on a Raspberry Pi.
79+
80+
## Why inject constraints into tool descriptions?
81+
82+
When the agent calls `tools/list`, Aegis adds constraint info to each tool's description: `[Rate:1/1d|ApprovalRequired] Publish post`. The LLM sees limits before deciding to call the tool, which reduces pointless retries.
83+
84+
## Current state
85+
86+
- Written in Go, single binary, 90%+ test coverage (185 tests)
87+
- Available via npm / Docker / go install / GitHub Releases
88+
- Apache 2.0
89+
90+
Code: [github.com/bigmoon-dev/Aegis](https://github.com/bigmoon-dev/Aegis)
91+
92+
If you're running AI agents on real accounts, give it a try. Issues and feedback welcome.

0 commit comments

Comments
 (0)