<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AyhanYetgin</title>
    <description>The latest articles on DEV Community by AyhanYetgin (@ayhanyetgin).</description>
    <link>https://dev.to/ayhanyetgin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4003095%2F06bb431b-0840-42c7-8ed9-9b4e85fbd812.jpg</url>
      <title>DEV Community: AyhanYetgin</title>
      <link>https://dev.to/ayhanyetgin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayhanyetgin"/>
    <language>en</language>
    <item>
      <title>I Built an Open Source Tool to Cut Claude Code Token Waste by 70%"</title>
      <dc:creator>AyhanYetgin</dc:creator>
      <pubDate>Fri, 26 Jun 2026 00:01:06 +0000</pubDate>
      <link>https://dev.to/ayhanyetgin/i-built-an-open-source-tool-to-cut-claude-code-token-waste-by-70-155</link>
      <guid>https://dev.to/ayhanyetgin/i-built-an-open-source-tool-to-cut-claude-code-token-waste-by-70-155</guid>
      <description>&lt;h2&gt;
  
  
  What is ContextOpt?
&lt;/h2&gt;

&lt;p&gt;ContextOpt is a &lt;strong&gt;smart proxy&lt;/strong&gt; that sits between your AI agent and its MCP servers. It filters tools by profile so only relevant ones consume context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AI Agent (Claude Code)
       │
       ▼
┌─────────────────┐
│  ContextOpt      │  ← Filters tools by profile
│  Proxy Engine    │  ← Lazily starts servers
└────────┬────────┘
         │
    ┌────┴────┐
    ▼         ▼
