<?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: Leon</title>
    <description>The latest articles on DEV Community by Leon (@warmcoding).</description>
    <link>https://dev.to/warmcoding</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%2F4220188%2F5692268f-f7a0-4c22-80ef-ba0a86fca8bc.png</url>
      <title>DEV Community: Leon</title>
      <link>https://dev.to/warmcoding</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/warmcoding"/>
    <language>en</language>
    <item>
      <title>From REST APIs to MCP Servers: Adapting Your Architecture for AI Agents</title>
      <dc:creator>Leon</dc:creator>
      <pubDate>Mon, 09 Nov 2026 12:16:37 +0000</pubDate>
      <link>https://dev.to/warmcoding/from-rest-apis-to-mcp-servers-adapting-your-architecture-for-ai-agents-a6k</link>
      <guid>https://dev.to/warmcoding/from-rest-apis-to-mcp-servers-adapting-your-architecture-for-ai-agents-a6k</guid>
      <description>&lt;p&gt;In my previous post, Building a Remote MCP Server to Handle Large Files (Audio/Video), we explored how to handle heavy media files without blowing up the LLM's context window.&lt;/p&gt;

&lt;p&gt;Since then, a common question I've received is: "Why bother building an MCP (Model Context Protocol) interface? Why not just use a standard REST API and let the agent call it?"&lt;/p&gt;

&lt;p&gt;It's a fair question. As AI agents (like Cursor, Claude Desktop, and custom autonomous agents) become the primary consumers of our software, the way we design interfaces is fundamentally shifting.&lt;/p&gt;

&lt;p&gt;Here is our journey of migrating a traditional API to an MCP server, why we did it, and the technical hurdles we faced along the way.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why Migrate to MCP? (The Agentic Advantage)
Standard REST APIs are built for deterministic clients (like a web frontend or a mobile app). The client knows exactly what to send and how to handle the response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;LLMs, however, are probabilistic. If you give an LLM an OpenAPI spec and tell it to use it, it often gets confused. It might hallucinate parameters, or you have to write massive system prompts just to explain how to use your API.&lt;/p&gt;

&lt;p&gt;MCP changes this by being "AI-native":&lt;/p&gt;

&lt;p&gt;Dynamic Tool Discovery: MCP servers declare their capabilities directly to the agent. The agent doesn't need to guess; it just asks the server, "What can you do?" and receives a structured list of tools and their schemas.&lt;/p&gt;

&lt;p&gt;Context Efficiency: Instead of a massive OpenAPI JSON file eating up tokens, MCP provides concise, LLM-readable tool descriptions.&lt;/p&gt;

&lt;p&gt;Built-in Streaming: MCP uses Server-Sent Events (SSE) natively, which is perfect for agents to receive real-time updates on long-running tasks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is Your Use Case Suitable for MCP? (The Audio/Video Test)
If you are processing text or simple database queries, a standard API wrapper might be enough. But if your system deals with heavy audio/video processing, MCP is a lifesaver.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is why audio/video is the perfect candidate for MCP:&lt;/p&gt;

&lt;p&gt;Asynchronous Nature: Audio transcription or video rendering takes time. You don't want the agent's reasoning loop to block for 3 minutes.&lt;/p&gt;

&lt;p&gt;Context Window Limits: You can't pass a 50MB .mp4 file or a base64 string directly into a prompt.&lt;/p&gt;

&lt;p&gt;Separation of Concerns: An MCP server acts as a "broker." It receives the intent from the agent, uploads the file via a presigned URL, kicks off the backend processing, and returns a task_id to the agent. This keeps the LLM's context window clean and focused.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Technical Hurdles During Migration (What We Learned)
Wrapping a REST API in an MCP SDK is the easy part. The hard part is adapting the logic for a non-deterministic AI. Here are the biggest challenges we faced:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A. Redesigning Schemas for LLMs&lt;br&gt;
A standard REST API might return a massive JSON object with 50 fields. An LLM doesn't need all that. We had to redesign our tool schemas to be incredibly descriptive and concise. The tool description needs to tell the LLM when and why to use it, not just what it does.&lt;/p&gt;

&lt;p&gt;B. Error Handling for AI&lt;br&gt;
If your REST API throws a 500 Internal Server Error, a human developer checks the logs. If an MCP tool throws that same error, the AI gets stuck.&lt;br&gt;
The fix: Return errors as natural language that the AI can read and self-correct from. For example: "Error: File exceeds 25MB. Please ask the user to compress the file or use the upload_large_file tool instead." This allows the agent to autonomously fix its own mistake.&lt;/p&gt;

&lt;p&gt;C. Handling Large Payloads&lt;br&gt;
As mentioned in my previous post, you cannot pass raw files. We had to enforce a strict rule: The MCP server only returns text or URIs. The AI gets a presigned URL to read or upload from, completely bypassing the context window.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keeping the System Stable Post-Migration
Once the agent is connected, you'll quickly realize that AI agents can be "impatient" and aggressive. Here is how we stabilized our MCP server:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Idempotency Keys: Agents will retry tool calls if they don't get a response fast enough. We implemented idempotency keys so repeated calls don't process the same video twice.&lt;/p&gt;

&lt;p&gt;Strict Timeouts &amp;amp; "Fail Fast": Don't let an agent poll a check_task_status endpoint indefinitely. We built a hard timeout on our side. If a task takes longer than X minutes, the tool returns a clear failure, preventing the agent from entering an infinite loop.&lt;/p&gt;

