惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Latest
Security Latest
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
S
SegmentFault 最新的问题
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
T
Threatpost
T
Tenable Blog
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
C
Cisco Blogs
H
Heimdal Security Blog
Attack and Defense Labs
Attack and Defense Labs
A
About on SuperTechFans
Last Week in AI
Last Week in AI
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
I
Intezer
V
V2EX
Cyberwarzone
Cyberwarzone
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog RSS Feed
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
PCI Perspectives
PCI Perspectives
P
Privacy International News Feed
D
Docker

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
MCP's Dark Secret: 5 Hidden Patterns Nobody Teaches You About Context Window Optimization
· 2026-05-01 · via DEV Community

MCP's Dark Secret: 5 Hidden Patterns Nobody Teaches You About Context Window Optimization

Anthropic shipped 9 connectors and leaked their entire creative industry strategy. But the real story this week isn't connectors — it's the silent context crisis happening inside every AI agent that uses MCP. Here's what's actually burning your tokens.

If you've been watching Hacker News this week, you probably saw the viral post: "MCP server that reduces Claude Code context consumption by 98%" — 570 points and climbing. The author, Mert Köseoğlu, showed that a single Playwright snapshot costs 56 KB of your 200K context window. Twenty GitHub issues cost 59 KB. After 30 minutes of agent work, 40% of your context is gone before the AI processes a single user message.

But that's just the tip of the iceberg. Here's what 90% of developers building with MCP don't know:

1. Tool Definitions Are Eating Your Context From Both Ends

Most developers think the MCP "context problem" is about the responses coming back from tools. It's not. It's about the tool definitions going in.

Cloudflare's research showed that tool definitions can be compressed by 99.9% with "Code Mode." But with the standard MCP approach, with 81+ tools active, 143K tokens get consumed before your first user message. Then tools start returning data.

The MCP protocol standard (84K stars, 10.5K forks at modelcontextprotocol/servers) sends full JSON schemas for every tool on every request. A Playwright MCP tool definition alone is ~8KB.

# BEFORE: Raw MCP tool call — burns 56KB per execution
# From a typical Playwright MCP server response:
tool_result = {
    "html": "<!DOCTYPE html><html><head>...500 lines of rendered DOM...",
    "screenshot": "base64_encoded_4MB_image",
    "accessibility_tree": {...15000 nodes...}
}

# AFTER: Context Mode MCP — compresses to 5.4KB (98% reduction)
# The MCP server filters output BEFORE sending to the agent
class ContextModeServer:
    def __init__(self, max_output_tokens=512):
        self.max_output_tokens = max_output_tokens

    def execute_tool(self, tool_name, params):
        raw_result = self.delegate_to_real_server(tool_name, params)

        # Step 1: Strip HTML/screenshot noise
        cleaned = self.remove_noise(raw_result)

        # Step 2: Semantic compression
        summary = self.summarize(cleaned, max_tokens=self.max_output_tokens)

        # Step 3: Return only what the LLM actually needs
        return {"context_compressed": summary, "meta": {"saved_tokens": raw_result.size - summary.size}}

# Verification: 315 KB → 5.4 KB (98% reduction)
# Source: https://mksg.lu/blog/context-mode

Enter fullscreen mode Exit fullscreen mode

The fix isn't to use fewer tools — it's to use a middleware that compresses tool outputs before they hit your context window.

2. The MCP Multiplexer Pattern: Cut Tool Call Pollution by 19x

Most agents execute MCP tools sequentially. Each tool call adds tokens to context. But what if you could batch multiple tool calls into one?

# callmux: MCP multiplexer that cuts tool call context pollution by ~19x
# https://github.com/edimuj/callmux

import asyncio
from callmux import MCPMultiplexer

async def batch_code_review(mcp_server_url: str, pr_data: dict):
    """
    Instead of 10 sequential tool calls (10 * token overhead),
    send 1 batched request. ~19x less context pollution.
    """
    multiplexer = MCPMultiplexer(mcp_server_url)

    # Define parallel operations
    operations = [
        {"tool": "gh", "method": "get_pr_files", "params": {"pr": pr_data["number"]}},
        {"tool": "gh", "method": "get_pr_diff", "params": {"pr": pr_data["number"]}},
        {"tool": "gh", "method": "list_comments", "params": {"pr": pr_data["number"]}},
        {"tool": "filesystem", "method": "read_related", "params": {"files": pr_data["touched_files"]}},
        {"tool": "linter", "method": "analyze", "params": {"files": pr_data["touched_files"]}},
    ]

    # Single batched call — 1 context entry instead of 5
    results = await multiplexer.execute_batch(operations, strategy="parallel")

    # Merge and deduplicate results
    return multiplexer.aggregate(results)

# Usage: ~19x reduction in tool call overhead

Enter fullscreen mode Exit fullscreen mode

This pattern is particularly powerful for code review workflows where you're calling gh for PR data, filesystem for related files, and a linter — all in parallel.

3. The Hidden MCP Architecture: Passive vs. Active Servers

Most developers run all their MCP servers in "active" mode — every tool definition, every response, always flowing. But there's a passive mode that changes everything.

# Lazy-loading MCP: Only activate server when actually needed
# Inspired by GhidraMCP's lazy tool loading pattern
# https://github.com/bethington/ghidra-mcp

