Urgent.News

650+ sources. One page. See who else covered it.

Editions

Tech

How I Cut MCP Token Usage by 91% (and Learned a Humbling Lesson About Tokenizers)

The Problem When you add MCP servers to your AI coding agent, each one dumps its full JSON schema into context. 255 tools across all servers = 39,964 tokens. On a 128K context window, that's 31% gone before you type a single character. I was literally paying for JSON syntax overhead. Every API call included {"content":[{"type":"text","text":"..."}]} — 80 tokens to deliver 6 tokens of data. The…

MCP servers add their entire JSON schema to context when included in an AI coding agent. This can consume a significant portion of the context window, costing valuable token space. The author built a tool called mcptoon to address this issue. Mcptoon works in three ways:

1. It compresses the JSON schema into a more compact format, reducing token usage by 91%. The original JSON schema for 255 tools used 39,964 tokens, but mcptoon compresses this down to just 3,511 tokens.

2. Schemas are stored on disk in a config file, allowing the agent to discover available tools and execute them without context. The compressed output enters context only when needed.

3. Results are returned in a human-readable key-value format (TOON) instead of nested JSON, saving even more token space. For example, instead of receiving a large JSON response, the agent gets a concise string like "name: react stars: 219000".

The author learned a valuable lesson about the importance of token optimization. An early attempt to replace null values with the empty set symbol (∅) actually increased the token count, demonstrating the need for thorough testing and measurement before implementing optimizations.

The cost impact of using mcptoon is substantial. At GPT-4o pricing, without the tool, 25 requests would consume 1 million tokens, costing $5. With mcptoon, the same number of requests would only use 87,500 tokens, costing just $0.44. This translates to around $540 in monthly savings for 100 sessions.

Implementing mcptoon is straightforward. You can install it via pip, set it up with your existing MCP fetch tool, and generate a schema manifest to see what's available. After that, you can execute tools using a single command that works with any agent compatible with shell commands.

With over 3,000 lines of Python code, 309 tests, and no external dependencies, mcptoon is a lightweight solution to a common problem. The author is working on adding more MCP servers to the default configuration and plans to develop a more comprehensive quality benchmark beyond just token counts. Feedback on the SLIM format and suggestions for reducing other MCP token waste are welcome.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

X Open Sources Its Ranking and Filtering Algorithms

An anonymous reader shared this report from TechCrunch: X is significantly expanding its open source codebase, which includes the app's "For You" algorithm and its core ranking engine, and adding a…

  • X open sources core ranking and filtering algorithms on GitHub
  • For You timeline algorithm and ranking model parameters released
  • Transparency tool lets users download aggregate stats as JSON

Paywall Any API Endpoint With Two Prices: Sats or Compute

You built an API. It works. Then the scrapers show up. Not paying customers. Bots hammering your endpoint a thousand times a minute, running up your compute bill, and giving you nothing back.

  • Pay-to-Compute model protects APIs against scrapers
  • Callers pay in sats or solve compute-intensive proof-of-work
  • Server-side verification is minimal and straightforward

Bloom Filters

One-liner: A probabilistic data structure that tells you if an element is definitely not in a set, or possibly in a set — using very little memory.

  • Bloom filters quickly tell if something is definitely not in a set or maybe it is.
  • They use a big array of bits and hash functions to add and check items.
  • Bloom filters save massive memory but can give false positives.

How to build and ship an iOS app without a Mac

If you want to put an app on the App Store, Apple requires you to build and sign it with Xcode, and Xcode only runs on macOS.

  • Purchase a Mac mini for $799 as a one-time hardware investment
  • Rent cloud Macs from services like MacStadium for $20/month to $100+/month
  • Use GitHub Actions for free macOS builds in public repositories

React useLatest Hook: Read Fresh State in Async Callbacks (2026)

Here's an autosave button that lies to the user: function Editor ({ docId }: { docId : string }) { const [ text , setText ] = useState ( "" ); const [ status , setStatus ] = useState < " idle " | "…

  • React useLatest hook reads fresh state in async callbacks
  • Prevents stale closures causing outdated data issues
  • Works with setTimeout, setInterval, event listeners

More from Sunday 16 August →