AgentGate

io.github.agentkitai由 GitHub 账号 agentkitai 发布v0.0.3更新于 Oct 25, 2026

Human-in-the-loop approval gateway for AI agents over MCP: request, decide, approve.

已验证STDIO仅桌面效率与工作流安全与监控

概览

AI 生成的概览

AgentGate 是一个人在环审批网关,让 AI 代理在执行操作前提交请求,经策略判定和人工审批后再执行。

可以做什么
提交、读取和列出审批请求,包括按 ID 查询状态以及按状态等条件筛选,并对待处理请求作出批准或拒绝并附上理由。创建、替换和删除审批策略,并按优先级列出策略。按条件分页读取审计日志,并列出审计记录中的不同操作者。请求可路由到仪表盘、Slack、Discord 或电子邮件,Webhook 会向外部系统通知请求事件。
适用场景
适用于代理可能执行发邮件、删文件或部署等有后果的操作时,希望由策略自动批准安全操作、自动拒绝危险操作,其余交由人工决定。也适合需要保留代理决策审计记录的团队。
运行要求
通过 npx 作为 MCP 服务器在本地运行,但需要一个可访问的 AgentGate 服务器(用 Docker 或从源码自托管,数据库为 SQLite 或 PostgreSQL)。MCP 客户端配置需提供 AGENTGATE_URL 和 AGENTGATE_API_KEY,API 密钥在初始化时生成且只显示一次。可选的 Slack、Discord 和 SMTP 凭据用于启用其他审批渠道。
安装前请注意
API 密钥(AGENTGATE_API_KEY,服务器端为 ADMIN_API_KEY)是授予分级权限的机密,其中 admin 范围可管理策略和密钥,不要放入共享配置。这些 MCP 工具可以批准或拒绝请求,也可以创建、替换或删除策略,因此拥有这些工具的代理能改变审批行为。审计日志和请求参数可能包含敏感操作数据,Webhook 会把请求详情发送到外部地址。

安装

在 SourceWeft 中

  1. 打开 控制台中的 AgentGate,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

AgentGate

Human-in-the-loop approval system for AI agents.
Agents request. Policies decide. Humans approve.
Keep humans in control of what AI agents can do.

[npm version] [MIT License] [CI] [TypeScript]


[AgentGate Demo]

Your AI agent wants to send an email, delete a file, or deploy to production. Should it? AgentGate lets you define policies that auto-approve safe actions, auto-deny dangerous ones, and route everything else to a human — via dashboard, Slack, Discord, or email.

✨ Highlights

  • 🛡️ Policy engine — auto-approve, auto-deny, or route to humans based on rules
  • 👥 Multi-channel approvals — Slack, Discord, email, or web dashboard
  • 🔌 TypeScript SDK + MCP — works with any agent framework or Claude Desktop
  • 🪝 Webhooks with retry — real-time notifications with exponential backoff
  • 📝 Full audit trail — every request, decision, and action logged, each policy decision tagged with the OWASP LLM Top-10 risk it mitigates (compliance evidence)
  • 🐳 Docker-ready — one docker-compose up for the full stack
  • 🔐 Production-hardened — SSRF protection, ReDoS defense, structured logging, graceful shutdown
  • 🔗 One-click decision links — approve or deny directly from notification emails and webhooks
  • ♿ Accessible UI — keyboard-navigable approval modals, focus trapping, ARIA labels
  • 💀 Skeleton loading — smooth loading states across every dashboard page
  • ⚡ Fast & lightweight — Hono server, SQLite or PostgreSQL

Quickstart

bash
# Self-host the full stack (server + dashboard + Postgres):docker compose up
# …or from source:pnpm install && pnpm --filter @agentkitai/agentgate-server db:migrate && pnpm --filter @agentkitai/agentgate-server bootstrap && pnpm dev

Drop AgentGate into an MCP client (Claude Desktop / Cursor / VS Code) — point it at the gateway:

jsonc
{ "mcpServers": { "agentgate": { "command": "npx", "args": ["@agentkitai/agentgate-mcp"] } } }
Dashboard

See all pending requests at a glance, color-coded by urgency so you know what needs attention first.

[Dashboard]

Approval Requests

Review, approve, or deny requests — filter by status to focus on what matters.

