
yi-111-a/mcpweigh
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
How much of your context window are your MCP servers eating? Weigh every tool definition across Claude, Cursor, VS Code, Windsurf, Gemini, Codex, Zed & OpenCode configs.
Обзор
Every MCP server you enable ships its tool names, descriptions and JSON schemas to the model on every request. Add a browser server, a GitHub server and a couple of others and you can burn 20–40k tokens before you type a word, which costs money, slows responses and pushes out the code you actually care about. mcpweigh reads the MCP config you already have (Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, Gemini CLI, Codex CLI, Zed, OpenCode), starts each server, asks it for its tools, and tells you exactly where the tokens go, per server and per tool, with a budget check you can put in CI. - : pure Python 3.9+ standard library. Uses tiktoken (o200k_base) automatically if it is installed, otherwise a built-in estimator calibrated against it (typically within ~10%). - : stdio, Streamable HTTP (with Mcp-Session-Id), and legacy HTTP+SSE.
README
Показан фрагмент оригинального README. Открыть оригинал.
mcpweigh
How much of your context window are your MCP servers eating?
Every MCP server you enable ships its tool names, descriptions and JSON schemas to the model on every request. Add a browser server, a GitHub server and a couple of others and you can burn 20–40k tokens before you type a word, which costs money, slows responses and pushes out the code you actually care about.
mcpweigh reads the MCP config you already have (Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, Gemini CLI, Codex CLI, Zed, OpenCode), starts each server, asks it for its tools, and tells you exactly where the tokens go, per server and per tool, with a budget check you can put in CI.
- Zero dependencies: pure Python 3.9+ standard library. Uses
tiktoken(o200k_base) automatically if it is installed, otherwise a built-in estimator calibrated against it (typically within ~10%). - Every transport: stdio, Streamable HTTP (with
Mcp-Session-Id), and legacy HTTP+SSE. - Every client config: auto-discovers user and project config files, understands JSONC,
${env:VAR},${workspaceFolder}, disabled servers, and Claude Code per-project scopes. The same server configured in several clients is weighed once. - Actionable output: heaviest tools, description vs schema split, server
instructions, bloated or undocumented tools, and tool names shared by several servers. - CI friendly:
--budget 8kexits 1 when you go over;--format json|markdownfor bots and PR comments;--tools-jsonworks fully offline.
Install
pipx install git+https://github.com/Yi-111-a/mcpweigh
# exact OpenAI-style token counts (optional):
pipx inject mcpweigh tiktoken
Or run it straight from a clone: python -m mcpweigh.
Usage
mcpweigh # weigh every server in every client config it can find
mcpweigh --list # just show what was discovered (never prints env values)
mcpweigh -c .cursor/mcp.json # one config file, any supported format
mcpweigh -s github -s playwright # only these servers
mcpweigh --context 200k # show the share of a 200k-token window
mcpweigh --budget 8k # exit 1 if the total is over 8,000 tokens
# one server, no config needed
mcpweigh -- npx -y @modelcontextprotocol/server-filesystem /tmp
mcpweigh --url https://example.com/mcp -H "Authorization: Bearer $TOKEN"
mcpweigh --url http://localhost:3001/sse --sse # legacy SSE servers
# offline / CI: weigh a saved tools/list result
mcpweigh -- uvx my-server --dump snapshots/ # save raw tools/list JSON
Установка
This server does not publish a one-line install command.
Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →