What are all the tool types in Google ADK? Explain Function Tools, MCP Tools, OpenAPI Tools, and Agents-as-Tools with examples.
#google-adk#tools#function-tools#mcp#openapi#agents-as-tools
Answer
Tool Types in Google ADK

Google ADK provides a rich tool ecosystem with 6 tool types that let agents interact with external systems, APIs, and data sources.
Tool Types Overview
1. Function Tools
Any Python function automatically becomes a tool. ADK extracts the docstring as the tool description and type hints as parameters.
pythonfrom google.adk.agents import Agent def search_database(query: str, limit: int = 10) -> list[dict]: """Search the internal database for relevant documents. Args: query: The search query string. limit: Maximum number of results to return. Returns: list[dict]: List of matching documents with title and content. """ # Your database logic here return [{"title": "Doc 1", "content": "..."}] def calculate_cost(tokens: int, model: str = "gpt-4o") -> dict: """Calculate the cost of an LLM API call. Args: tokens: Number of tokens used. model: The model name for pricing lookup. Returns: dict: Cost breakdown with input/output pricing. """ rates = {"gpt-4o": 0.005, "gemini-2.5-flash": 0.0001} cost = (tokens / 1000) * rates.get(model, 0.01) return {"model": model, "tokens": tokens, "cost": f"${cost:.4f}"} agent = Agent( name="helper", model="gemini-2.5-flash", instruction="Help users search data and calculate costs.", tools=[search_database, calculate_cost], )
2. Built-in Tools
| Tool | Import | Description |
|---|---|---|
| Google Search | text | Web search via Google |
| Code Execution | Built-in | Execute code using Gemini |
| RAG Retrieval | Built-in | Private data retrieval |
pythonfrom google.adk.tools import google_search agent = Agent( name="search_agent", model="gemini-2.5-flash", instruction="Search the web to answer questions.", tools=[google_search], )
3. MCP Tools
Connect to any Model Context Protocol server:
pythonfrom google.adk.tools.mcp_tool import McpToolset, StdioServerParameters # Stdio connection (local) fs_tools = McpToolset( connection_params=StdioServerParameters( command="npx", args=["-y", "@modelcontextprotocol/server-filesystem", "./data"], ) ) # SSE connection (remote) from google.adk.tools.mcp_tool import SseServerParams remote_tools = McpToolset( connection_params=SseServerParams( url="https://mcp-server.example.com/sse" ) ) agent = Agent( name="file_agent", model="gemini-2.5-flash", tools=[fs_tools], )
4. OpenAPI Tools
Auto-generate tools from OpenAPI v3.x specifications:
pythonfrom google.adk.tools.openapi_tool import OpenAPIToolset # Generate tools from API spec toolset = OpenAPIToolset( spec_str=open("petstore.yaml").read(), spec_str_type="yaml", ) agent = Agent( name="api_agent", model="gemini-2.5-flash", instruction="Help users interact with the Pet Store API.", tools=toolset.get_tools(), )
5. Agents-as-Tools (AgentTool)
Use a specialized agent as a tool for another agent:
pythonfrom google.adk.tools import AgentTool # Specialist agent math_agent = Agent( name="math_solver", model="gemini-2.5-flash", instruction="Solve math problems step by step.", ) # Use it as a tool main_agent = Agent( name="tutor", model="gemini-2.5-flash", instruction="Help students learn. Use the math solver for calculations.", tools=[AgentTool(agent=math_agent)], )
6. Long Running Function Tools
For async operations that take time to complete:
pythonfrom google.adk.tools import LongRunningFunctionTool async def train_model(dataset: str, epochs: int = 10): """Train a model on the given dataset. Args: dataset: Path to training data. epochs: Number of training epochs. """ for epoch in range(epochs): yield {"status": "training", "epoch": epoch + 1, "total": epochs} yield {"status": "complete", "accuracy": 0.95} agent = Agent( name="ml_agent", model="gemini-2.5-flash", tools=[LongRunningFunctionTool(func=train_model)], )
Tool Confirmation (Human-in-the-Loop)

Require user approval before executing sensitive tools:
pythonagent = Agent( name="db_agent", model="gemini-2.5-flash", instruction="Help manage the database.", tools=[delete_record], # dangerous operation tool_confirmation=True, # ask user before executing )
Summary
| Tool Type | When to Use |
|---|---|
| Function Tool | Wrap any Python function |
| Built-in Tool | Google Search, Code Exec, RAG |
| MCP Tool | Connect to MCP servers |
| OpenAPI Tool | Auto-generate from API specs |
| Agent-as-Tool | Use agent as a callable tool |
| Long Running | Async operations with progress |
Learn more at Custom Tools and Function Tools.