nerve icon indicating copy to clipboard operation
nerve copied to clipboard

feat: respect --quiet flag in MCP client logging

Open nickpending opened this issue 7 months ago • 0 comments

Respect --quiet flag in MCP client logging

Problem

When orchestrating multiple agents using MCP (Model Context Protocol), the current implementation logs all MCP server output as ERROR level, creating very verbose and confusing output. This makes it difficult to understand the high-level orchestration flow.

Before:

[05-29-25 10:35:00] ERROR <discovery_planner> [05-29-25 10:35:00] INFO 🧠 nerve v1.7.0
[05-29-25 10:35:00] ERROR <discovery_planner> [05-29-25 10:35:00] INFO 🔍 tracing to /Users/...
[05-29-25 10:35:00] ERROR <discovery_planner> [05-29-25 10:35:00] INFO 🤖 anthropic/claude...
[05-29-25 10:35:00] ERROR <discovery_planner> [05-29-25 10:35:00] INFO 🚀 max steps: 3...
[05-29-25 10:35:00] ERROR <discovery_planner> 1. Context: draw.io is a web application
[05-29-25 10:35:00] ERROR <discovery_planner> 2. Port 443 indicates HTTPS service
...hundreds of lines of tool output...

After:

[05-29-25 11:30:55] INFO 🧠 nerve v1.7.0
[05-29-25 11:30:55] INFO 🤖 anthropic/claude-3-5-sonnet-20241022 | orchestrator v1.0.0 with 3 tools
[05-29-25 11:30:57] INFO 🛠️  discovery_planner(draw.io:443)
[05-29-25 11:31:11] INFO  ↳ discovery_planner -> <class 'str'> (2175 bytes) in 13.7s
[05-29-25 11:31:17] INFO 🛠️  command_generator(draw.io:443, {...})
[05-29-25 11:31:25] INFO  ↳ command_generator -> <class 'str'> (178 bytes) in 8.9s

Solution

This PR implements proper --quiet flag support in the MCP client:

  1. Parse quiet flag: Check for --quiet in MCP server args during client initialization
  2. Selective suppression: In quiet mode, suppress INFO/DEBUG logs but still show ERROR/WARNING
  3. Proper log levels: Parse nerve-style log formats and map to appropriate logger levels
  4. Preserve errors: Important error information is still visible even in quiet mode

Changes

  • Added _is_quiet property to Client class that checks for --quiet in server args
  • Modified _logging_callback to respect quiet mode:
    • Suppresses informational logs and tool output when quiet
    • Still shows errors and warnings in quiet mode
    • Parses nerve log format patterns for proper log level mapping

Use Case

This is particularly useful when orchestrating multiple agents:

mcp:
  discovery_planner:
    command: nerve
    args: ["serve", "discovery-planner", "--mcp", "--max-steps", "3", "--quiet"]
    
  command_generator:
    command: nerve
    args: ["serve", "command-generator", "--mcp", "--max-steps", "3", "--quiet"]

The orchestrator now shows clean, high-level progress without being overwhelmed by internal MCP server details.

Backward Compatibility

  • Fully backward compatible - existing behavior unchanged when --quiet is not used
  • Only affects MCP client logging behavior
  • No breaking changes to APIs or interfaces

Testing

Tested with multi-agent orchestration scenarios using both quiet and verbose modes. Confirms that:

  • Quiet mode produces clean orchestrator output
  • Error and warning logs still appear in quiet mode
  • Normal (non-quiet) mode behavior is unchanged

nickpending avatar May 29 '25 18:05 nickpending