How many tokens do your MCP tools cost? Measure any remote MCP server in ~60 lines of Python A stdlib-only Python script of roughly 60 lines can connect to any remote MCP server over Streamable HTTP, call tools/list with cursor pagination, and estimate each tool's context cost at about 4 characters of compact JSON per token, according to the post. Test runs on 2026-11-21 measured DeepWiki 4.0.2 at 3 tools and ~426 tokens, docs-ai-search 0.5.0 at 2 tools and ~433 tokens, GitMCP 1.1.0 at 5 tools and ~718 tokens, and Context7 4.7.3 at 2 tools and ~1,306 tokens, with Context7's resolve-library-id alone at 760 tokens. The script also flags tools with descriptions under 20 characters and parameters with no description, which the author says hurt tool selection more than the token budget does. How many tokens do your MCP tools cost? Measure any remote MCP server in ~60 lines of Python Every tool an MCP server exposes is shipped to the model as JSON: name, description and input schema. Most clients load the whole tools/list result at the start of each conversation, so a big or wordy catalogue quietly eats context before the user has typed anything. That cost is easy to measure fro m outside. This post is a ~60-line, stdlib-only Python script that connects to a remote MCP server the way a client does, lists its tools and estimates what they cost in tokens. It also flags tools and parameters with no description, which hurt tool selection more than they hurt the token budget. initialize, then notifications/initialized, over HTTPS POST Streamable HTTP transport . Keeps the Mcp-Session-Id header if the server issues one; stateless servers just don't send it. Handles both reply styles: plain JSON and text/event-stream SSE data: lines . Calls tools/list, following nextCursor until the list ends. Estimates tokens at ~4 characters of compact JSON per token, per tool, and prints the five most expensive. import json, sys, urllib.request def rpc url, method, params, req id, session=None : body = {"jsonrpc": "2.0", "method": method, "params": params} if req id is not None: body "id" = req id headers = {"Content-Type": "application/json", "Accept": "application/json, text/event-stream", "MCP-Protocol-Version": "2025-11-25", "User-Agent": "mcp-cost/1"} default Python UA is often blocked if session: headers "Mcp-Session-Id" = session req = urllib.request.Request url, json.dumps body .encode , headers with urllib.request.urlopen req, timeout=20 as r: sid = r.headers.get "Mcp-Session-Id" or session raw = r.read .decode if req id is None: return None, sid if "text/event-stream" in r.headers.get "Content-Type", "" : take the JSON-RPC reply out of the SSE "data:" lines for line in raw.splitlines : if line.startswith "data:" : msg = json.loads line 5: if msg.get "id" == req id: return msg, sid raise RuntimeError "no reply in event stream" return json.loads raw , sid def tools of url : init, sid = rpc url, "initialize", { "protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "mcp-cost", "version": "1"}}, 1 rpc url, "notifications/initialized", {}, None, sid tools, cursor, n = , None, 2 while True: reply, sid = rpc url, "tools/list", {"cursor": cursor} if cursor else {}, n, sid tools += reply "result" "tools" cursor = reply "result" .get "nextCursor" n += 1 if not cursor: return init "result" .get "serverInfo", {} , tools def tokens obj : rough: ~4 characters of compact JSON per token return round len json.dumps obj, separators= ",", ":" / 4 url = sys.argv 1 info, tools = tools of url rows = sorted tokens t , t "name" for t in tools , reverse=True total = sum r 0 for r in rows print f"{info.get 'name' } {info.get 'version', '' }: {len tools } tools, ~{total} tokens" for tok, name in rows :5 : print f" {tok: 6} {name}" for t in tools: props = t.get "inputSchema" or {} .get "properties", {} bare = p for p, s in props.items if not s.get "description" if len t.get "description", "" < 20: print f" {t 'name' }: description missing or very short" if bare: print f" {t 'name' }: params without description: {', '.join bare }" Run it with any remote MCP URL: python3 mcp cost.py https://mcp.deepwiki.com/mcp These are the actual results from runs on 2026-11-21 tokens are the rough 4-chars estimate, not a tokenizer count : DeepWiki 4.0.2: 3 tools, ~426 tokens 178 ask wiki question 126 read wiki structure 122 read wiki contents docs-ai-search 0.5.0: 2 tools, ~433 tokens docs.mcp.cloudflare.com/mcp 358 search cloudflare documentation 75 migrate pages to workers guide search cloudflare documentation: params without description: query GitMCP 1.1.0: 5 tools, ~718 tokens gitmcp.io/docs Context7 4.7.3: 2 tools, ~1306 tokens 760 resolve-library-id 546 query-docs siftwright 1.0.0: 9 tools, ~2004 tokens our own server 312 ats jobs 302 youtube transcript website screenshot: params without description: pdfPageFormat, delaySec app store reviews: params without description: sortBy, minRating, maxRating ats jobs: params without description: titleKeywords, excludeTitleKeywords, locations, departments, remoteOnly Two things stand out: Token cost is about description length, not tool count. Context7 has two tools and costs more than GitMCP's five, because its descriptions carry detailed usage guidance. That can be a good trade: a longer description that stops the model from calling the tool wrongly is worth a few hundred tokens. Missing parameter descriptions are common, including on our own server we'll fix ours . A parameter called delaySec or locations makes the model guess the unit or format. One short sentence per parameter costs a handful of tokens and saves failed calls. The default Python user agent gets 403s. Three of the five servers sit behind bot protection that rejects Python-urllib/3.x. Setting any honest User-Agent fixed it. Send both Accept types. Streamable HTTP servers may answer with JSON or an SSE stream; Accept: application/json, text/event-stream lets them pick. Don't skip notifications/initialized. Some servers refuse tools/list on a session that never finished the handshake. The 4-chars rule is rough. Real tokenizers differ, and clients wrap tool definitions in their own framing. Use the number to compare servers and spot outliers, not as an exact budget. Different checkers also count slightly differently for example, schema-only vs. the whole tool object . Remote servers only Streamable HTTP . A local stdio server needs a subprocess transport instead. Servers that require OAuth answer 401; the script stops there. Read the WWW-Authenticate header to find the protected-resource metadata. It never calls a tool, only initialize and tools/list. If you just want the answer for one server, the free MCP server checker runs the same handshake from a browser and also reports protocol version, session model, CORS, the auth challenge and tool annotations. No signup. If you're building agents that need web data YouTube transcripts, screenshots, Google News, contact details, tech stacks, job listings , our hosted MCP server is at https://siftwright.com/mcp; setup docs here. Key Takeaways - •This post is a ~60-line, stdlib-only Python script that connects to a remote MCP server the way a client does, lists its tools and estimates what they cost in tokens. - •This story was reported by Dev.to , covering developments in the dev space. - •AI advancements continue to reshape industries — read the full article on Dev.to for complete coverage. 📖 Continue reading the full article: Read Full Article on Dev.to → https://dev.to/siftwright/how-many-tokens-do-your-mcp-tools-cost-measure-any-remote-mcp-server-in-60-lines-of-python-5h7d