Skip to content

Example: Agent with remote HTTP MCP server for real-world APIs #5092

@whiteknightonhorse

Description

@whiteknightonhorse

Context

ADK's MCP integration via McpToolset works great with local servers. For production agents, connecting to remote HTTP MCP servers that provide real-world data (stock prices, weather, flights, job listings) is a common need but lacks an official example.

Proposed Example

An agent that queries real-world APIs through a remote MCP server:

from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset, StreamableHTTPConnectionParams

# Connect to remote MCP server with 409 real-world API tools
toolset = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url="https://apibase.pro/mcp"
    )
)
tools, exit_stack = await toolset.create_tools()

agent = Agent(
    model="gemini-2.0-flash",
    name="data-agent",
    instruction="You have access to real-world API tools for stocks, weather, flights, and more.",
    tools=tools,
)

# Agent calls the right tool based on the question
response = await agent.run("What is the current weather in Tokyo?")

What this demonstrates

  1. StreamableHTTPConnectionParams with a production remote endpoint
  2. Real-world data retrieval (not toy math/echo examples)
  3. Agent tool selection — 409 tools, agent picks the relevant one
  4. No local server setup required — works out of the box

Happy to contribute a PR with the full example if there's interest.

Metadata

Metadata

Labels

mcp[Component] Issues about MCP supportneeds review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions