Connect a DSPy agent to Civic by wrapping MCP tools as Python callables and passing them toDocumentation Index
Fetch the complete documentation index at: https://docs.civic.com/llms.txt
Use this file to discover all available pages before exploring further.
dspy.ReAct. DSPy v2.6 does not include a built-in MCP client, so tools are discovered via the raw mcp package.
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
Discover tools via the rawmcp client and wrap each one as a Python callable for DSPy:
Running the Agent
DSPy v2.6 has no built-in MCPClient. This pattern uses the raw
mcp package for discovery and wraps each tool as a Python callable. Each tool call opens a new MCP connection — for production use, consider connection pooling.Production Configuration
For production agents, lock to a specific toolkit using theprofile URL parameter:
Reference Implementation
dspy-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

