CLI tool to inspect MCP servers and analyze context token costs
mcp-inspector
A CLI tool to inspect MCP (Model Context Protocol) servers and analyze their context token costs.
MCP servers add tools to your AI assistant, but each tool definition consumes context tokens. This tool helps you understand the "weight" of your MCP servers so you can optimize your setup and avoid context bloat.
Installation
npm install -g mcp-inspector
Or run directly with npx:
npx mcp-inspector
Usage
Inspect a Single Server
Inspect any MCP server by providing its command:
# Inspect the filesystem server
mcp-inspector inspect npx -y @modelcontextprotocol/server-filesystem /tmp
# Inspect a local server
mcp-inspector inspect node ./my-server.js
# Inspect with custom timeout
mcp-inspector inspect --timeout 60000 npx -y @modelcontextprotocol/server-postgres
# Get JSON output
mcp-inspector inspect --json npx -y @modelcontextprotocol/server-filesystem /tmp
Scan Your MCP Config
Scan all servers configured in your Claude Desktop or Cline config:
# Auto-detect config file
mcp-inspector scan
# Specify config file
mcp-inspector scan --config ~/.config/claude/claude_desktop_config.json
# JSON output
mcp-inspector scan --json
Help
mcp-inspector --help
mcp-inspector help-config
Output
The tool shows:
- Server info: Name and version
- Summary: Number of tools, resources, and prompts
- Context cost: Estimated tokens for each component
- Tools breakdown: Each tool with its token cost, sorted by weight
- Recommendations: Suggestions when context cost is high
Example Output
Server Info
--------------------------------------------------
Name: filesystem
Version: 1.0.0
Summary
--------------------------------------------------
Tools: 5
Resources: 0
Prompts: 0
Context Cost (estimated tokens)
--------------------------------------------------
Tools: 842
Resources: 0
Prompts: 0
--------------------
Total: 842
Tools
--------------------------------------------------
read_file - 215 tokens
Read the complete contents of a file from the file system
write_file - 198 tokens
Create a new file or overwrite an existing file with new content
list_directory - 156 tokens
Get a detailed listing of all files and directories in a specified path
create_directory - 142 tokens
Create a new directory or ensure a directory exists
delete_file - 131 tokens
Remove a file from the file system
Config Scan Output
Found 3 MCP server(s)
[filesystem]
Command: npx -y @modelcontextprotocol/server-filesystem /tmp
Tools: 5, Resources: 0, Tokens: 842
[postgres]
Command: npx -y @modelcontextprotocol/server-postgres
Tools: 3, Resources: 0, Tokens: 1.2k
[github]
Command: npx -y @modelcontextprotocol/server-github
Tools: 12, Resources: 0, Tokens: 2.4k
Total Context Cost
--------------------------------------------------
github 2.4k (54%) ████████████
postgres 1.2k (27%) ██████
filesystem 842 (19%) ████
---------------------------------------------
TOTAL 4.4k
Warning: High total context cost!
Consider disabling unused servers or using ENABLE_TOOL_SEARCH=true
Why This Matters
Every MCP tool you add to Claude or other AI assistants consumes context tokens. This happens before your conversation even starts. If you have multiple servers with many tools, you might be burning thousands of tokens on tool definitions alone.
Common symptoms of context bloat:
- Shorter effective conversations
- Higher API costs
- Model forgetting earlier context
Use mcp-inspector to:
- Identify which servers are the heaviest
- Decide which tools you actually need
- Optimize your MCP configuration
Tips for Reducing Context Cost
- Disable unused servers: If you don't use a server often, disable it
- Use ENABLE_TOOL_SEARCH=true: Claude can search tools instead of loading all definitions upfront
- Choose lightweight servers: Some servers expose fewer, more focused tools
- Build custom servers: Create servers with only the tools you need
Config File Locations
- Claude Desktop (macOS):
~/Library/Application Support/Claude/claude_desktop_config.json - Claude Desktop (Linux):
~/.config/claude/claude_desktop_config.json - Cline (VS Code):
~/.cline/mcp_settings.json
License
MIT