mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-04-25 21:22:40 +00:00
* fix: exclude disabled MCP servers from count Fixes #3 - MCP count was showing all servers regardless of enabled/disabled state. ## Root Cause The HUD was counting all MCP server keys from config files without checking if they were in the disabled lists: - `disabledMcpServers` in `~/.claude.json` (user-scope) - `disabledMcpjsonServers` in `settings.local.json` (project .mcp.json) ## Changes - Add `getDisabledMcpServers()` function to read disabled arrays - Add `DisabledMcpKey` union type for compile-time safety - Filter disabled servers when counting MCPs - Add debug logging (enable via `DEBUG=claude-hud`) - Add 8 new tests including Issue #3 regression test ## Test Coverage - User-scope disabled filtering - Project .mcp.json disabled filtering - All MCPs disabled → 0 - Non-string values in disabled arrays (ignored) - Cross-scope duplicate counting behavior - Case-sensitive server name matching - Issue #3 exact scenario (6 MCPs, disable progressively) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: extract debug logging into shared helper module Per PR feedback, consolidate duplicate debug logging code from config-reader.ts and usage-api.ts into a shared debug.ts helper. - Add src/debug.ts with createDebug() factory function - Update config-reader.ts to use createDebug('config') - Update usage-api.ts to use createDebug('usage') - Same functionality, better DRY compliance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: melon-hub <melon-hub@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
17 lines
486 B
TypeScript
17 lines
486 B
TypeScript
// Shared debug logging utility
|
|
// Enable via: DEBUG=claude-hud or DEBUG=*
|
|
|
|
const DEBUG = process.env.DEBUG?.includes('claude-hud') || process.env.DEBUG === '*';
|
|
|
|
/**
|
|
* Create a namespaced debug logger
|
|
* @param namespace - Tag for log messages (e.g., 'config', 'usage')
|
|
*/
|
|
export function createDebug(namespace: string) {
|
|
return function debug(msg: string, ...args: unknown[]): void {
|
|
if (DEBUG) {
|
|
console.error(`[claude-hud:${namespace}] ${msg}`, ...args);
|
|
}
|
|
};
|
|
}
|