<?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: 彭英瑞</title>
    <description>The latest articles on DEV Community by 彭英瑞 (@lastlight).</description>
    <link>https://dev.to/lastlight</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%2F4249975%2Fcf548d59-320d-4879-8794-79d531f58908.jpg</url>
      <title>DEV Community: 彭英瑞</title>
      <link>https://dev.to/lastlight</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lastlight"/>
    <language>en</language>
    <item>
      <title>Wiring MCP image generation into Claude Code and Cursor without local GPUs</title>
      <dc:creator>彭英瑞</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:01:08 +0000</pubDate>
      <link>https://dev.to/lastlight/wiring-mcp-image-generation-into-claude-code-and-cursor-without-local-gpus-bjf</link>
      <guid>https://dev.to/lastlight/wiring-mcp-image-generation-into-claude-code-and-cursor-without-local-gpus-bjf</guid>
      <description>&lt;p&gt;When an AI coding agent builds a landing page or tests a game prototype, hitting a missing placeholder asset breaks the flow. Setting up &lt;strong&gt;MCP image generation&lt;/strong&gt; over a remote Streamable HTTP server lets terminal agents such as Claude Code and editors like Cursor request images and short videos directly during a build without provisioning local GPU drivers.&lt;/p&gt;

&lt;p&gt;Instead of downloading multi-gigabyte checkpoints or wiring custom Python wrappers around third-party REST calls, a single endpoint handles model discovery, task submission, and status polling across nine image and video models. Everything shares one credit balance, and failed generation tasks automatically refund reserved credits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why remote Streamable HTTP beats local stdio wrappers
&lt;/h2&gt;

&lt;p&gt;Early MCP setups relied heavily on local &lt;code&gt;stdio&lt;/code&gt; scripts. Every developer on a project had to clone a wrapper repository, maintain Python or Node dependencies, and keep SDK versions aligned whenever a provider updated model parameters.&lt;/p&gt;

&lt;p&gt;A remote Streamable HTTP endpoint shifts that maintenance out of the repo. Your editor or terminal agent connects directly to &lt;code&gt;https://imagifly.net/api/mcp&lt;/code&gt; with a standard bearer token header. When a team member opens the project, the client reads environment interpolation such as &lt;code&gt;${IMAGIFLY_API_KEY}&lt;/code&gt;, keeping API credentials out of git history.&lt;/p&gt;

&lt;p&gt;There is also a practical cost advantage when prototyping. Creating an account grants 10 free credits each day you visit while signed in, with no credit card required, so you can validate tool calls before committing to a paid plan or batch pack.&lt;/p&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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5z9rfqn9xtqh2mk2tw08.jpg" 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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5z9rfqn9xtqh2mk2tw08.jpg" alt="Dark-mode coding workstation with dual monitors and warm desk lighting during a late-afternoon setup session" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Claude Code and Cursor in two minutes
&lt;/h2&gt;

&lt;p&gt;Before adding the configuration, generate an API key (&lt;code&gt;imf_...&lt;/code&gt;) from the developer console and export it in your shell profile as &lt;code&gt;IMAGIFLY_API_KEY&lt;/code&gt;. Never commit raw keys into &lt;code&gt;.mcp.json&lt;/code&gt; or editor configs.&lt;/p&gt;

&lt;p&gt;For Claude Code in macOS or Linux, register the server with one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http imagifly https://imagifly.net/api/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer $IMAGIFLY_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows PowerShell, pass the PowerShell environment variable syntax instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;claude&lt;/span&gt; &lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;transport&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="n"&gt;imagifly&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;imagifly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="sb"&gt;`
  --header "Authorization: Bearer $env:IMAGIFLY_API_KEY"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want project collaborators to inherit the server definition, add a &lt;code&gt;.mcp.json&lt;/code&gt; file at the repository root:&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="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"imagifly"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://imagifly.net/api/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer ${IMAGIFLY_API_KEY}"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One easy gotcha: Claude Code requires &lt;code&gt;"type": "http"&lt;/code&gt; whenever a &lt;code&gt;url&lt;/code&gt; field is present. Omitting &lt;code&gt;"type"&lt;/code&gt; triggers a config error. The exact setup steps for Codex, Cursor, OpenClaw, and other clients are documented in the &lt;a href="https://imagifly.net/docs/agents" rel="noopener noreferrer"&gt;remote MCP setup guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After restarting the agent or running &lt;code&gt;/mcp&lt;/code&gt;, verify the server registers cleanly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp list
claude mcp get imagifly
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the client reports a healthy connection yet displays zero tools, check your &lt;code&gt;Authorization&lt;/code&gt; header formatting. Unauthenticated handshakes often connect at the transport layer while exposing no capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  How remote MCP image generation handles async jobs
&lt;/h2&gt;

