From f384793649999e89b3eba9f79832e8fe273a81f5 Mon Sep 17 00:00:00 2001 From: "Xiang (Sean) Zhou" Date: Fri, 16 May 2025 09:10:10 -0700 Subject: [PATCH] fix: fix mcp agent filter logic PiperOrigin-RevId: 759638254 --- contributing/samples/mcp_agent/agent.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/contributing/samples/mcp_agent/agent.py b/contributing/samples/mcp_agent/agent.py index 6f8dcca..660c98c 100755 --- a/contributing/samples/mcp_agent/agent.py +++ b/contributing/samples/mcp_agent/agent.py @@ -34,11 +34,22 @@ root_agent = LlmAgent( ], ), # don't want agent to do write operation + # you can also do below + # tool_filter=lambda tool, ctx=None: tool.name + # not in [ + # 'write_file', + # 'edit_file', + # 'create_directory', + # 'move_file', + # ], tool_filter=[ - 'write_file', - 'edit_file', - 'create_directory', - 'move_file', + 'read_file', + 'read_multiple_files', + 'list_directory', + 'directory_tree', + 'search_files', + 'get_file_info', + 'list_allowed_directories', ], ) ],