From e278ca954161a1eb42c85fdc9ce9217542930502 Mon Sep 17 00:00:00 2001 From: "Wei Sun (Jack)" Date: Sat, 17 May 2025 12:56:32 -0700 Subject: [PATCH] chore: Refines mcp_agent instruction to include the allowed folder in the instruction. PiperOrigin-RevId: 760057162 --- contributing/samples/mcp_agent/agent.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contributing/samples/mcp_agent/agent.py b/contributing/samples/mcp_agent/agent.py index 660c98c..a14ab43 100755 --- a/contributing/samples/mcp_agent/agent.py +++ b/contributing/samples/mcp_agent/agent.py @@ -19,10 +19,16 @@ from google.adk.agents.llm_agent import LlmAgent from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters +_allowed_path = os.path.dirname(os.path.abspath(__file__)) + root_agent = LlmAgent( model='gemini-2.0-flash', name='enterprise_assistant', - instruction='Help user accessing their file systems', + instruction=f"""\ +Help user accessing their file systems. + +Allowed directory: {_allowed_path} + """, tools=[ MCPToolset( connection_params=StdioServerParameters( @@ -30,7 +36,7 @@ root_agent = LlmAgent( args=[ '-y', # Arguments for the command '@modelcontextprotocol/server-filesystem', - os.path.dirname(os.path.abspath(__file__)), + _allowed_path, ], ), # don't want agent to do write operation