-
Notifications
You must be signed in to change notification settings - Fork 0
Replace global MCP_MODE with struct-based config propagation #28
Copy link
Copy link
Closed
Labels
area/mcpMCP server, tool definitionsMCP server, tool definitionstype/refactorCode improvement without behavior changeCode improvement without behavior change
Milestone
Description
Source: Code quality review 2026-03-31 (Score: 52/100)
Category: Rust Code Quality (10/20)
Priority: 4/5
Problem
// mcp.rs:8
static MCP_MODE: AtomicBool = AtomicBool::new(false);is_mcp_mode() is referenced across search.rs, lib.rs, candidates.rs, and mcp_tools.rs to suppress stderr output. Global mutable state hurts testability and blocks future multi-instance support (searching multiple repos in one process).
Proposed Solution
Add a config field to Xgrep struct:
pub struct Xgrep {
root: PathBuf,
index_path: PathBuf,
config: Config,
}
pub struct Config {
pub quiet: bool, // suppresses stderr warnings
}Replace all is_mcp_mode() calls with self.config.quiet checks. MCP server sets quiet: true when constructing Xgrep.
Why Now
Small refactor now prevents entrenching the global state pattern as more features are added.
Estimated effort: 1-2 hours
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/mcpMCP server, tool definitionsMCP server, tool definitionstype/refactorCode improvement without behavior changeCode improvement without behavior change