[Requests]

Audit Log

Search through every decision with filters for event type, action, actor, and date range.

[Audit Log]

Request Detail

Drill into any request to see parameters, context, timeline, and audit trail — with one-click Approve/Deny buttons.

[Request Detail]

API Keys

Manage API keys with fine-grained scopes, rate limits, and usage tracking. Create, edit, or revoke keys from the dashboard.

[API Keys]

Webhooks

Configure webhook endpoints for real-time notifications. Add URLs, pick events, and let AgentGate handle retries automatically.

[Webhooks]

Login

Sign in with your API key — create one via the CLI or ask your admin.

[Login]


Table of Contents


Quick Start

1. Install dependencies

bash
pnpm install

2. Run database migrations

bash
pnpm --filter @agentkitai/agentgate-server db:migrate

3. Bootstrap (create admin API key)

bash
pnpm --filter @agentkitai/agentgate-server bootstrap

Save the API key - it's shown once only! Set it in your environment:

bash
export AGENTGATE_API_KEY="agk_..."

4. Start the development environment

bash
# Start server (port 3000) and dashboard (port 5173)pnpm dev

5. Run the demo

In a new terminal (with API key set):

bash
export AGENTGATE_API_KEY="agk_..."pnpm demo

6. Open the dashboard

Visit http://localhost:5173 to view and manage approval requests.

Architecture

┌─────────────────────────────────────────────────────────────────┐│                         AI Agents                                ││  (use @agentkitai/agentgate-sdk or MCP to request approvals)               │└───────────────────────────┬─────────────────────────────────────┘                            │ HTTP API (authenticated)                            ▼┌─────────────────────────────────────────────────────────────────┐│                    AgentGate Server                              ││  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐          ││  │ Policy Engine│  │ Request Store│  │ Audit Logger │          ││  ├──────────────┤  ├──────────────┤  ├──────────────┤          ││  │  API Keys    │  │  Webhooks    │  │  MCP Server  │          ││  └──────────────┘  └──────────────┘  └──────────────┘          │└───────────────────────────┬─────────────────────────────────────┘                            │              ┌─────────────┼─────────────┐              ▼             ▼             ▼┌────────────────┐ ┌────────────────┐ ┌────────────────┐│  Web Dashboard │ │   Slack Bot    │ │  Discord Bot   ││(React+Tailwind)│ │(approve in DM) │ │(approve in ch) │└────────────────┘ └────────────────┘ └────────────────┘              │             │             │              └─────────────┼─────────────┘                            ▼                      ┌──────────┐                      │  Humans  │                      └──────────┘

Packages

PackageDescriptionDocs
@agentkitai/agentgate-coreTypes, schemas, policy engine-
@agentkitai/agentgate-serverHono API server-
@agentkitai/agentgate-sdkTypeScript SDK for agentsREADME
@agentkitai/agentgate-cliCommand-line interface-
@agentkitai/agentgate-mcpMCP server for Claude Desktop-
@agentkitai/agentgate-slackSlack bot integrationREADME
@agentkitai/agentgate-discordDiscord bot integrationREADME
@agentkitai/agentgate-dashboardReact web dashboard-

SDK Usage

