diff --git a/src/dippy/dippy_statusline.py b/src/dippy/dippy_statusline.py index fcde69b..2b1d41f 100755 --- a/src/dippy/dippy_statusline.py +++ b/src/dippy/dippy_statusline.py @@ -227,7 +227,7 @@ def get_mcp_servers() -> str | None: mtime = os.path.getmtime(MCP_CACHE_PATH) age = time.time() - mtime with open(MCP_CACHE_PATH) as f: - cached = f.read().strip() + cached = f.read().strip().replace("claude.ai ", "") log.debug("mcp_cache_read", age=age, has_cached=bool(cached)) except FileNotFoundError: log.debug("mcp_cache_not_found", path=MCP_CACHE_PATH) @@ -242,7 +242,7 @@ def get_mcp_servers() -> str | None: os.makedirs(CACHE_DIR, exist_ok=True) tmp = f"{MCP_CACHE_PATH}.tmp.{os.getpid()}" disc_r, disc_g, disc_b = hex_to_rgb(MOLOKAI[STYLES["mcp_disconnected"][0]]) - cmd = f'timeout 10 claude mcp list 2>/dev/null | awk -F: \'NF>1 {{if (/Connected/) print "\\033[38;2;{conn_r};{conn_g};{conn_b}m" $1 "\\033[0m"; else print "\\033[38;2;{disc_r};{disc_g};{disc_b}m!" $1 "\\033[0m"}}\' | paste -sd, | sed \'s/,/, /g\' > {tmp} && mv {tmp} {MCP_CACHE_PATH}' + cmd = f'timeout 10 claude mcp list 2>/dev/null | awk -F: \'NF>1 {{if (/Connected/) print "\\033[38;2;{conn_r};{conn_g};{conn_b}m" $1 "\\033[0m"; else print "\\033[38;2;{disc_r};{disc_g};{disc_b}m!" $1 "\\033[0m"}}\' | paste -sd, | sed -e \'s/,/, /g\' -e \'s/claude\\.ai //g\' > {tmp} && mv {tmp} {MCP_CACHE_PATH}' subprocess.Popen( cmd, shell=True, diff --git a/tests/test_statusline.py b/tests/test_statusline.py index 1f213af..3ea4bf8 100644 --- a/tests/test_statusline.py +++ b/tests/test_statusline.py @@ -4,11 +4,16 @@ import json import subprocess +import sys import tempfile import uuid from pathlib import Path REPO_ROOT = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(REPO_ROOT / "src")) + +from dippy.dippy_statusline import get_mcp_servers # noqa: E402 + DIPPY_STATUSLINE = REPO_ROOT / "bin" / "dippy-statusline" SYSTEM_PYTHON = "/usr/bin/python3" @@ -168,6 +173,18 @@ def test_empty_current_dir(self): assert result.returncode == 0 +class TestMcpServerNames: + """Tests for MCP server name formatting.""" + + def test_strips_claude_ai_prefix(self): + """Server names should strip 'claude.ai ' prefix for cleaner display.""" + output = get_mcp_servers() + if output and "claude.ai " in output: + raise AssertionError( + f"MCP output contains 'claude.ai ' prefix that should be stripped: {output!r}" + ) + + class TestOutputFormat: """Tests for output format validation."""