Skip to main content
Connect a Google Agent Development Kit (ADK) agent to Civic using McpToolset with Streamable HTTP transport. Google ADK natively supports Gemini models; for Claude, register LiteLlm as shown below.

Prerequisites

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

Installation

pip install google-adk litellm python-dotenv

Environment Variables

CIVIC_URL=https://nexus.civic.com/hub/mcp?profile=your-toolkit
CIVIC_TOKEN=your-civic-token
ANTHROPIC_API_KEY=your-anthropic-key

Get Your Credentials

How to generate a Civic token and configure toolkit URL parameters

Connecting to Civic

Google ADK’s built-in Anthropic support requires Vertex AI. To use Claude directly with the Anthropic API, register LiteLlm with the ADK model registry:
import os
import asyncio
from dotenv import load_dotenv
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
from google.adk.models.lite_llm import LiteLlm
from google.adk.models.registry import LLMRegistry

load_dotenv()

# Required: register LiteLlm to use non-Gemini models
LLMRegistry.register(LiteLlm)

root_agent = Agent(
    model=LiteLlm(model="anthropic/claude-sonnet-4-6"),
    name="civic_assistant",
    instruction="You are a helpful assistant with access to Civic tools.",
    tools=[
        McpToolset(
            connection_params=StreamableHTTPConnectionParams(
                url=os.environ["CIVIC_URL"],
                headers={"Authorization": f"Bearer {os.environ['CIVIC_TOKEN']}"},
            ),
        )
    ],
)

Running the Agent

Google ADK uses a Runner to execute agents. Sessions are managed via InMemorySessionService:
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

async def main():
    session_service = InMemorySessionService()
    runner = Runner(
        agent=root_agent,
        app_name="my-app",
        session_service=session_service,
    )
    await session_service.create_session(
        app_name="my-app", user_id="user-1", session_id="session-1"
    )

    message = types.Content(
        role="user",
        parts=[types.Part(text="What events do I have today?")],
    )
    async for event in runner.run_async(
        user_id="user-1", session_id="session-1", new_message=message
    ):
        if event.is_final_response():
            for part in event.content.parts:
                if part.text:
                    print(part.text)

asyncio.run(main())
Use types.Part(text=...) — not types.Part.from_text(...). The from_text class method does not exist in the current Google Gen AI SDK.

Production Configuration

For production agents, lock to a specific toolkit using the profile URL parameter:
CIVIC_URL=https://nexus.civic.com/hub/mcp?profile=your-production-toolkit

Reference Implementation

google-adk-reference-implementation-civic

Complete implementation with ADK web UI, FastAPI chat server, 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