Vercel Connect's TanStack AI integration handles authentication when an AI agentAn AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.Full definition → calls an OAuth-protected MCPThe Model Context Protocol — an open standard that lets any AI assistant plug into any tool or data source without custom integration code.Full definition → server, a service exposing tools to the agent. Its transport adapter asks Connect for authentication before each request, moving recurring access-credential handling into that service.
The integration also places consent in the application's user flow. If access has not been granted, client creation raises a consent challenge before the model runs. The application can redirect the person to approve access, instead of allowing the problem to reach the model later as a failed tool call. Developers still need to handle that redirect in their application.
Key takeaways · AI-distilled
The integration ships as the @vercel/connect/tanstack-ai subpath, whose connectMCPTransport wraps a TanStack transport config with a Connect-backed auth provider.
The auth provider runs before every MCP request, which is how Vercel says tokenThe chunk of text a model reads and writes in — roughly three-quarters of a word — and the unit AI usage is billed in.Full definition → stay fresh without the app storing or rotating credentials.
If a user has not granted access, createMCPClient fails with a consent challenge before the model runs; catching it with getConsentChallenge lets the app redirect the user to Connect's consent URL.
Vercel's stated reason for failing early: a consent error raised inside a tool call would reach the model as an error string instead of reaching the user as a redirect.
Terms in this piece · Glossary
AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
MCP — The Model Context Protocol — an open standard that lets any AI assistant plug into any tool or data source without custom integration code.
token — The chunk of text a model reads and writes in — roughly three-quarters of a word — and the unit AI usage is billed in.