Overview
This recipe shows how to wire Nexus MCP tools to the official OpenAI Node SDK using function calling.Why manual function calling? The standard OpenAI SDK doesn’t have native MCP support yet. OpenAI announced MCP support for their Responses API is coming soon, but it’s not available in the
openai
package yet.Want a simpler approach? Check out the OpenAI Agents SDK recipe which has native MCP support via hostedMcpTool()
- no manual tool looping required!Access Token Setup (Next.js)
Why Civic Auth? Nexus needs to identify which user is accessing tools and authorize their permissions. Civic Auth provides the secure access token. (Support for additional identity providers coming soon.)- 1. next.config.ts
- 2. API Route
- 3. Middleware
- 4. Get Token
Full Integration Guide
Complete Next.js setup with frontend components, configuration options, and deployment details
AI Prompt for Next.js
Use Claude, ChatGPT, or other AI assistants to automatically set up Civic Auth
Get your Client ID at auth.civic.com
Create an MCP Client
Call with Tool Functions
Notes
- Obtain the Civic access token via your server environment (e.g., Next.js
getTokens()
), or forward a Bearer token from a trusted frontend. - To verify tokens server-side in non-Next.js stacks, see /libraries/auth-verify.