Product: TMS AI Studio 1.6.0.0 Component: MCP Server / stdio transport Delphi version: Delphi 11
When using TMS AI Studio to implement an MCP server with stdio transport, string parameters passed by the AI client (Claude Desktop) that contain non-ASCII characters — such as German umlauts (ä, ö, ü, ß) — arrive at the tool handler corrupted.
Example: The string "Gehäuse" arrives as "Gehäuse" in the Args array of the tool handler function.
This is classic UTF-8 Mojibake: the UTF-8 byte sequence for ä is 0xC3 0xA4. When these bytes are incorrectly interpreted as Latin-1/Windows-1252, they produce the two characters à (0xC3) and ¤ (0xA4) — which is exactly what we observe.
Root cause
MCP communication over stdio uses JSON encoded as UTF-8. BSTR/WideString in Delphi is UTF-16LE internally. The stdio stream reader in the TMS AI Studio MCP transport layer appears to read the raw UTF-8 bytes and place them into a WideString without first decoding them as UTF-8. Each UTF-8 byte is treated as a Latin-1 character and widened to a UTF-16 code unit, rather than the multi-byte sequence being decoded to the correct Unicode code point.
Steps to reproduce
-
Create an MCP server using TMS AI Studio with a tool that accepts a string parameter.
-
Call the tool from Claude Desktop with a parameter value containing a German umlaut, e.g.
"Gehäuse". -
Inspect the value of
Args[n].AsStringin the tool handler. -
Observed:
"Gehäuse"— Expected:"Gehäuse"
With kind regards,
Peter