Skip to main content
Glama
Anshv784
by Anshv784

AgentGate

一个为 AI 智能体构建的受治理工具调用网关,基于 Terminal 3 的 ADK 构建。

给 LLM 智能体一个 API 密钥,它就能调用任何东西、花费任何东西、泄露任何东西——而你事后才从它自己写的日志里发现。

AgentGate 在智能体与外部世界之间放置了一个硬件隔离的飞地。智能体指定的是端点,而不是 URL。它从不持有凭证,也从不看到用户的个人数据。它所做的每一次尝试——无论允许还是拒绝——都会落入一个它无法编辑的账本中。

它以 MCP server 的形式发布,因此任何 MCP 客户端(Claude Code、Claude Desktop、Cursor、SDK 智能体)只需添加一条配置项即可获得受治理的工具调用。无需框架,无需重写。

  MCP client (Claude / Cursor / your agent)
    │  call_endpoint { endpoint: "resend", path: "/emails",
    │                  body: { to: ["{{profile.verified_contacts.email.value}}"] } }
    ▼
  AgentGate MCP server            ← holds the T3N session; the model holds nothing
    │
    ▼
┌─ z:<tid>:agentgate — TEE contract (Rust → WASM, Intel TDX) ───────────────┐
│  1. every {{…}} marker must be profile.* AND on this endpoint's allowlist │
│  2. path must be one the tenant enumerated — exact match, no globs        │
│  3. credential read from the sealed z:<tid>:secrets map                   │
│  4. host substitutes real PII inside the enclave (contract never sees it) │
│  5. upstream response projected to declared fields only                   │
│  6. ledger entry appended — for ALLOWED and DENIED alike                  │
└───────────────────────────────────────────────────────────────────────────┘
    ▼
  api.resend.com   ← reached only if the data owner's grant permits this host

它确实有效。这是凭证

在 T3N 测试网上运行 npm run demo——下面的每一次调用都由组织铸造的智能体发出:

🛑 DENIED   profile field outside the endpoint's allowlist  ({{profile.ssn}})
            marker rejected: 'ssn' is not in this endpoint's allowed_placeholders
🛑 DENIED   marker reaching for another namespace  ({{secret.resend_api_key}})
            marker rejected: 'secret.resend_api_key' is not a profile marker
🛑 DENIED   path the tenant never enumerated  (/domains)
            path rejected: '/domains' is not in this endpoint's allowed_paths
🛑 DENIED   endpoint that does not exist  (stripe)
            unknown endpoint

── policy is per-ENDPOINT, not per-host ──────────────────────────────
   'resend' and 'resend-notify' share a host AND a credential.
   The same marker is allowed on one and refused on the other.

✅ ALLOWED  {{profile.first_name}} via 'resend'        (allowlisted there)
            {"data":{"id":"d7299ce6-668f-47f2-8e22-8f3f96c0f255"},"status":200}
🛑 DENIED   {{profile.first_name}} via 'resend-notify' (allowlist is empty)
            marker rejected: 'first_name' is not in this endpoint's allowed_placeholders
✅ ALLOWED  no markers via 'resend-notify'             (allowed, returns nothing)
            {"data":{},"status":200}

真实邮件已送达。收件人的地址和姓名是在飞地内从数据所有者的资料中解析出来的——它们不会出现在智能体的输入、MCP 传输、合约内存或账本中的任何地方。

最后一行是默认拒绝的响应投影:resend-notify 未声明任何 response_fields,因此成功调用只返回状态码和一个空对象。连上游的消息 ID 也被扣留了。

之后的账本:

denied     0  resend/emails         markers=["profile.ssn", …]        'ssn' not allowed here
denied     0  resend/emails         markers=["secret.resend_api_key"] not a profile marker
denied     0  resend/domains        markers=[]                        path not enumerated
denied     0  stripe/emails         markers=[]                        unknown endpoint
ok       200  resend/emails         markers=["first_name","last_name","verified_contacts.email.value"]
denied     0  resend-notify/emails  markers=["profile.first_name", …] 'first_name' not allowed here
ok       200  resend-notify/emails  markers=[]

标记名称会被记录。标记值从未可供记录。

Related MCP server: MCP Warden

快速开始

npm install
cp .env.example .env          # add your T3N_API_KEY from terminal3.io/claim-page
npm run test                  # 9 native policy tests, no network, no credits
npm run build                 # Rust → wasm32-wasip2
npm run deploy                # idempotent — safe to re-run
npm run doctor                # pre-flight a deployment you didn't just create
npm run demo                  # the run shown above