class LazyMCPLoader:
    def __init__(self, server_registry: dict):
        # Server registry stores metadata, NOT active connections
        self.server_registry = server_registry  
        self.active_servers = {}

    async def invoke(self, tool_name: str, params: dict):
        server_name = self._resolve_server(tool_name)

        # Lazy initialization — server starts only on first use
        if server_name not in self.active_servers:
            print(f"🔌 Lazy-loading MCP server: {server_name}")
            self.active_servers[server_name] = await self._start_server(
                self.server_registry[server_name]
            )

        return await self.active_servers[server_name].invoke(tool_name, params)

    async def invoke_batch(self, tools: list):
        """Pre-warm servers for tools likely to be used together"""
        servers_needed = {self._resolve_server(t['tool']) for t in tools}
        for srv in servers_needed:
            if srv not in self.active_servers:
                self.active_servers[srv] = await self._start_server(
                    self.server_registry[srv]
                )

        # Now all servers are pre-warmed for parallel execution
        return await asyncio.gather(*[
            self.active_servers[self._resolve_server(t['tool'])].invoke(t['tool'], t['params'])
            for t in tools
        ])

# Register servers — this is ALL that loads into context at startup
# 500 bytes vs 50,000 bytes of tool definitions
SERVER_REGISTRY = {
    "github": {"host": "localhost", "port": 3100, "tools": 23},
    "filesystem": {"host": "localhost", "port": 3101, "tools": 8},
    "ghidra": {"host": "localhost", "port": 3102, "tools": 110},  # Lazy loaded
}

Enter fullscreen mode Exit fullscreen mode

This is exactly how the GhidraMCP server achieves 110+ reverse engineering tools without flooding your context — lazy tool loading with batch warm-up.

4. RAG-Enhanced MCP: Add Codebase Context Without Token Bloat

Here's the pattern nobody talks about: instead of feeding your entire codebase into the agent's context, use a lightweight MCP tool that answers questions about your code on-demand.

# ragtoolina: MCP tool that adds codebase RAG to AI coding agents
# https://www.ragtoolina.com

from ragtoolina import CodebaseRAG

rag = CodebaseRAG(project_root="./my-project")

# Instead of dumping 50 files into context...
# ...ask the RAG layer first
query = "How does the authentication middleware work?"
context_snippets = rag.query(query, top_k=3)

# Returns:
# [
#   {"file": "src/middleware/auth.py", "lines": "24-67", 
#    "content": "async def auth_middleware(req, ctx): ...", 
#    "relevance": 0.94},
#   {"file": "src/routes/auth.py", "lines": "1-30", 
#    "content": "@router.post('/login') async def login(req): ...", 
#    "relevance": 0.87}
# ]

# Now the agent gets 500 tokens of HIGHLY relevant context
# instead of 50,000 tokens of "dump everything"

Enter fullscreen mode Exit fullscreen mode

This approach was discussed in detail on Hacker News as part of the broader MCP ecosystem — the idea being that your agent shouldn't know everything about your codebase; it should query what it needs.

5. The Multi-Agent MCP Pattern: Divide and Conquer Your Context

The most advanced pattern is splitting MCP across multiple specialized agents, each with their own context window.

# Prism MCP: Multi-agent Hivemind with on-device LLM
# https://github.com/dcostenco/prism-coder

class MCPAgentHivemind:
    """
    Split MCP tools across agents. Each agent gets a FRESH context.
    A coordinator agent synthesizes results.
    """

    def __init__(self, mcp_config: dict):
        # Each sub-agent gets its own MCP server subset
        self.agents = {
            "backend": Agent(
                name="backend-dev",
                mcp_servers=["github", "docker", "postgres"],
                llm="prism-coder:7b"  # Local, no API cost
            ),
            "frontend": Agent(
                name="frontend-dev", 
                mcp_servers=["playwright", "filesystem", "npm"],
                llm="prism-coder:7b"
            ),
            "security": Agent(
                name="security-reviewer",
                mcp_servers=["semgrep", "trivy", "ghidra"],
                llm="prism-coder:7b"
            ),
            "coordinator": Agent(
                name="coordinator",
                mcp_servers=["mcp_bridge"],  # Connects to sub-agents
                llm="claude-sonnet-4"
            )
        }

    async def review_pr(self, pr_url: str):
        # Parallel execution — each agent gets its own clean context
        backend_result = await self.agents["backend"].analyze(pr_url)
        frontend_result = await self.agents["frontend"].analyze(pr_url)
        security_result = await self.agents["security"].analyze(pr_url)

        # Coordinator synthesizes three fresh contexts
        final_report = await self.agents["coordinator"].synthesize({
            "backend": backend_result,
            "frontend": frontend_result,
            "security": security_result
        })

        return final_report

# Result: 3 agents × 200K context = 600K effective context
# vs 1 agent with 200K that degrades with every tool call

Enter fullscreen mode Exit fullscreen mode

What This Means for Your Stack

The MCP ecosystem has exploded — 84K stars on the official servers repo, specialized MCP servers for reverse engineering, WhatsApp, document search, and codebase RAG. But most developers are using them naively.

The shift happening right now is from "MCP as a tool bus" to "MCP as a context optimization layer." The 570-point HN post this week is just the beginning.

"After two years of vibecoding, I'm back to writing by hand." — After two years of vibecoding, I'm back to writing by hand (865 HN points)

The backlash to AI-assisted coding isn't that AI is bad — it's that agents burn through context without discipline. The developers who figure out context optimization first will have the most capable agents.


Data sources:


What MCP context optimization pattern has saved your agents the most tokens? Drop it in the comments — I'm especially curious about niche MCP servers people have built.

Tags: AI, Programming, Github, Tutorial, MCP, DeveloperTools, LLM, ContextWindow