typescript
import { AgentGateClient } from '@agentkitai/agentgate-sdk';
// Create client with API keyconst client = new AgentGateClient({  baseUrl: 'http://localhost:3000',  apiKey: process.env.AGENTGATE_API_KEY,});
// Request approvalconst request = await client.request({  action: 'send_email',  params: {    to: '[email protected]',    subject: 'Order shipped!',  },  urgency: 'normal',});
// Wait for human decisionconst decided = await client.waitForDecision(request.id, {  timeout: 60000, // 1 minute});
if (decided.status === 'approved') {  // Execute the action  await sendEmail(decided.params);} else {  console.log('Action denied:', decided.decisionReason);}

CLI

AgentGate includes a command-line interface for managing approval requests.

Installation

bash
# From the monorepopnpm --filter @agentkitai/agentgate-cli build
# Or install globally (when published)npm install -g @agentkitai/agentgate-cli

Configuration

Configure the CLI with your server URL and API key:

bash
# Set server URLagentgate config set serverUrl http://localhost:3000
# Set API keyagentgate config set apiKey agk_your_api_key
# View current configagentgate config show

Configuration is stored in ~/.agentgate/config.json. You can also use environment variables:

bash
export AGENTGATE_URL=http://localhost:3000export AGENTGATE_API_KEY=agk_...

Commands

CommandDescription
agentgate config showShow current configuration
agentgate config set <key> <value>Set a configuration value
agentgate request <action>Create a new approval request
agentgate status <id>Get status of a request
agentgate listList approval requests
agentgate approve <id>Approve a pending request
agentgate deny <id>Deny a pending request

Examples

bash
# Create a requestagentgate request send_email \  --params '{"to": "[email protected]", "subject": "Hello"}' \  --urgency high
# List pending requestsagentgate list --status pending
# Approve a requestagentgate approve req_abc123 --reason "Looks good"
# Deny a requestagentgate deny req_abc123 --reason "Not authorized"
# Output as JSONagentgate list --json

MCP Integration

AgentGate includes a Model Context Protocol (MCP) server for integration with Claude Desktop and other MCP-compatible clients.

Claude Desktop Configuration

Add to your claude_desktop_config.json:

json
{  "mcpServers": {    "agentgate": {      "command": "npx",      "args": ["@agentkitai/agentgate-mcp"],      "env": {        "AGENTGATE_URL": "http://localhost:3000",        "AGENTGATE_API_KEY": "agk_..."      }    }  }}

Available MCP Tools

ToolDescription
agentgate_requestSubmit a new approval request
agentgate_getGet the status of an approval request by ID
agentgate_listList approval requests with optional filters
agentgate_decideApprove or deny a pending request
agentgate_list_policiesList all policies ordered by priority
agentgate_create_policyCreate a new policy with rules
agentgate_update_policyReplace an existing policy
agentgate_delete_policyDelete a policy by ID
agentgate_list_audit_logsList audit log entries with filters and pagination
agentgate_get_audit_actorsGet unique actor values from audit logs

Authentication

AgentGate uses API keys for authentication. All API requests (except /health) require a valid API key.

API Key Scopes

ScopeDescription
adminFull access to all operations
request:createCreate new approval requests
request:readRead approval requests
request:decideApprove or deny requests
webhook:manageCreate/update/delete webhooks

Using API Keys

HTTP Header:

bash
curl -H "Authorization: Bearer agk_..." http://localhost:3000/api/requests

SDK:

typescript
const client = new AgentGateClient({  baseUrl: 'http://localhost:3000',  apiKey: process.env.AGENTGATE_API_KEY,});

Creating Additional API Keys

typescript
// Via API (requires admin scope)POST /api/api-keys{  "name": "My Agent",  "scopes": ["request:create", "request:read"]}

API Endpoints

MethodEndpointDescriptionRequired Scope
POST/api/requestsCreate approval requestrequest:create
GET/api/requestsList requests (with filters)request:read
GET/api/requests/:idGet request by IDrequest:read
POST/api/requests/:id/decideSubmit approval/denialrequest:decide
GET/api/requests/:id/auditGet audit trailrequest:read
GET/api/policiesList policiesadmin
POST/api/policiesCreate policyadmin
PUT/api/policies/:idUpdate policyadmin
DELETE/api/policies/:idDelete policyadmin
POST/api/api-keysCreate API keyadmin
GET/api/api-keysList API keysadmin
PATCH/api/api-keys/:idUpdate API keyadmin
DELETE/api/api-keys/:idRevoke API keyadmin
GET/api/webhooksList webhookswebhook:manage
POST/api/webhooksCreate webhookwebhook:manage
DELETE/api/webhooks/:idDelete webhookwebhook:manage
GET/healthHealth check(none)

Rate Limiting

AgentGate supports per-API-key rate limiting to prevent abuse and ensure fair usage.

How It Works

  • Rate limits use a sliding window algorithm (requests per minute)
  • Limits are configured per API key
  • When exceeded, requests return 429 Too Many Requests
  • Rate limit headers are included in all authenticated responses

Rate Limit Headers

HeaderDescription
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetSeconds until window resets

Configuring Rate Limits

Set rate limits when creating or updating API keys:

typescript
// Via API (requires admin scope)POST /api/api-keys{  "name": "My Agent",  "scopes": ["request:create", "request:read"],  "rateLimit": 60  // 60 requests per minute}
// null = unlimited{  "name": "Internal Service",  "scopes": ["admin"],  "rateLimit": null}

Dashboard

Rate limits can also be managed from the web dashboard under Settings → API Keys.

Webhooks

AgentGate can notify external systems when request events occur.

Setting Up Webhooks

typescript
// Create a webhook via APIPOST /api/webhooks{  "url": "https://your-server.com/webhook",  "events": ["request.created", "request.decided"],  "secret": "optional-signing-secret"}

Webhook Events

EventDescription
request.createdA new approval request was created
request.decidedA request was approved or denied
request.expiredA request expired without decision

Webhook Payload

json
{  "event": "request.decided",  "timestamp": "2024-01-15T10:30:00Z",  "data": {    "id": "abc123",    "action": "send_email",    "status": "approved",    "decidedBy": "[email protected]"  }}

Webhook Signatures

If you provide a secret, requests are signed with HMAC-SHA256:

X-AgentGate-Signature: sha256=...

Verify by computing HMAC-SHA256(secret, body) and comparing.

Webhook Retry

Failed webhook deliveries are retried automatically with exponential backoff. The server scans for pending deliveries and retries them with increasing delays (2^attempts * 1000ms) until successful or the maximum retry count is reached.

Configuration

Environment Variables

VariableDefaultDescription
PORT3000Server port
DATABASE_URL./data/agentgate.dbSQLite database path
AGENTGATE_API_KEY-API key for SDK/CLI
SLACK_BOT_TOKEN-Slack bot token (for Slack integration)
SLACK_SIGNING_SECRET-Slack signing secret
DISCORD_BOT_TOKEN-Discord bot token (for Discord integration)
DISCORD_DEFAULT_CHANNEL-Default Discord channel for notifications

File-Based Secrets (_FILE suffix)

For Docker secrets or Kubernetes secret mounts, AgentGate supports a _FILE suffix convention. Instead of setting a secret directly in an environment variable, point to a file containing the value:

VariableReads secret from file
ADMIN_API_KEY_FILESets ADMIN_API_KEY
JWT_SECRET_FILESets JWT_SECRET
DATABASE_URL_FILESets DATABASE_URL
REDIS_URL_FILESets REDIS_URL
SLACK_BOT_TOKEN_FILESets SLACK_BOT_TOKEN
SLACK_SIGNING_SECRET_FILESets SLACK_SIGNING_SECRET
DISCORD_BOT_TOKEN_FILESets DISCORD_BOT_TOKEN
SMTP_PASS_FILESets SMTP_PASS

Behavior:

  • File contents are trimmed of leading/trailing whitespace
  • If both the env var and the _FILE variant are set, the explicit env var takes precedence
  • Missing or unreadable files produce a warning but do not crash the server

Example with Docker Compose:

yaml
services:  agentgate:    environment:      ADMIN_API_KEY_FILE: /run/secrets/admin_api_key      JWT_SECRET_FILE: /run/secrets/jwt_secret    secrets:      - admin_api_key      - jwt_secret
secrets:  admin_api_key:    file: ./secrets/admin_api_key.txt  jwt_secret:    file: ./secrets/jwt_secret.txt

Policy Configuration

Policies are stored in the database and can be managed via API:

typescript
// Example: Auto-approve low-risk emails{  name: "auto-approve-emails",  priority: 10,  enabled: true,  rules: [    {      match: { action: "send_email" },      decision: "auto_approve"    }  ]}

Docker Deployment

AgentGate provides Docker images for easy self-hosted deployments.

Quick Start

  1. Copy the example environment file:
bash
cp .env.example .env
  1. Generate secure credentials:
bash
# Generate admin API key (required)echo "ADMIN_API_KEY=$(openssl rand -hex 32)" >> .env
# Generate JWT secret (recommended for production)echo "JWT_SECRET=$(openssl rand -hex 32)" >> .env
  1. Start all services:
bash
docker-compose up -d
  1. Access the services:

Host ports are configurable via SERVER_PORT (default 3002) and DASHBOARD_PORT (default 3003); both map to the container's internal port 3000/80.

Services

ServiceDescriptionHost Port
serverAgentGate API server3002
dashboardWeb dashboard (nginx)3003
postgresPostgreSQL databaseinternal only*
redisRedis (rate limiting, queues)internal only*

* PostgreSQL and Redis are on an internal Docker network (agentgate-internal) and are not exposed to the host by default. During development, docker-compose.override.yml is auto-loaded and exposes them on ports 5432/6379. For production, run docker-compose -f docker-compose.yml up -d to skip the override.

With Slack or Discord Bots

To include the bot services, use the bots profile:

bash
# Set required bot credentials in .env firstdocker-compose --profile bots up -d

Configuration

All configuration is done via environment variables. See .env.example for all options.

Required variables:

  • ADMIN_API_KEY — Admin API key (min 16 characters)

Recommended for production:

  • JWT_SECRET — JWT signing secret (min 32 characters)
  • CORS_ALLOWED_ORIGINS — Restrict to your domain(s)
  • POSTGRES_PASSWORD — Use a strong password

Building Images

Build all images locally:

bash
docker-compose build

Build a specific service:

bash
docker-compose build serverdocker-compose build dashboard

Database Migrations

Migrations run automatically when the server starts. For manual control:

bash
# Run migrations inside the containerdocker-compose exec server node -e "  import('./dist/db/migrate.js').then(m => m.runMigrations())"

Viewing Logs

bash
# All servicesdocker-compose logs -f
# Specific servicedocker-compose logs -f server
# Last 100 linesdocker-compose logs --tail=100 server

Stopping Services

bash
# Stop alldocker-compose down
# Stop and remove volumes (WARNING: deletes data)docker-compose down -v

Production Considerations

  1. Use a reverse proxy (nginx, Caddy, Traefik) for TLS termination
  2. Set strong passwords for PostgreSQL
  3. Restrict CORS origins to your domain
  4. Use Docker secrets for sensitive values in production
  5. Set up backups for PostgreSQL data volume
  6. Monitor health endpoints for uptime checks

Development

bash
# Install dependenciespnpm install
# Run migrationspnpm --filter @agentkitai/agentgate-server db:migrate
# Bootstrap (create admin key)pnpm --filter @agentkitai/agentgate-server bootstrap
# Start development (server + dashboard)pnpm dev

Testing

AgentGate uses Vitest for testing across all packages.

bash
# Run all testspnpm test
# Run tests with coverage reportpnpm test:coverage
# Run tests in watch mode (single package)pnpm --filter @agentkitai/agentgate-server test:watch
# Run a specific test filepnpm --filter @agentkitai/agentgate-server test -- src/__tests__/integration.test.ts

Coverage reports are generated per-package and include line, branch, and function coverage.

Code Quality

bash
# Build all packagespnpm build
# Type checkingpnpm typecheck
# Lint (ESLint)pnpm lint
# Fix lint issuespnpm lint:fix
# Format code (Prettier)pnpm format
# Check formattingpnpm format:check

Project Structure

agentgate/├── packages/│   ├── core/           # Shared types, schemas, policy engine│   ├── server/         # Hono API server│   ├── sdk/            # TypeScript SDK│   ├── cli/            # Command-line interface│   ├── mcp/            # MCP server for Claude Desktop│   ├── slack/          # Slack bot│   ├── discord/        # Discord bot│   └── dashboard/      # React dashboard├── apps/│   └── demo/           # Demo application├── docker-compose.yml  # Docker deployment└── package.json        # Monorepo root

Contributing

Contributions are welcome! To get started:

  1. Fork the repository
  2. Clone and install dependencies (pnpm install)
  3. Follow the Development section above to set up your local environment
  4. Create a feature branch and make your changes
  5. Run pnpm build && pnpm test to verify everything works
  6. Open a pull request

Please make sure all tests pass and code is formatted (pnpm format:check && pnpm lint) before submitting.

🧰 AgentKit Ecosystem

ProjectDescription
AgentLensObservability & audit trail for AI agents
LoreCross-agent memory and lesson sharing
AgentGateHuman-in-the-loop approval gateway⬅️ you are here
FormBridgeAgent-human mixed-mode forms
AgentEvalTesting & evaluation framework
agentkit-cliUnified CLI orchestrator

License

MIT

来源:README.md,提交 abb46ee

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.0.3最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分