Skip to main content

Overview

Integrate Civic with Anthropic’s Messages API using the native MCP connector — built directly into the API, no separate MCP client needed.
Native MCP Support: Add a mcp_servers parameter to your messages.create() call. Claude discovers and calls tools automatically — no tool looping required.

Prerequisites

Installation

npm install @anthropic-ai/sdk
No MCP SDK required — the connector is built into the Anthropic SDK.

Authentication

Choose the path that matches your use case:
For autonomous agents, scripts, and server-side code that runs without a user browser session — 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

CIVIC_TOKEN=your-civic-token-here
CIVIC_URL=https://app.civic.com/hub/mcp
For production agents, lock to a specific toolkit by appending a profile parameter:
CIVIC_URL=https://app.civic.com/hub/mcp?profile=your-toolkit-alias

Use the Token

Pass the token as a Bearer token in the Authorization header:
headers = {"Authorization": f"Bearer {os.environ['CIVIC_TOKEN']}"}
headers: { Authorization: `Bearer ${process.env.CIVIC_TOKEN}` }

Full credentials guide

Token generation, URL parameters, OAuth vs token comparison
# .env
ANTHROPIC_API_KEY=your_anthropic_api_key
CIVIC_TOKEN=your-civic-token-here
CIVIC_URL=https://app.civic.com/hub/mcp

Basic Example

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY!,
});

async function createMessage(userMessage: string) {
  const response = await client.messages.create({
    model: 'claude-sonnet-4-5',
    max_tokens: 1024,
    messages: [{ role: 'user', content: userMessage }],
    mcp_servers: [
      {
        type: 'url',
        url: process.env.CIVIC_URL!,
        name: 'civic',
        authorization_token: process.env.CIVIC_TOKEN!,
      },
    ],
  }, {
    headers: {
      'anthropic-beta': 'mcp-client-2025-11-20',
    },
  });

  return response;
}
Key points:
  • Add mcp_servers to your messages.create() call
  • Include the beta header: "anthropic-beta": "mcp-client-2025-11-20" (required)
  • Pass your token as authorization_token
  • Claude handles tool selection and execution automatically

Streaming

const stream = await client.messages.create({
  model: 'claude-sonnet-4-5',
  max_tokens: 4096,
  messages: [{ role: 'user', content: 'List my GitHub repositories' }],
  mcp_servers: [
    {
      type: 'url',
      url: process.env.CIVIC_URL!,
      name: 'civic',
      authorization_token: process.env.CIVIC_TOKEN!,
    },
  ],
  stream: true,
}, {
  headers: { 'anthropic-beta': 'mcp-client-2025-11-20' },
});

for await (const event of stream) {
  if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
    process.stdout.write(event.delta.text);
  }
}

Tool Configuration (Optional)

Restrict which tools Claude can use:
mcp_servers: [
  {
    type: 'url',
    url: process.env.CIVIC_URL!,
    name: 'civic',
    authorization_token: process.env.CIVIC_TOKEN!,
    tool_configuration: {
      enabled: true,
      allowed_tools: ['github__list_repos', 'slack__search_messages']
    }
  },
]

Current Limitations

The MCP connector currently only supports:
  • Tool calls (not MCP resources or prompts)
  • HTTP servers (not STDIO servers)
  • SSE and Streamable HTTP transports
Amazon Bedrock and Google Vertex integrations are not yet supported.

Comparison

FeatureAnthropic MCP ConnectorOpenAI Agents SDKVercel AI SDK
Setup ComplexityLowLowMedium
MCP SDK NeededNoNoYes
Tool LoopingNo (automatic)No (automatic)Yes (manual)
Best ForDirect API usageQuick prototypesNext.js apps
StreamingYesYesYes

Next Steps

Anthropic MCP Docs

Official Anthropic MCP connector reference

Get Help

Developer Slack