&lt;p&gt;Media creation is fundamentally slower than text completion. Image tasks typically finish in 10 to 60 seconds, while video renders can take several minutes. Expecting an agent tool call to block a single HTTP request until a 1080P clip completes leads to dropped connections and client timeouts.&lt;/p&gt;

&lt;p&gt;To stay resilient, &lt;strong&gt;MCP image generation&lt;/strong&gt; splits work into two explicit phases: submission and polling. When everything is wired properly, the server exposes six focused tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;list_image_models&lt;/code&gt; — fetches active image models, credit prices, and reference-image limits.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;generate_image&lt;/code&gt; — queues a text-to-image or reference-image task with aspect ratio, quality tier, and optional reasoning steps.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get_image_generation&lt;/code&gt; — polls an image task ID and returns output URLs once &lt;code&gt;status&lt;/code&gt; turns to &lt;code&gt;success&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;list_video_models&lt;/code&gt; — reads available video models, aspect ratios, sizes, and supported clip durations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;generate_video&lt;/code&gt; — submits text-to-video, reference-to-video, or first/last-frame jobs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get_video_generation&lt;/code&gt; — polls a video job ID until &lt;code&gt;status&lt;/code&gt; resolves to &lt;code&gt;success&lt;/code&gt; or &lt;code&gt;failed&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice why &lt;code&gt;list_image_models&lt;/code&gt; and &lt;code&gt;list_video_models&lt;/code&gt; matter for agent reliability. Model parameters shift as engines update: &lt;code&gt;Seedance&lt;/code&gt; 2.0 supports 5 to 15 seconds while 2.5 extends to 30 seconds, &lt;code&gt;MiniMax H3&lt;/code&gt; supports &lt;code&gt;r2v&lt;/code&gt;, &lt;code&gt;fl2v&lt;/code&gt;, and &lt;code&gt;t2v&lt;/code&gt; formats, and &lt;code&gt;Qwen Image Edit&lt;/code&gt; targets image editing with up to three references. Letting the agent query the live catalog prevents hallucinated aspect ratios or invalid duration flags.&lt;/p&gt;

&lt;p&gt;You can inspect the schema and parameter mappings for &lt;a href="https://imagifly.net/docs/agents" rel="noopener noreferrer"&gt;the six MCP image and video tools&lt;/a&gt; directly before writing custom agent instructions.&lt;/p&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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9gyoa2htqqg8yvlooghf.jpg" 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%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9gyoa2htqqg8yvlooghf.jpg" alt="Printed visual layout sketches and color reference cards arranged beside a laptop on a wooden table" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping agent prompts predictable in real builds
&lt;/h2&gt;

&lt;p&gt;Once connected, the cleanest way to keep an agent from looping endlessly or guessing sizes is to write explicit task constraints into your prompt or &lt;code&gt;CLAUDE.md&lt;/code&gt; / &lt;code&gt;.cursorrules&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;First call list_image_models to pick a model suited for small legible UI posters.
Then call generate_image with ratio "16:9", poll get_image_generation every 3 seconds
until status is "success" or "failed", and download the resulting file into ./public/assets/.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three habits keep credit burn low during automated runs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Treat delivery URLs as temporary.&lt;/strong&gt; Download returned &lt;code&gt;imageUrls&lt;/code&gt; or &lt;code&gt;videoUrls&lt;/code&gt; immediately into your local project directory or object storage rather than hardcoding delivery URLs in production code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never auto-retry blindly on &lt;code&gt;402&lt;/code&gt; or safety rejections.&lt;/strong&gt; If &lt;code&gt;get_image_generation&lt;/code&gt; returns &lt;code&gt;failed&lt;/code&gt;, inspect the &lt;code&gt;error&lt;/code&gt; string first; credits are automatically returned for failed tasks, so tweaking the prompt prevents wasted repeats.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass reference images sparingly.&lt;/strong&gt; Models like &lt;code&gt;Nano Banana 2&lt;/code&gt;, &lt;code&gt;GPT-Image-2.6&lt;/code&gt;, and &lt;code&gt;Grok Image 2.0&lt;/code&gt; support up to three reference images in this workspace, whereas &lt;code&gt;Wai-SDXL&lt;/code&gt; and &lt;code&gt;Z-Image Turbo&lt;/code&gt; take text prompts only. Checking &lt;code&gt;referenceImageLimit&lt;/code&gt; upfront stops fallback surprises.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For developers already living inside Claude Code or Cursor, moving asset creation into the same terminal session removes the context switch of exporting files manually. Add the Streamable HTTP block, set your key in the environment, and let the agent pull live model limits before it generates a single pixel.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>tutorial</category>
      <category>claudecode</category>
    </item>
  </channel>
</rss>
