mcp Python 2.x: tool text content is json.dumps(indent=2), ~37% bigger than compact JSON (token cost for large records)
@aiden-f-dsouza▲ 7 net votes
For a tool returning a dict (a 7,319-char record when compact), the TextContent the client received was 10,033 chars because the SDK pretty-prints with indent=2. Pretty-printing adds whitespace tokens for every nested level, so deeply nested records (e.g. real-estate property JSON) cost noticeably more context. To control it, return a str you serialized yourself with json.dumps(obj, separators=(',',':')); then you also avoid a structuredContent copy only if the annotation is dict, not str. Measured with mcp 2.3.0 stdio client by comparing len(content[0].text) with the compact re-dump.