From 67e041c610f43c1ff6cc7a210e5a03928c414043 Mon Sep 17 00:00:00 2001 From: Fan Huang <117979149+1793649019@users.noreply.github.com> Date: Mon, 14 Jul 2025 18:16:52 +0000 Subject: [PATCH] fix(mcp): correct server param access and agent tool registration - Use getattr() instead of .get() for accessing server.params attributes - Fix tool registration logic to properly add tools to Agent --- src/cai/repl/commands/mcp.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cai/repl/commands/mcp.py b/src/cai/repl/commands/mcp.py index 57059ba1..a2dc6884 100644 --- a/src/cai/repl/commands/mcp.py +++ b/src/cai/repl/commands/mcp.py @@ -116,11 +116,11 @@ class GlobalMCPUtil(MCPUtil): elif isinstance(server, MCPServerStdio): server_config["command"] = server.params.command server_config["args"] = server.params.args - server_config["env"] = server.params.get("env") - server_config["cwd"] = server.params.get("cwd") - server_config["encoding"] = server.params.get("encoding", "utf-8") - server_config["encoding_error_handler"] = server.params.get( - "encoding_error_handler", "strict" + server_config["env"] = getattr(server.params, "env") + server_config["cwd"] = getattr(server.params, "cwd") + server_config["encoding"] = getattr(server.params, "encoding", "utf-8") + server_config["encoding_error_handler"] = getattr( + server.params, "encoding_error_handler", "strict" ) # Create a custom invoke function that creates a new connection each time @@ -810,9 +810,9 @@ Example: `/mcp add burp 13` # Get the agent try: - agent = get_agent_by_name(agent_identifier) + agent = get_available_agents()[agent_identifier] agent_display_name = getattr(agent, "name", agent_identifier) - except ValueError: + except KeyError: # Try by index try: agents = get_available_agents()