feat: add server_log_path() for in-app MCP log viewer (#6)
This commit is contained in:
+20
-1
@@ -474,7 +474,7 @@ def _normalize_unicode(text: str, notes: list[str]) -> str:
|
|||||||
out = text
|
out = text
|
||||||
for junk in _JUNK_CHARS:
|
for junk in _JUNK_CHARS:
|
||||||
out = out.replace(junk, "")
|
out = out.replace(junk, "")
|
||||||
out = out.replace(" ", " ") # non-breaking space
|
out = out.replace(" ", " ") # non-breaking space
|
||||||
for smart, ascii_q in _QUOTE_MAP.items():
|
for smart, ascii_q in _QUOTE_MAP.items():
|
||||||
out = out.replace(smart, ascii_q)
|
out = out.replace(smart, ascii_q)
|
||||||
if out != text:
|
if out != text:
|
||||||
@@ -1270,6 +1270,25 @@ def diagnostics_text(name: str, data: dict) -> str:
|
|||||||
return "\n".join(L)
|
return "\n".join(L)
|
||||||
|
|
||||||
|
|
||||||
|
def server_log_path(name: str) -> Path | None:
|
||||||
|
"""
|
||||||
|
The platform-specific Claude Desktop MCP server log file for `name`, or
|
||||||
|
None if it doesn't exist yet (nothing has been logged for this server).
|
||||||
|
|
||||||
|
macOS : ~/Library/Logs/Claude/mcp-server-<name>.log (one file per server)
|
||||||
|
Windows: %APPDATA%\\Claude\\logs\\mcp.log (one shared file)
|
||||||
|
Other platforms: Claude Desktop doesn't ship a log in a known location -> None.
|
||||||
|
"""
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
p = Path.home() / "Library" / "Logs" / "Claude" / f"mcp-server-{name}.log"
|
||||||
|
elif sys.platform.startswith("win"):
|
||||||
|
appdata = Path(os.environ.get("APPDATA", Path.home() / "AppData" / "Roaming"))
|
||||||
|
p = appdata / "Claude" / "logs" / "mcp.log"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return p if p.is_file() else None
|
||||||
|
|
||||||
|
|
||||||
_STDERR_CAP = 4096 # bytes
|
_STDERR_CAP = 4096 # bytes
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user