[BUG] color ansi codes were not rendered properly when running `claude mcp` command
Environment
- Platform (select one):
- [x] Anthropic API
- Claude CLI version: 0.2.41
- Operating System: Debian GNU/Linux testing/sid kenrel 6.12.22-amd64
- Terminal: A terminal emulator for the GNOME desktop Using VTE version 0.80.0 +BIDI +GNUTLS +ICU +SYSTEMD
Bug Description
Seemed to render them fine in prior (internal) commands (I am new, just trying out) and then all of a sudden:
> claude mcp
⎿ [38;5;246mManaged Claude Programs let you customize Claude with your own Python code.[39m
[38;5;246mYou can configure one or more MCP servers in ~/.config/claude/config.yaml:[39m
[1mDefault configuration (recommended)[0m
[38;5;4mmcps:[39m
[38;5;4mdefault: # Use any name instead of 'default'[39m
[38;5;4mtype: openai_proxy[39m
[38;5;4mbase_url: http://localhost:1234/v1[39m
[38;5;4mapi_key: claude-code-mcp[39m [38;5;246m# Can be any string[39m
[1mAdvanced configuration (using OpenAI API server)[0m
[38;5;4mmcps:[39m
[38;5;4mopenai: # Use any name instead of 'openai'[39m
[38;5;4mtype: openai[39m
[38;5;4mapi_key: ... # Your OpenAI API key[39m
[38;5;4mmodel: gpt-4o[39m
[38;5;4mbase_url: https://api.openai.com/v1[39m [38;5;246m# Optional, defaults to OpenAI[39m
[1mSupported types[0m
[38;5;4mtype: openai_proxy[39m [38;5;246m# Local proxy server configured to handle OpenAI-formatted requests[39m
[38;5;4mtype: openai[39m [38;5;246m# OpenAI API server or compatible provider[39m
[1mLearn more[0m
[1;4mhttps://github.com/anthropics/anthropic-cookbook/tree/main/ai-agents/claude-code-interpreter[0m
[1;4mhttps://docs.anthropic.com/claude/docs/managed-claude-programs[0m
screenshot with prior interactions
Steps to Reproduce
-
claude mcp
Expected Behavior
get them rendered
Actual Behavior
they are not
See #4946 as well this is also afffecing /agents and / commands
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Still experiencing this in December 2025. ANSI escape codes from MCP server tool output are displayed as raw text (e.g., [38;5;246m) instead of being rendered as colors.
This affects custom MCP servers that use chalk/ANSI for styled output - the colors work fine when running the MCP server directly in terminal, but get stripped/broken when called through Claude Code.
Would appreciate a fix or at least a config flag to enable ANSI rendering in MCP output.
Update (Dec 28, 2025): After more testing, ANSI escape codes do work in MCP tool output!
What I found:
- ✅ 256-color codes ([38;5;xxxm) render correctly
- ✅ True color/RGB ([48;2;r;g;bm) works
- ✅ Bold, italic, underline, strikethrough
- ✅ Background colors
The issue might have been:
- Using chalk without forcing color level (chalk.level = 3)
- MCP stdio not being detected as TTY (need process.env.FORCE_COLOR = '3')
Fix for MCP servers using chalk: // Add BEFORE importing chalk process.env.FORCE_COLOR = '3'; import chalk from 'chalk'; chalk.level = 3;
This forces chalk to output colors even when stdio isn't a TTY. Works perfectly with Claude Code now.