Claude with ADK on Vertex AI Agent Engine
Source notebook
Repo path:
agents/agent_engine/tutorial_claude_with_adk_on_agent_engine.ipynb· Open on GitHub · advanced
Builds and deploys a Claude-powered ADK Reddit agent on Vertex AI Agent Engine with memory and tracing.
Summary
This notebook teaches how to build a Google ADK agent using Anthropic Claude on Vertex AI, first as a local social media assistant and then with Reddit tools through MCP. It demonstrates local testing with an ADK Runner, deployment to Vertex AI Agent Engine as an AdkApp, session-based remote chat, generated memories, and an optional update that adds Memory Bank retrieval and tracing.
Key code patterns
Register Claude for ADK
from google.adk.models.anthropic_llm import Claude
from google.adk.models.registry import LLMRegistry
MODEL_ID = "claude-sonnet-4@20250514"
LLMRegistry.register(Claude)Registers the Anthropic Claude model class so ADK agents can use the Vertex-hosted Claude model id.
Local ADK agent
root_agent = LlmAgent(
name="SocialMediaAssistant",
model=os.getenv("MODEL_ID", "claude-sonnet-4@20250514"),
instruction="You are a creative and knowledgeable Social Media Assistant.",
tools=[],
)Defines the agent identity, system instruction, model, and tool list before local or remote execution.
MCP Reddit toolset
MCPToolset(
connection_params=StdioConnectionParams(
server_params=StdioServerParameters(command="mcp-reddit"),
),
errlog=errlog,
)Connects the ADK agent to an external Reddit MCP server and redirects errors for Colab compatibility.
Deploy ModuleAgent
remote_app = agent_engines.create(
display_name="reddit_assistant_agent",
agent_engine=agent_engines.ModuleAgent(
module_name="root_agent",
agent_name="agent_app",
),
extra_packages=["root_agent.py", "installation_scripts/install_local_mcp.sh"],
)Packages the ADK app module and installer script for managed deployment on Vertex AI Agent Engine.
Memory and tracing
agent_app = AdkApp(
agent=root_agent,
session_service_builder=session_service_builder,
memory_service_builder=memory_service_builder,
enable_tracing=True,
)Adds Agent Engine tracing and connects the deployed app to Vertex AI Memory Bank.
Models & APIs used
- Models:
claude-sonnet-4@20250514 - APIs / services: Vertex AI, Vertex AI Agent Engine, Vertex AI Memory Bank, Cloud Storage
- SDKs / libraries:
google-cloud-aiplatform,google-adk,anthropic,vertexai,google-genai,litellm,fastmcp,redditwarp,praw
When to use this
Use this pattern to deploy an ADK agent powered by Claude on Vertex AI Agent Engine with MCP tools, sessions, memory, and tracing.
Gotchas & caveats
- The notebook requires an existing Google Cloud project with the Vertex AI API enabled.
- A Cloud Storage bucket is created and used as the Vertex AI staging bucket for deployment artifacts.
- The location is set to europe-west1 throughout the notebook.
- Reddit client id, client secret, and refresh token are required for the Reddit MCP tool.
- The mcp-reddit server is installed from GitHub with uv through a custom shell installation script.
- The notebook redirects MCP tool stderr to an aiofiles errlog in Colab to avoid a fileno error.
- Environment variables are passed into the deployed Agent Engine app for model and Reddit credentials.
- The cleanup section explicitly deletes the Agent Engine deployment and Cloud Storage bucket to avoid charges.
Best practices
- Test the ADK agent locally with InMemorySessionService and Runner before deploying.
- Package the deployable agent in a root_agent.py module and expose an AdkApp entry point.
- Use a VertexAiSessionService builder for production sessions on Agent Engine.
- Pass runtime credentials and model settings through environment variables for the deployed app.
- Use build_options installation steps to install external MCP runtime dependencies during deployment.
- Use generate_memories or async_add_session_to_memory to persist useful facts from prior sessions.
- Use PreloadMemoryTool to retrieve relevant Memory Bank facts at the start of each turn.
- Delete deployed Agent Engine resources and staging buckets when finished.
Related
- Concepts: Agents & ADK · Agent Engine · Function Calling & Tools
- Entities: Vertex AI · Agent Development Kit · Model Context Protocol · Cloud Storage
- Area: Agents & ADK Notebooks
- Best practices: Agents & ADK - Best Practices · Agent Engine - Best Practices · Function Calling & Tools - Best Practices