Skip to content

Commit edb6cee

Browse files
committed
mcp: UTF-8-safe logging + ASCII banner (no cp1252 crash on Windows consoles)
1 parent 43501d6 commit edb6cee

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

mcp/server.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,21 @@ async def get_stealth_cdp_endpoint() -> dict:
599599

600600
def main() -> None:
601601
"""Console entry point (``tilion-mcp`` / ``python -m tilion.mcp``)."""
602+
# Windows consoles default to cp1252, so any non-latin1 glyph in a log line raises
603+
# UnicodeEncodeError and can kill the server. Force UTF-8 on the streams (JSON-RPC is
604+
# UTF-8 anyway) so no banner/log character can ever crash it. The banner itself is
605+
# kept ASCII as belt-and-suspenders.
606+
for _stream in (sys.stdout, sys.stderr):
607+
try:
608+
_stream.reconfigure(encoding="utf-8", errors="backslashreplace")
609+
except Exception:
610+
pass
602611
# Banner to STDERR only — stdout is the MCP stdio transport and must stay clean.
603612
print(
604-
"Tilion · Fortress Stealth-Browser MCP [Beta]\n"
605-
" 26 tools · local & free · hosted cloud (residential egress) coming soon\n"
606-
" docs: DOCUMENTATION.md more coming benchmarks in the README\n"
607-
" listening on stdio",
613+
"Tilion Fortress Stealth-Browser MCP [Beta]\n"
614+
" 26 tools | local & free | hosted cloud (residential egress) coming soon\n"
615+
" docs: DOCUMENTATION.md - more coming; benchmarks in the README\n"
616+
" listening on stdio...",
608617
file=sys.stderr, flush=True,
609618
)
610619
mcp.run()

0 commit comments

Comments
 (0)