Skip to content

Commit 62148fc

Browse files
refactor: update MCP examples to use StdioConnectionParams (#457)
* refactor: swap to StdioConnectionParams - Fix import path to avoid ImportError - Changed from StdioServerParameters to StdioConnectionParams as recommended. * fix: Re-modify imports for MCP config libraries --------- Co-authored-by: Joe Fernandez <[email protected]>
1 parent dd215e6 commit 62148fc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/tools/mcp-tools.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ Create an `agent.py` file (e.g., in `./adk_agent_samples/mcp_agent/agent.py`). T
5959
# ./adk_agent_samples/mcp_agent/agent.py
6060
import os # Required for path operations
6161
from google.adk.agents import LlmAgent
62-
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioConnectionParams, StdioServerParameters
62+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
63+
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
64+
from mcp import StdioServerParameters
6365

6466
# It's good practice to define paths dynamically if possible,
6567
# or ensure the user understands the need for an ABSOLUTE path.
@@ -261,7 +263,9 @@ Modify your `agent.py` file (e.g., in `./adk_agent_samples/mcp_agent/agent.py`).
261263
# ./adk_agent_samples/mcp_agent/agent.py
262264
import os
263265
from google.adk.agents import LlmAgent
264-
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioConnectionParams, StdioServerParameters
266+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
267+
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
268+
from mcp import StdioServerParameters
265269

266270
# Retrieve the API key from an environment variable or directly insert it.
267271
# Using an environment variable is generally safer.
@@ -605,7 +609,9 @@ Create an `agent.py` (e.g., in `./adk_agent_samples/mcp_client_agent/agent.py`):
605609
# ./adk_agent_samples/mcp_client_agent/agent.py
606610
import os
607611
from google.adk.agents import LlmAgent
608-
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioConnectionParams, StdioServerParameters
612+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
613+
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
614+
from mcp import StdioServerParameters
609615
610616
# IMPORTANT: Replace this with the ABSOLUTE path to your my_adk_mcp_server.py script
611617
PATH_TO_YOUR_MCP_SERVER_SCRIPT = "/path/to/your/my_adk_mcp_server.py" # <<< REPLACE
@@ -693,7 +699,9 @@ from google.adk.agents.llm_agent import LlmAgent
693699
from google.adk.runners import Runner
694700
from google.adk.sessions import InMemorySessionService
695701
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService # Optional
696-
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseConnectionParams, StdioConnectionParams, StdioServerParameters
702+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
703+
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
704+
from mcp import StdioServerParameters
697705
698706
# Load environment variables from .env file in the parent directory
699707
# Place this near the top, before using env vars like API keys

0 commit comments

Comments
 (0)