Skip to main content

Overview

civic-mcp-client is a Python MCP client for connecting to the Civic MCP Hub and exposing MCP tools to AI frameworks. It supports:
  • Direct Civic token authentication
  • RFC 8693 token exchange (server-side only)
  • Adapter-based integration with frameworks like LangChain, Pydantic AI, and FastMCP
Start with the reference implementation: That demo uses Civic Auth in the frontend and forwards the authenticated Civic access token to a Python backend, which then passes it into CivicMCPClient(auth={"token": ...}).

Install

Optional framework integrations:

Authentication

Civic Token (direct; manual token for local testing)

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
CIVIC_TOKEN (docs) is the same value as access_token. In the python-civic-mcp-client repo, this value is named CIVIC_ACCESS_TOKEN.

Token Exchange (RFC 8693)

Token exchange is server-side only. Your Civic client secret must never be shipped to a browser or untrusted environment.

Quick Start (manual token)

This quick start uses a manually generated Civic access token for local testing. For a production-like frontend + Python backend setup, use the demo app above.

Framework Adapters

Use await client.adapt_for(...) with the adapter for your framework. Depending on the adapter, adapt_for(...) will either:
  • Return a new CivicMCPClient (backend adapters like FastMCP), or
  • Return adapter-native tool outputs (e.g. tool schemas / definitions)

LangChain / LangGraph

Pydantic AI

FastMCP

Next Steps

  • See the agent deployment guide: profile locking, URL parameters, and best practices

Get help

  • Ask questions in our developer Slack