<?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: Samet Taşlıoğlu</title>
    <description>The latest articles on DEV Community by Samet Taşlıoğlu (@stfade).</description>
    <link>https://dev.to/stfade</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3912297%2Fa0f51b88-7973-45ed-85e2-b308d71acd64.png</url>
      <title>DEV Community: Samet Taşlıoğlu</title>
      <link>https://dev.to/stfade</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stfade"/>
    <language>en</language>
    <item>
      <title>How I built an MCP server to enforce structured bug-fixing for AI agents</title>
      <dc:creator>Samet Taşlıoğlu</dc:creator>
      <pubDate>Mon, 04 May 2026 14:46:14 +0000</pubDate>
      <link>https://dev.to/stfade/how-i-built-an-mcp-server-to-enforce-structured-bug-fixing-for-ai-agents-59ko</link>
      <guid>https://dev.to/stfade/how-i-built-an-mcp-server-to-enforce-structured-bug-fixing-for-ai-agents-59ko</guid>
      <description>&lt;p&gt;If you use AI coding agents like Claude Code or Cursor, you’ve hit this wall: &lt;/p&gt;

&lt;p&gt;The agent runs into a framework-specific error. It reads a massive, unstructured raw stack trace. It guesses a fix blindly. Sometimes it hallucinates entirely because it lacks project context. Next week, it hits the exact same error and repeats the exact same blind guesses.&lt;/p&gt;

&lt;p&gt;I wanted to stop this chaotic, guess-heavy behavior. I wanted my agents to fix bugs using a disciplined, structured, and evidence-backed workflow.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href="https://github.com/stfade/moth" rel="noopener noreferrer"&gt;Moth&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Moth?
&lt;/h2&gt;

&lt;p&gt;Moth is a lightweight, open-source Node.js MCP (Model Context Protocol) server. Rather than just tossing error logs to an LLM, Moth intercepts the error and forces the agent into a strict pipeline: &lt;code&gt;analyze → fix → verify → remember&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Moth operates locally in your workspace without massive Vector DB setups or cloud dependencies, exposing exactly two tools to your agent: &lt;code&gt;analyze_error&lt;/code&gt; and &lt;code&gt;remember_fix_result&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "Evidence-Backed" Pipeline
&lt;/h2&gt;

&lt;p&gt;Here is how Moth transforms a blind guess into a structured workflow:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Pre-computational Redaction (Safety First) 🔒
&lt;/h3&gt;

&lt;p&gt;Agent logs are often full of sensitive data. Before the LLM even sees the error, Moth parses the local output and scrubs API keys, bearer tokens, DB URLs, and &lt;code&gt;.env&lt;/code&gt; formats via strict Regex.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Stack Inference &amp;amp; Issue Fingerprinting 🧠
&lt;/h3&gt;

&lt;p&gt;Instead of just parsing strings, &lt;code&gt;analyze_error&lt;/code&gt; normalizes a failure. It detects the likely stack (Vite, Next.js, Prisma, TS), strips away variable line numbers, and generates a deterministic &lt;code&gt;fingerprint&lt;/code&gt; of the core issue.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Structured Fix Briefs 📝
&lt;/h3&gt;

&lt;p&gt;Moth stops the agent from immediately modifying code. It analyzes the context and returns a structured "fix brief." It forces the AI to look at the &lt;em&gt;evidence&lt;/em&gt; of the error and formulate a confident "best first fix" strategy based on your project's specific local context.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Verified Memory (The Magic Loop) 💾
&lt;/h3&gt;

&lt;p&gt;If the agent attempts the fix, Moth prevents blind logging. A local fix is &lt;em&gt;only&lt;/em&gt; recorded to &lt;code&gt;.moth/fix-memory.jsonl&lt;/code&gt; if the agent runs a verification command (like &lt;code&gt;npm run build&lt;/code&gt;) and explicitly passes a hard &lt;code&gt;passed&lt;/code&gt; or &lt;code&gt;failed&lt;/code&gt; state back to the tool. &lt;/p&gt;

&lt;p&gt;Tomorrow, when the agent hits the same fingerprint, it doesn't need to guess. It pulls the verified, successful solution from its local memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running Moth Locally
&lt;/h2&gt;

&lt;p&gt;Moth is environment-agnostic and relies purely on explicitly provided context. You can spin it up immediately without installation via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;-y&lt;/span&gt; @stfade/moth moth-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ve also included plug-and-play configuration wrappers for Claude Code, Cursor, and Gemini CLI in the repo.&lt;/p&gt;

&lt;p&gt;Feedback Wanted!&lt;br&gt;
I built this purely to scratch my own itch—turning chaotic agent debugging into a reliable, evidence-backed workflow.&lt;/p&gt;

&lt;p&gt;Are you dealing with agent hallucinations in your local workspace? Check out the repo here and let me know your thoughts on the architecture:&lt;br&gt;
Github: &lt;a href="https://github.com/stfade/moth" rel="noopener noreferrer"&gt;https://github.com/stfade/moth&lt;/a&gt;&lt;/p&gt;

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