&lt;p&gt;Rate Limiting by Agent ID: If you are serving multiple agents or users, ensure you rate-limit at the MCP level, not just the backend level, to prevent a runaway agent from DDoS-ing your own infrastructure.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Migrating from REST to MCP is not just a technical refactor; it's a mindset shift from building for deterministic humans to building for probabilistic agents. It requires you to rethink how your data is passed, how errors are communicated, and how tasks are sequenced.&lt;/p&gt;

&lt;p&gt;But the payoff is huge. Once your API is MCP-compatible, it instantly becomes a powerful tool for the entire ecosystem of AI agents.&lt;/p&gt;

&lt;p&gt;Have you started building MCP servers? What challenges have you run into? Let me know in the comments below!&lt;/p&gt;

&lt;p&gt;If you want to dive straight into the code, the full implementation of this MCP server architecture is open-sourced on &lt;a href="https://github.com/warmcoding/sonicaura-mcp" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Feel free to star it or open an issue if you have any questions!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>agents</category>
      <category>podcast</category>
    </item>
    <item>
      <title>Building a Remote MCP Server to Handle Large Files (Audio/Video)</title>
      <dc:creator>Leon</dc:creator>
      <pubDate>Sun, 01 Nov 2026 08:12:16 +0000</pubDate>
      <link>https://dev.to/warmcoding/building-a-remote-mcp-server-to-handle-large-files-audiovideo-3b6l</link>
      <guid>https://dev.to/warmcoding/building-a-remote-mcp-server-to-handle-large-files-audiovideo-3b6l</guid>
      <description>&lt;p&gt;The rise of AI agents (like Cursor and Claude Desktop) is incredible. But if you've ever tried to build a custom tool for them to process large files—like a 50MB audio track or a video—you already know the pain. &lt;/p&gt;

&lt;p&gt;LLMs have strict token and payload limits. You can't just pass a local &lt;code&gt;.mp3&lt;/code&gt; file into a prompt.&lt;/p&gt;

&lt;p&gt;In this post, I'll share the architectural pattern I used to build a &lt;strong&gt;Remote MCP (Model Context Protocol) Server&lt;/strong&gt; that allows an AI agent to process heavy media files entirely hands-free.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Problem: File Size &amp;amp; Context Switching
&lt;/h2&gt;

&lt;p&gt;When you want an AI to process a file, the naive approach is to base64 encode it and send it. This blows up the context window instantly. &lt;/p&gt;

&lt;p&gt;Alternatively, you can build a local MCP server that reads the file directly. But what if the processing requires heavy GPU compute that your local laptop doesn't have?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: The Async Upload Pattern
&lt;/h2&gt;

&lt;p&gt;To solve this, I designed an MCP server that uses an &lt;strong&gt;asynchronous pipeline&lt;/strong&gt; with presigned URLs. &lt;/p&gt;

&lt;p&gt;Here is the exact flow the AI agent follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;get_upload_url&lt;/code&gt;&lt;/strong&gt;: The agent calls this tool. The server returns a presigned URL (e.g., an S3/R2 URL).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Upload&lt;/strong&gt;: The agent (or a local script it triggers) uploads the file directly to cloud storage. &lt;em&gt;No file data ever touches the LLM context window.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;submit_task&lt;/code&gt;&lt;/strong&gt;: The agent tells the server, "Hey, process this uploaded file."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;check_task_status&lt;/code&gt;&lt;/strong&gt;: The agent polls the server (or uses webhooks) to check when the GPU processing is done.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;get_download_url&lt;/code&gt;&lt;/strong&gt;: Finally, the agent gets a URL to download the processed stems, MIDI, or denoised audio back to the local workspace.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why This Rocks for Agentic Workflows
&lt;/h2&gt;

&lt;p&gt;This pattern completely decouples the AI's reasoning from the heavy lifting.&lt;/p&gt;

&lt;p&gt;Here is what a prompt looks like in Cursor:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Extract the vocals from ./demo.mp3 and save the result locally."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI handles the file system, calls the tools, waits for the GPU, and drops the finished file right back into your project folder. It feels like magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Streamable HTTP&lt;/strong&gt;: If you are building for remote clients like Claude or Cursor, &lt;code&gt;stdio&lt;/code&gt; isn't enough. Host your server and expose it via HTTP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle Polling Gracefully&lt;/strong&gt;: LLMs can get stuck in loops if a task fails. Make sure your &lt;code&gt;check_task_status&lt;/code&gt; returns clear error states, not just "pending".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication&lt;/strong&gt;: Protect your server with OAuth. Exposing a GPU-backed API without auth is a quick way to get a massive bill.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Open Source Example
&lt;/h2&gt;

&lt;p&gt;I built this entire architecture for &lt;strong&gt;Sonicaura MCP&lt;/strong&gt; (an audio processing engine). It's completely open-source and published in the official MCP Registry if you want to dig into the code or try it out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Repo&lt;/strong&gt;: &lt;a href="https://github.com/warmcoding/sonicaura-mcp" rel="noopener noreferrer"&gt;warmcoding/sonicaura-mcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Registry&lt;/strong&gt;: &lt;a href="https://registry.modelcontextprotocol.io/?q=sonicaura-mcp" rel="noopener noreferrer"&gt;Official MCP Registry&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are building agents, I'd love to know: &lt;strong&gt;How are you handling large file processing in your MCP servers?&lt;/strong&gt; Let me know in the comments!&lt;/p&gt;

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