Show HN:A2a-gateway —— 使用 Rust 实现的 A2A v1.0 与 MCP 2.0 网关(973 RPS,13.5 MB 内存)
Show HN: A2a-gateway – Rust A2A v1.0 and MCP 2.0 gateway (973 RPS, 13.5 MB RAM)

原始链接: https://github.com/csa7mdm/a2a-gateway

A2A Gateway 是一个精简的生产级 Rust Agent2Agent v1.0 边缘代理,面向 GCP e2-micro 等微型虚拟机设计。它在解析前强制要求 JSON 媒体类型,以阻止 text/plain/form 形式的 CSRF 式请求;支持可选的恒定时间 Bearer 认证和按租户的令牌桶速率限制;发现上游代理卡片,并发布确定性的聚合 A2A 卡片。它通过零拷贝 SSE 透传流式传输 SendStreamingMessage 响应,并输出隐私安全的 JSONL 遥测数据,不包含正文、提示词、标头或 IP。无状态 MCP 2.0 门面通过 POST /mcp 暴露健康的 A2A 技能。可选的 langextract-agent 功能增加一个零 LLM、确定性的文本清理/分块/片段锚定代理。在 e2-micro 上以 300 个请求进行实测基准测试,达到 973.6 RPS、8.99/18.24/25.21 ms 的 p50/p95/p99 延迟,以及低于 13.5 MB 的合计 RSS。可使用 cargo install a2a-gateway 安装,可选添加 --features langextract-agent;端点包括健康与就绪探针、/.well-known/agent-card.json、/agents/{agent_id}、/{tenant}/agents/{agent_id} 和 /mcp。

黑客新闻 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN:A2a-gateway —— 用 Rust 实现的 A2A v1.0 和 MCP 2.0 网关(973 RPS,13.5 MB 内存) ( github.com/csa7mdm ) 4 分 由 csa7mdm 发布于 1 小时前 | 往期 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

CI Crates.io License: Apache-2.0

Lean, production-grade Rust A2A (Agent2Agent v1.0) Edge Gateway engineered for low-memory VMs (such as GCP Always Free e2-micro), featuring:

  • Strict Edge Media-Type / CSRF Defense: Enforces application/json or application/*+json (including application/a2a+json) before body parsing, blocking cross-origin text/plain and form-encoded CORS simple requests with JSON-RPC -32005 (CONTENT_TYPE_NOT_SUPPORTED).
  • Constant-Time Auth & Per-Tenant Rate Limiting: Optional Bearer token verification + lightweight token-bucket rate limiter per tenant (/{tenant}/agents/{agent_id}).
  • Dynamic Agent Discovery & Aggregated Card: Discovers upstream /.well-known/agent-card.json endpoints and serves a deterministic aggregated A2A v1.0 Agent Card.
  • Zero-Copy SSE Streaming Passthrough: Proxies SendStreamingMessage / text/event-stream responses chunk-by-chunk with no buffering.
  • Zero-PII Mizan Telemetry: Emits structured JSONL metrics (ts_ms, tenant, agent_id, rpc_method, status, streaming, latency_ms, bytes_in, bytes_out) — never logs message bodies, prompts, headers, or IP addresses.
  • Stateless MCP 2.0 (2026-07-28) Discovery Facade: Exposes registered healthy A2A skills via POST /mcp (server/discover and tools/list) with cacheScope and ttlMs.
  • Optional langextract-agent Binary (--features langextract-agent): Ships a zero-LLM-cost A2A v1.0 agent powered by langextract-core for deterministic text cleaning, chunking, and snippet grounding.

Real Production Benchmark (GCP Always Free e2-micro, 1 GB RAM)

Measured live on mizan-cloud-prod (e2-micro, us-central1, 300 concurrent SendMessage JSON-RPC requests at concurrency=10, full round-trip a2a-gateway -> langextract-agent -> langextract-core 0.3.0 + JSONL telemetry):

Metric Measured Value
Throughput 973.6 RPS (300 reqs in 0.308s)
End-to-End Latency (p50 / p95 / p99) 8.99 ms / 18.24 ms / 25.21 ms
langextract-core Compute (p50 / p95 / p99) 25 us / 41 us / 71 us
a2a-gateway RSS (idle / post-bench) 5.4 MB / 6.5 MB
langextract-agent RSS (idle / post-bench) 4.0 MB / 6.8 MB
Combined Stack Memory < 13.5 MB RSS
# 1. Aggregated A2A v1.0 Agent Card
curl -s https://a2a.35-209-222-203.sslip.io/.well-known/agent-card.json

# 2. Stateless MCP 2.0 (2026-07-28) Discovery
curl -s -X POST https://a2a.35-209-222-203.sslip.io/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"server/discover"}'

# 3. Live A2A v1.0 SendMessage (clean, chunk & ground snippets via langextract-core)
curl -s -X POST https://a2a.35-209-222-203.sslip.io/agents/langextract \
  -H "Content-Type: application/json" \
  -H "A2A-Version: 1.0" \
  -d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"demo-1","role":"ROLE_USER","parts":[{"text":"Rust A2A Edge Gateway runs in 5.4 MB RSS on GCP e2-micro."}]},"metadata":{"maxChars":120,"overlap":10,"snippets":["5.4 MB RSS"]}}}'
# Install from crates.io
cargo install a2a-gateway

# Or build with the optional LangExtract A2A v1.0 agent
cargo install a2a-gateway --features langextract-agent

# Run with config
cp a2a-gateway.example.toml a2a-gateway.local.toml
a2a-gateway a2a-gateway.local.toml
Endpoint Purpose
GET /health/live Liveness probe
GET /health/ready Readiness probe (reports healthy upstream agent count)
GET /.well-known/agent-card.json Aggregated A2A v1.0 Agent Card merging healthy upstream skills
POST /agents/{agent_id} JSON-RPC 2.0 & SSE proxy (default tenant)
POST /{tenant}/agents/{agent_id} Multi-tenant JSON-RPC 2.0 & SSE proxy
POST /mcp Stateless MCP 2.0 (2026-07-28) server/discover & tools/list facade
cargo test --all-targets --all-features
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --check
联系我们 contact @ memedata.com