chore: Refines mcp_agent instruction to include the allowed folder in the instruction.

PiperOrigin-RevId: 760057162
This commit is contained in:
Wei Sun (Jack) 2025-05-17 12:56:32 -07:00 committed by Copybara-Service
parent 9324801b75
commit e278ca9541

View File

@ -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 MCPToolset
from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters
_allowed_path = os.path.dirname(os.path.abspath(__file__))
root_agent = LlmAgent( root_agent = LlmAgent(
model='gemini-2.0-flash', model='gemini-2.0-flash',
name='enterprise_assistant', name='enterprise_assistant',
instruction='Help user accessing their file systems', instruction=f"""\
Help user accessing their file systems.
Allowed directory: {_allowed_path}
""",
tools=[ tools=[
MCPToolset( MCPToolset(
connection_params=StdioServerParameters( connection_params=StdioServerParameters(
@ -30,7 +36,7 @@ root_agent = LlmAgent(
args=[ args=[
'-y', # Arguments for the command '-y', # Arguments for the command
'@modelcontextprotocol/server-filesystem', '@modelcontextprotocol/server-filesystem',
os.path.dirname(os.path.abspath(__file__)), _allowed_path,
], ],
), ),
# don't want agent to do write operation # don't want agent to do write operation