[BUG] Incorrect token counts per MCP tool
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
/context reports incorrect token count for MCP tool. The number comes from the from
https://api.anthropic.com/v1/messages/count_tokens?beta=true
API call.
CC reports cca 600 tokens per MCP tool. I have extracted tool definition from the system prompt and it amounts around 130 tokens (600 chars).
If I disable the MCP (has multiple tools), the total amount of tokens used reported by /context command matches my calculation and not sum of all MCP tools reported by CC.
What Should Happen?
Fix token count for MCP tools.
Error Messages/Logs
Steps to Reproduce
Trivial check: Run /context with MCP tools. Check total token count. Disable MCPs and run /context again. Sum of all tool tokens reported does not match of context size reductions.
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.75
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