Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dippy/dippy_statusline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions tests/test_statusline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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."""

Expand Down