vercel 24天前 · 2026-10-16 14:46:41 · 16 阅读
MCP Events 在 Vercel Connect 中的支持现已进入公开测试阶段
Vercel Connect 现已推出 MCP Events 公测支持,让你的应用和智能体可以订阅来自兼容 MCP 服务器的 webhook 事件。你可以构建这样的智能体:总结新消息、审查新建的 issue,或响应文档反馈。
Connect 会代替你在 MCP 服务器上创建订阅,并按需自动续期,同时验证服务器的 webhook,再通过带认证的投递方式将事件转发给你的应用。
你可以使用 Connect SDK 订阅 MCP 事件:
lib/subscribe-to-issues.ts
1import { experimental_subscribe } from '@vercel/connect/mcp';2// Use a new key for each subscription.3// Reuse it when retrying the same request.4export async function subscribeToIssues(idempotencyKey: string) {5 return experimental_subscribe('oauth/issues', {6 tokenParams: { subject: { type: 'app' } },7 name: 'issue.created',8 arguments: { project_id: 'ABC' },9 destination: { path: '/hooks' },10 ttlMs: 24 * 60 * 60 * 1000,11 idempotencyKey,12 });13}请求一个 24 小时的 issue 事件订阅
在你的投递端点上,在确认收到之前,先使用 SDK 验证每次投递确实来自 Connect:
app/hooks/route.ts
1import { experimental_verifyMcpEvent } from '@vercel/connect/mcp';2
3export async function POST(request: Request) {4 await experimental_verifyMcpEvent(request, { path: '/hooks' });5 return new Response(null, { status: 204 });6}在 Next.js 路由中验证传入的投递
你还可以借助 Connect 的 MCP Events 适配器来管理订阅,把 AI SDK 的事件发现和订阅接口暴露为智能体工具。
在 eve 中,为 MCP 连接开启事件功能后,智能体即可获得相应工具来发现服务器的事件,并使用 Connect 创建、查看或停止订阅。
SDK 配置与认证请参阅 Vercel Connect 快速入门。
原始来源: vercel