Vercel Connect 現已支援 TanStack AI
Vercel Connect now supports TanStack AI
使用 TanStack AI 構建的 Agent 現在可通過 Vercel Connect 呼叫 OAuth 保護的 MCP 伺服器,無需儲存或輪換憑證。
新的 @vercel/connect/tanstack-ai 子路徑匯出 connectMCPTransport,自動為每次 MCP 請求附加 Connect 授權提供者,保證令牌始終新鮮。
Agents built with TanStack AI can now call OAuth-protected MCP servers through Vercel Connect, with no credentials for you to store or rotate.
The new @vercel/connect/tanstack-ai subpath exports connectMCPTransport, which takes a TanStack transport config and attaches a Connect-backed auth provider. The provider is called before every MCP request, so the token is always fresh.
import { chat, toServerSentEventsResponse } from '@tanstack/ai';
import { createMCPClient } from '@tanstack/ai-mcp';
import { vercelGatewayText } from '@tanstack/ai-vercel-gateway';
import {
connectMCPTransport,
getConsentChallenge,
} from '@vercel/connect/tanstack-ai';
export async function POST(request: Request) {
const { messages } = await request.json();
const userId = await getUserId(request);
try {
const linear = await createMCPClient({
transport: connectMCPTransport(
{ type: 'http', url: 'https://mcp.linear.app/mcp' },
'oauth/linear',
{ subject: { type: 'user', id: userId } },
),
});
const stream = chat({
adapter: vercelGatewayText('anthropic/claude-opus-5'),
messages,
mcp: { clients: [linear] },
});
return toServerSentEventsResponse(stream);
} catch (err) {
const challenge = getConsentChallenge(err);
if (challenge) return Response.redirect(challenge.url, 303);
throw err;
}
}
Connect a Linear MCP client with a per-user token and redirect to consent when needed.
If the user has not granted access, createMCPClient fails with a consent challenge before the model runs. Catch it with getConsentChallenge and redirect to Connect's consent URL. Otherwise, a consent error raised within a tool call would reach the model as an error string rather than the user as a redirect.
Read the TanStack AI integration docs to get started, or see the full list of supported frameworks and adapters for Vercel Connect.
來源:Vercel Blog · vercel.com