Trying to access a local MCP-Server (HTTP) #2034
Unanswered
BenjaminBuff
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I created a little HTTP MCP-Server as a trial and I try to access it now from one of my ADK experiments. Therefore I checked this documentation: https://cloud.google.com/blog/topics/developers-practitioners/use-google-adk-and-mcp-with-an-external-server and implemented it exactly the way it's shown there.
I'm always getting the error:
"error": "Fail to load 'Test-Agent' module. cannot import name 'SseServerParams' from 'google.adk.tools.mcp_tool.mcp_toolset'
Nevertheless in all the documentations I've found I see the import being done like this:
from google.adk.tools.mcp_tool.mcp_toolset import ( MCPToolset, SseServerParams, )
Does anyone know what I miss here? Here is the code:
`import asyncio
import json
from typing import Any
from dotenv import load_dotenv
from google.adk.agents.llm_agent import LlmAgent
from google.adk.artifacts.in_memory_artifact_service import (
InMemoryArtifactService, # Optional
)
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools.mcp_tool.mcp_toolset import (
MCPToolset,
SseServerParams,
)
from google.genai import types
from rich import print
load_dotenv()
async def get_tools_async():
"""Gets tools from the File System MCP Server."""
tools, exit_stack = await MCPToolset.from_server(
connection_params=SseServerParams(
url="http://localhost:8001/sse",
)
)
print("MCP Toolset created successfully.")
return tools, exit_stack
async def get_agent_async():
"""Creates an ADK Agent equipped with tools from the MCP Server."""
tools, exit_stack = await get_tools_async()
print(f"Fetched {len(tools)} tools from MCP server.")
Weather_planner_Agent = LlmAgent(
model="gemini-2.0-flash",
name="weather_planner_agent",
instruction=prompt.WEATHER_PLANNER_PROMPT,
tools=[
read_training_plan_tool,
write_training_plan_tool,
],
)
return Weather_planner_Agent, exit_stack
Weather_planner_Agent = get_agent_async()`
Beta Was this translation helpful? Give feedback.
All reactions