Overview
Integrate Civic with the OpenAI Agents SDK usinghostedMcpTool() — the simplest way to use Civic with OpenAI. No manual tool looping or schema conversion required.
For the older manual function calling approach, see OpenAI SDK (Node.js).
Prerequisites
- Civic account at app.civic.com with at least one MCP server connected
- OpenAI API key from platform.openai.com
Installation
openai package is bundled as a dependency — no need to install it separately.
Authentication
- Backend / Script (Civic Token)
- Next.js App (Civic Auth)
For autonomous agents and server-side scripts — use a Civic token directly.For production agents, lock to a specific toolkit by appending a
Generate a Civic Token
- Log in to app.civic.com
- Click your account name in the bottom left
- Go to Install → MCP URL
- Click Generate Token and copy it immediately — it won’t be shown again
Set Environment Variables
profile parameter:Use the Token
Pass the token as a Bearer token in theAuthorization header:Full credentials guide
Token generation, URL parameters, OAuth vs token comparison
Basic Setup
- Backend / Script
- Next.js API Route
Streaming
Tool Approval
Control which tools require human approval before execution:Strict Mode
Comparison
OpenAI Agents SDK Docs
Official OpenAI Agents SDK MCP guide
Get Help
Developer Slack

