The Billion-Token Problem
Modern large language models like Anthropic's Claude 3 boast massive context windows, allowing developers to feed them entire codebases for analysis and generation. While powerful, this capability comes at a steep price. Sending hundreds of thousands of tokens with every request is not only slow but also prohibitively expensive, creating a significant barrier to leveraging these models for large-scale, iterative software development.
Enter the Master Control Program
Enter the Master Control Program (MCP), an ingenious open-source solution created by developer Maciej Skorski. In a recent blog post that gained significant attention, Skorski detailed his creation: a local server that acts as an intelligent proxy between a developer's editor and the AI model. The result? A staggering reduction in context consumption—up to 98% in his tests—translating directly into massive cost savings and speed improvements.
The core idea behind MCP is to stop treating the LLM as a stateless endpoint. Instead of re-sending the entire project context with every single prompt, the MCP server maintains the state of the files locally. It then communicates with the AI using a compact, command-based language.
How It Works: Diffs, Not Dumps
The magic lies in how MCP handles context. When a developer prompts the AI, the MCP server intercepts the request. Instead of blindly forwarding huge files, it uses a few key commands:
@<file_path>: This command references a file without including its full content in the prompt sent to the LLM. The server intelligently manages what the LLM needs to 'see' from these files.!diff: This is the system's cornerstone. On subsequent interactions, instead of resending an entire file that has been modified, the server calculates adiff—a summary of just the changes—and sends only that tiny patch to the model. This is conceptually similar to how version control systems like Git track changes, and it's incredibly token-efficient.!edit: When the AI suggests a code change, it doesn't send back the entire modified file. Instead, it can respond with a structured!editcommand that the MCP server parses and applies directly to the local file. This creates a tight, efficient feedback loop.
A response from the model might look something like this:
I see the issue in `main.py`. Here is the fix:
!edit app/main.py
<<<<<<<
# old buggy code
=======
# new corrected code
>>>>>>>
The MCP server receives this, finds the old buggy code block in app/main.py, and replaces it with the , completing the operation with minimal data transfer.