添加到任何 MCP 客户端:

{ "mcpServers": {
    "agentgate": { "command": "npx", "args": ["tsx", "/path/to/agentgate/mcp/server.ts"] } } }

添加端点

一个文件。无需 Rust,无需重新部署合约。

// agentgate.config.json
"endpoints": {
  "stripe": {
    "base": "https://api.stripe.com",
    "secret_key": "stripe_api_key",        // key in z:<tid>:secrets
    "auth_header": "Authorization",
    "auth_prefix": "Bearer ",
    "allowed_paths": ["/v1/customers"],    // exact match only
    "allowed_placeholders": ["first_name", "verified_contacts.email.value"],
    "response_fields": ["id"]              // everything else is dropped
  }
}

然后运行 npm run deploy。当 wasm 未变化时,它会跳过合约注册,因此添加一个端点只需约 160 积分,而不是约 1,850 积分。

为什么设计成这个样子

三个决策来自对平台的实测,而非纸上谈兵:

  • 拒绝返回 Ok,绝不返回 Err。 合约写入在出错时会回滚,因此在策略拒绝时返回 Err 会回滚记录该拒绝的审计条目——智能体可以反复触发策略而不留任何痕迹。

  • 响应是投影的,而非透传的。 http-with-placeholders 只保护出站方向。上游响应会完整返回 WASM,因此一个回显请求的端点会把标记扣留的 PII 交还回去。已在 docs/BUGS.md 中演示。

  • 合约不设置 Content-Type。 宿主会追加自己的而不是替换你的,产生 application/json,application/json,严格的上游会拒绝——静默地,返回 HTTP 200 和空响应体。参见 docs/BUGS.md#1。

仓库结构

Path

What

contract/

TEE 合约——policy.rs 是纯逻辑且经过原生测试,gateway.rs 与宿主通信

mcp/server.ts

MCP 服务器——3 个工具

scripts/deploy.ts

幂等部署;持有 contract_id 账本

scripts/doctor.ts

预检健康检查

scripts/demo.ts

上面展示的运行

agentgate.config.json

声明式地定义每个端点和授权(2 个端点,对比策略)

deployments.json

已提交的账本,记录所有签发过的 contract_id

docs/BUGS.md

针对平台的 13 项发现

docs/ARCHITECTURE.md

为什么飞地边界设在这里

docs/HANDOVER.md

给下一位运维者的运行手册

contract-probe/

用于绘制占位符表面的临时诊断工具——未随产品发布

状态

使用 @terminal3/t3n-sdk@5.2.0 在 T3N 测试网上完成端到端构建与验证,运行了完整的三方身份流程:

Principal

Holds

Role in the run above

租户

eth 密钥,已注资

拥有合约,封存凭证,枚举策略

数据所有者

自己的 DID + 资料

授权智能体;标记根据其资料解析

智能体

一个不透明的 bearer token,仅此而已

发出上面展示的每一次调用

智能体的签名密钥在 TEE 内部铸造,从未离开过。它不持有 API 密钥、URL 或任何个人数据,也无法访问核心合约来查看自己的授权——但它却能将一封个性化邮件送达真实收件箱。

要做到这一点,需要 Terminal 3 手动为智能体 DID 注资:铸造出的智能体从零开始,一次调用会预留 10,000 个代币,且没有自助充值功能(docs/BUGS.md#10)。每个开发者在创建第一个智能体时都会遇到这个问题。

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    Enables AI agents to make authenticated API calls and run commands with secrets injected, while keeping credentials completely hidden from the model, with policy enforcement, grants, and audit logging.
    6
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to reach upstream MCP tool servers through a central policy gateway that authenticates each agent, enforces least-privilege and default-deny rules, and applies response obligations such as redaction, inference stripping, PII masking, and truncation. It also records every decision in a tamper-evident, hash-chained audit log that can be verified later.
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to securely reach enterprise tools and other agents through a governed gateway with pinned tool definitions, delegated authorization, content inspection, human approval, and signed audit trails.
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to call backend tools under per-agent policy, deciding which tools each agent can see, what arguments it may pass, how often it may call, and which writes wait for human approval. It also redacts secrets and PII from tool results, fences untrusted output against injection, and records every call in a hash-chained audit log.
    25 npm
    MIT