filesystem  github  ... (only active profile servers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Here's a typical MCP config for Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"filesystem"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@anthropic/mcp-filesystem"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"github"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@modelcontextprotocol/github"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"playwright"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@anthropic/mcp-playwright"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"sequential-thinking"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@anthropic/mcp-sequential-thinking"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"memory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@anthropic/mcp-memory"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's &lt;strong&gt;5 servers&lt;/strong&gt; → &lt;strong&gt;~78 tool definitions&lt;/strong&gt; → &lt;strong&gt;~19,500 tokens&lt;/strong&gt; per prompt. Every. Single. Message.&lt;/p&gt;

&lt;p&gt;If you send 50 messages a day, that's nearly &lt;strong&gt;1M tokens/month&lt;/strong&gt; just on tool definitions — about &lt;strong&gt;$90/month&lt;/strong&gt; on Claude Sonnet.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Profile-Based Filtering
&lt;/h2&gt;

&lt;p&gt;Instead of loading every tool all the time, ContextOpt groups servers into profiles:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Profile&lt;/th&gt;
&lt;th&gt;Servers Active&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;th&gt;Savings&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;default&lt;/code&gt; (all)&lt;/td&gt;
&lt;td&gt;5 servers&lt;/td&gt;
&lt;td&gt;~19.5K&lt;/td&gt;
&lt;td&gt;baseline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;coding&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;filesystem, github&lt;/td&gt;
&lt;td&gt;~10K&lt;/td&gt;
&lt;td&gt;49%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;debugging&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;playwright, memory&lt;/td&gt;
&lt;td&gt;~8.8K&lt;/td&gt;
&lt;td&gt;55%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;research&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;sequential-thinking, memory&lt;/td&gt;
&lt;td&gt;~2K&lt;/td&gt;
&lt;td&gt;90%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When you're coding, you don't need Playwright. When you're debugging, you don't need GitHub. Simple.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Analyze your current setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx contextopt analyze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reads your MCP config (auto-detects Claude Code, Cursor, or Windsurf) and shows a breakdown of token usage per server, estimated cost, and potential savings.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Pick a profile
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List available profiles&lt;/span&gt;
npx contextopt profile &lt;span class="nt"&gt;-l&lt;/span&gt;

&lt;span class="c"&gt;# Switch to coding profile&lt;/span&gt;
npx contextopt profile &lt;span class="nt"&gt;-s&lt;/span&gt; coding

&lt;span class="c"&gt;# Create a custom profile&lt;/span&gt;
npx contextopt profile &lt;span class="nt"&gt;-c&lt;/span&gt; myprofile &lt;span class="nt"&gt;--servers&lt;/span&gt; &lt;span class="s2"&gt;"github,filesystem"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Start the proxy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx contextopt start &lt;span class="nt"&gt;--profile&lt;/span&gt; coding
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The proxy connects to only the servers in your active profile, discovers their tools, and exposes the filtered list to your AI agent. Servers you don't need are never started — saving both tokens and system resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  HTTP Mode (Pro)
&lt;/h3&gt;

&lt;p&gt;For remote connections, you can run the proxy in HTTP mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx contextopt start &lt;span class="nt"&gt;--http&lt;/span&gt; &lt;span class="nt"&gt;--port&lt;/span&gt; 3456
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This uses &lt;a href="https://spec.modelcontextprotocol.io/" rel="noopener noreferrer"&gt;Streamable HTTP&lt;/a&gt; transport, so any MCP-compatible client can connect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Web Dashboard
&lt;/h2&gt;

&lt;p&gt;You don't have to use the CLI if you prefer a visual interface. The &lt;a href="https://contextopt.vercel.app" rel="noopener noreferrer"&gt;live dashboard&lt;/a&gt; lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paste your MCP config and see instant token analysis&lt;/li&gt;
&lt;li&gt;Compare savings across profiles&lt;/li&gt;
&lt;li&gt;See per-server breakdown with charts&lt;/li&gt;
&lt;li&gt;Calculate your monthly savings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcontextopt.vercel.app" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcontextopt.vercel.app" alt="Dashboard" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned Building This
&lt;/h2&gt;

&lt;p&gt;This was my first time working with the &lt;a href="https://github.com/modelcontextprotocol/typescript-sdk" rel="noopener noreferrer"&gt;MCP SDK&lt;/a&gt;. A few things I learned:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server lifecycle management is tricky.&lt;/strong&gt; MCP servers are spawned as child processes, and you need to handle startup, keepalive, and graceful shutdown. The SDK handles most of this, but I had to build a wrapper around it for lazy loading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Token estimation is never exact.&lt;/strong&gt; I use a heuristic based on typical tool counts per server (filesystem ~15 tools, github ~25, etc.) and average tool schema size (~250 tokens/tool). It's close enough for planning, but actual usage varies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The proxy pattern is powerful.&lt;/strong&gt; By acting as a transparent proxy, ContextOpt works with any MCP client without modification. The agent connects to ContextOpt, and ContextOpt connects to the real servers. No config changes needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx contextopt analyze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No installation needed — &lt;code&gt;npx&lt;/code&gt; handles everything.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/AyhanYetgin/contextopt" rel="noopener noreferrer"&gt;github.com/AyhanYetgin/contextopt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Demo:&lt;/strong&gt; &lt;a href="https://contextopt.vercel.app" rel="noopener noreferrer"&gt;contextopt.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/contextopt" rel="noopener noreferrer"&gt;npmjs.com/package/contextopt&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[x] CLI with analyze, profile, start commands&lt;/li&gt;
&lt;li&gt;[x] Profile system with persistent storage&lt;/li&gt;
&lt;li&gt;[x] Proxy engine with lazy tool discovery&lt;/li&gt;
&lt;li&gt;[x] Web dashboard with live token analytics&lt;/li&gt;
&lt;li&gt;[x] HTTP transport for remote connections&lt;/li&gt;
&lt;li&gt;[x] Pro subscription with Lemon Squeezy payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Up next: usage analytics, team profiles, and a VS Code extension.&lt;/p&gt;




&lt;p&gt;*ContextOpt is open source (MIT). If you find it useful, consider &lt;a href="https://contextopt.vercel.app/pro" rel="noopener noreferrer"&gt;sponsoring the project&lt;/a&gt; or &lt;a href="https://github.com/AyhanYetgin/contextopt" rel="noopener noreferrer"&gt;starring it on GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>claude</category>
      <category>mcp</category>
      <category>opensource</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
