Skip to main content
Connect a Haystack pipeline to Civic using MCPTool from the Haystack MCP integration. Because MCPTool wraps one named tool at a time, you first discover available tool names via the raw MCP client, then create a tool object for each.

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

Haystack’s MCPTool wraps a single named tool. First discover all tool names using the raw mcp client, then create MCPTool instances and pass them to AnthropicChatGenerator:
MCPTool wraps a single named tool — not a server. You must discover tool names first using the raw mcp package, then create one MCPTool per name. Import AnthropicChatGenerator from haystack_integrations.components.generators.anthropic (requires the anthropic-haystack package).

Production Configuration

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

Reference Implementation

haystack-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