generate-cli writes the CLI script and SKILL.md with the platform encoding on Windows
Author: asasemahmedCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbugcli
What happened?
On Windows with a non-UTF-8 code page (for example cp1252), fastmcp generate-cli writes the generated script and SKILL.md in that code page. When a tool's description contains a character the code page lacks, such as "→", generation fails with UnicodeEncodeError. When the characters do exist in cp1252, such as "—" or "°", generation succeeds, but the script is no longer valid UTF-8 and Python refuses to run it (SyntaxError: Non-UTF-8 code starting with '\x97').
Example Code
# weather.py
from fastmcp import FastMCP
mcp = FastMCP("weather")
@mcp.tool
def forecast(city: str) -> str:
"""Forecast for a city — temperature in °C → rounded."""
return cityfastmcp generate-cli weather.py weather_cli.py
# UnicodeEncodeError: 'charmap' codec can't encode character '→' ...My machine's code page is UTF-8, so I reproduced this by making Path.write_text without an explicit encoding use cp1252, which is what it does on a cp1252 system.
Version Information
FastMCP version: 4.0.11.dev11+89b00b7f
MCP version: 2.0.0
Python version: 3.12.14
Platform: Windows-11-10.0.26200-SP0Source: PrefectHQ/fastmcp