nerve
nerve copied to clipboard
feat: respect --quiet flag in MCP client logging
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:
- Parse quiet flag: Check for
--quietin MCP server args during client initialization - Selective suppression: In quiet mode, suppress INFO/DEBUG logs but still show ERROR/WARNING
- Proper log levels: Parse nerve-style log formats and map to appropriate logger levels
- Preserve errors: Important error information is still visible even in quiet mode
Changes
- Added
_is_quietproperty toClientclass that checks for--quietin server args - Modified
_logging_callbackto 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
--quietis 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