Skip to main content
Connect a smolagents agent from Hugging Face to Civic using MCPClient with Streamable HTTP transport. smolagents’ MCP client discovers all available tools and exposes them to a CodeAgent.

Prerequisites

  • Python 3.11+
  • A Civic account at app.civic.com with a configured toolkit
  • A Civic token and an Anthropic API key

Installation

Environment Variables

Get Your Credentials

How to generate a Civic token and configure toolkit URL parameters

Connecting to Civic

Pass a single config dict to MCPClient with the transport key set to "streamable-http" (hyphen, not underscore):
The transport key must be "streamable-http" with a hyphen. Using "streamable_http" with an underscore will fail. Pass a flat dict to MCPClient — not a nested {"server_name": {...}} structure.

Running the Agent

Production Configuration

For production agents, lock to a specific toolkit using the profile URL parameter:

Reference Implementation

smolagents-reference-implementation-civic

Complete implementation with FastAPI chat UI and deployment guide

Next Steps

Agent Deployment

Production deployment guide: profile locking, URL params, authentication

Guardrails

Constrain what tools your agent can call

Audit Trail

Query what your agent did via Civic Chat

Get Credentials

Token generation and URL parameter reference