@@ -310,9 +310,11 @@ def get_announcements(self):
310310 else :
311311 lines .append ("Repo-map: disabled" )
312312
313- if self .mcp_servers :
314- server_names = [server .name for server in self .mcp_servers ]
315- lines .append (f"MCP servers configured: { ', ' .join (server_names )} " )
313+ if self .mcp_tools :
314+ mcp_servers = []
315+ for server_name , server_tools in self .mcp_tools :
316+ mcp_servers .append (server_name )
317+ lines .append (f"MCP servers configured: { ', ' .join (mcp_servers )} " )
316318
317319 for fname in self .abs_read_only_stubs_fnames :
318320 rel_fname = self .get_rel_fname (fname )
@@ -2101,12 +2103,45 @@ async def process_tool_calls(self, tool_call_response):
21012103
21022104 def _print_tool_call_info (self , server_tool_calls ):
21032105 """Print information about an MCP tool call."""
2104- self .io .tool_output ("Preparing to run MCP tools" , bold = True )
2106+ self .io .tool_output ("Preparing to run MCP tools" , bold = False )
21052107
21062108 for server , tool_calls in server_tool_calls .items ():
21072109 for tool_call in tool_calls :
21082110 self .io .tool_output (f"Tool Call: { tool_call .function .name } " )
2109- self .io .tool_output (f"Arguments: { tool_call .function .arguments } " )
2111+
2112+ # Parse and format arguments as headers with values
2113+ if tool_call .function .arguments :
2114+ # Only do JSON unwrapping for tools containing "replace" in their name
2115+ if "replace" in tool_call .function .name .lower ():
2116+ try :
2117+ args_dict = json .loads (tool_call .function .arguments )
2118+ first_key = True
2119+ for key , value in args_dict .items ():
2120+ # Convert explicit \\n sequences to actual newlines using regex
2121+ # Only match \\n that is not preceded by any other backslashes
2122+ if isinstance (value , str ):
2123+ value = re .sub (r"(?<!\\)\\n" , "\n " , value )
2124+ # Add extra newline before first key/header
2125+ if first_key :
2126+ self .io .tool_output ("\n " )
2127+ first_key = False
2128+ self .io .tool_output (f"{ key } :" )
2129+ # Split the value by newlines and output each line separately
2130+ if isinstance (value , str ):
2131+ for line in value .split ("\n " ):
2132+ self .io .tool_output (f"{ line } " )
2133+ else :
2134+ self .io .tool_output (f"{ str (value )} " )
2135+ self .io .tool_output ("" )
2136+ except json .JSONDecodeError :
2137+ # If JSON parsing fails, show raw arguments
2138+ raw_args = tool_call .function .arguments
2139+ self .io .tool_output (f"Arguments: { raw_args } " )
2140+ else :
2141+ # For non-replace tools, show raw arguments
2142+ raw_args = tool_call .function .arguments
2143+ self .io .tool_output (f"Arguments: { raw_args } " )
2144+
21102145 self .io .tool_output (f"MCP Server: { server .name } " )
21112146
21122147 if self .verbose :
@@ -2343,11 +2378,12 @@ async def get_all_server_tools():
23432378 tools = []
23442379
23452380 if len (tools ) > 0 :
2346- self .io .tool_output ("MCP servers configured:" )
2347- for server_name , server_tools in tools :
2348- self .io .tool_output (f" - { server_name } " )
2381+ if self .verbose :
2382+ self .io .tool_output ("MCP servers configured:" )
2383+
2384+ for server_name , server_tools in tools :
2385+ self .io .tool_output (f" - { server_name } " )
23492386
2350- if self .verbose :
23512387 for tool in server_tools :
23522388 tool_name = tool .get ("function" , {}).get ("name" , "unknown" )
23532389 tool_desc = tool .get ("function" , {}).get ("description" , "" ).split ("\n " )[0 ]
0 commit comments