Skip to main content

Overview

Integrate Civic with the OpenAI Agents SDK using hostedMcpTool() — 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

Installation

The openai package is bundled as a dependency — no need to install it separately.

Authentication

For autonomous agents and server-side scripts — use a Civic token directly.

Generate a Civic Token

  1. Log in to app.civic.com
  2. Click your account name in the bottom left
  3. Go to Install → MCP URL
  4. Click Generate Token and copy it immediately — it won’t be shown again
Never commit your token to source control. Store it in environment variables or a secrets manager. Tokens expire after 30 days.

Set Environment Variables

For production agents, lock to a specific toolkit by appending a profile parameter:

Use the Token

Pass the token as a Bearer token in the Authorization header:

Full credentials guide

Token generation, URL parameters, OAuth vs token comparison

Basic Setup

The Agent automatically discovers available Civic tools, selects the right one, calls it, and returns the result.

Streaming

Tool Approval

Control which tools require human approval before execution:

Strict Mode

Not all Civic tool schemas are compatible with OpenAI’s strict: true structured outputs. Set strict to false on the Responses API when using Civic tools.

Comparison

OpenAI Agents SDK Docs

Official OpenAI Agents SDK MCP guide

Get Help

Developer Slack