Overview
Integrate Civic Nexus with Vercel AI SDK to build AI applications that can access external tools and services through MCP (Model Context Protocol). This enables your AI agents to interact with GitHub, Slack, Dropbox, and other connected services.Updated for AI SDK v5: This guide has been updated to use Vercel AI SDK v5. The main changes from v4 include:
- New tool definition format with
execute
functions - Updated streaming response methods (
toDataStreamResponse()
instead oftoAIStreamResponse()
) - Improved error handling and type safety
- App Router examples instead of Pages Router
Prerequisites: You’ll need a Civic account and Node.js 18+ installed. Create your account and select your tools first.
Installation
Install the required packages:AI SDK v5: This guide uses the latest Vercel AI SDK v5, which includes significant improvements and breaking changes from v4. Make sure to use v5 for the best experience.
Vercel AI SDK v5
Latest AI SDK for building AI applications
Model Providers
OpenAI and Anthropic provider packages
MCP SDK
Provides HTTP client transport for MCP protocol
Civic Auth
Handles authentication with Civic Nexus
Basic Setup
Step 1: Create MCP Client
Create a function to initialize the MCP client with authentication:Step 2: List Available Tools
Query available MCP tools from your connected services:Step 3: Call MCP Tools
Execute tools with the MCP client:Integration with Vercel AI SDK
Using with OpenAI
Combine MCP tools with OpenAI’s function calling:Using with Anthropic Claude
Complete Example: AI Assistant
Here’s a complete example showing how to authenticate with Nexus and integrate MCP tools:Nexus Authentication
The key to integrating with Nexus is properly setting up the authentication headers. Here’s what you need:Required Headers
Required Headers
Getting the Access Token
Getting the Access Token
Use Civic Auth to get the user’s access token:
Nexus Endpoint
Nexus Endpoint
Always connect to the Nexus MCP Hub endpoint:
Next Steps
1
Set up Authentication
Configure Civic Auth in your Next.js application following our auth guide
2
Connect Services
Visit nexus.civic.com to connect GitHub, Slack, or other services
3
Build Your AI App
Use the examples above to create your AI-powered application
4
Deploy
Deploy to Vercel or your preferred platform with proper environment variables
Need Help?
Join our developer community for technical support and implementation assistance