cd /news/ai-agents/building-a-stateful-ai-comic-studio-… · home › topics › ai-agents › article
[ARTICLE · art-175184] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Building a Stateful AI Comic Studio Over Streamable HTTP MCP (for Claude Code, Cursor & Antigravity)

StarVeil AI 2.0 shipped a stateful comic-generation server over Streamable HTTP MCP, exposing 18 agent-callable tools that split comic creation into four state transitions: a persistent character identity vault, chained page rendering that carries a previousTaskId forward, 3-zone bounding-box region patching for text edits, and art-preserving localization into six languages. The team reports that stateless text-to-image APIs fail on sequential pages with consistent characters and legible speech bubbles, and that a 2%–3% halo buffer around edited speech bubbles prevents lettering artifacts without full rerolls. The server supports OAuth 2.1 for Claude Code and revocable sv_live_ API keys for headless automation, and the team documented a Cloudflare Workers OAuth 2.1 JWKS issue hit during Glama certification.

recommendation

Model multi-step image generation as explicit state transitions over MCP — lock character identity, pass previousTaskId between pages, and patch edits with a 2%–3% halo buffer instead of rerolling whole images.

more in playbook: Designing agent systems
by read3 min views2 publishedNov 24, 2026

TL;DR: Calling stateless text-to-image APIs from an AI coding agent breaks down as soon as you need two consecutive comic pages with the same character and legible speech bubbles. This post walks through the 4-Stage Agent Comic State Machine we shipped over Streamable HTTP MCP (https://starveilai.com/api/mcp), the 3-Zone Bounding-Box geometry that fixes typos without full rerolls, and a real Cloudflare Workers OAuth 2.1 JWKS gotcha we hit during Glama certification.

AI coding agents (Claude Code, Antigravity, Cursor, Codex, OpenClaw) are great at multi-step tool loops, yet terrible at drawing sequential comics with raw image generators. The bottleneck isn't aesthetics — it's missing state:

Following the open Model Context Protocol specification and IETF RFC 9728 OAuth 2.0 Protected Resource Metadata, StarVeil AI 2.0 splits comic generation into four explicit state transitions across 18 agent-callable MCP tools (plus an embedded MCP App side-pane):

Stage MCP Tool(s) What State It Locks Cost
1. Persistent Identity Vault create_character ,list_my_characters Canonical face, hair, proportions, and default silhouette ( characterIds ) 0 cr (upload photo) / 20 cr (AI ref sheet)
2. Chained Page Render create_comic_page ,get_comic_page Previous page context ( previousTaskId ) so Page 2+ keeps outfits & ink on fresh layouts 25 cr per 3:4 page (1st page free ontrial_v1 )
3. 3-Zone Region Patch edit_comic_page Anchor Zone (locked) + 2%–3% Halo Buffer + Active Rewrite Zone ( 0..1 bbox) 25 cr per edit (1st edit free ontrial_v1 )
4. Art-Preserving Localization translate_comic ,get_translation_status Downstream 6-language derivatives ( en ,zh-CN ,zh-TW ,ja ,ko ,es ) fromsourceVersionId 10 cr per page (~$0.06 on$6 pack)
claude mcp add --transport http starveil https://starveilai.com/api/mcp

curl -fsSL https://starveilai.com/install.sh | bash

For headless automation (OpenClaw, n8n, GitHub Actions, cron jobs), generate a revocable sv_live_ Personal API Key at https://starveilai.com/app/agents and send Authorization: Bearer sv_live_... to the exact same endpoint.

{
  "tool": "create_character",
  "arguments": {
    "name": "Mochi the Tabby",
    "description": "Warm orange tabby kitten wearing an indigo developer hoodie",
    "referenceImageUrl": "https://example.com/mochi-photo.jpg"
  }
}

previousTaskId

{
  "tool": "create_comic_page",
  "arguments": {
    "title": "The Yarn Ball Incident - Page 2",
    "characterIds": ["chr_mochi_01"],
    "previousTaskId": "task_page1_id",
    "artStyle": "warm watercolor healing storybook comic",
    "language": "en",
    "prompt": "Direct continuation after Page 1. Panel 1: Sleepy engineer enters with coffee staring at the red yarn web. Panel 2: Mochi peeks out: \"Good news: zero merge conflicts.\" Panel 3: Warm sunrise wide shot as the engineer laughs."
  }
}

Informed by masked diffusion inpainting (RePaint, arXiv:2201.09865), mask geometry matters as much as the prompt. Leave a 2%–3% halo buffer outside the black balloon stroke so old letters don't leave artifacts while everything outside the box stays anchored:

{
  "tool": "edit_comic_page",
  "arguments": {
    "taskId": "task_noir_page1",
    "instruction": "Text-only edit inside the boxed white speech bubble: replace text with exact words \"He left at midnight.\" Keep face, rain lighting, and surrounding panels unchanged.",
    "region": { "x": 0.54, "y": 0.06, "width": 0.40, "height": 0.16 }
  }
}

When we submitted StarVeil MCP to Glama's connector directory, OAuth authorization succeeded in the browser, yet hourly tools/list health checks returned HTTP 500.

The culprit: Better Auth's mcpHandler({ jwksUrl }) fetches https://starveilai.com/api/auth/jwks over HTTP during token verification — which on Cloudflare Workers triggers a same-zone self-fetch back to the same Worker route and fails under edge proxy rules.

The fix was replacing the remote JWKS HTTP fetch with an in-process local JWKS lookup directly against Cloudflare D1 (jose.createLocalJWKSet + jwtVerify with exact issuer/ audience verification). Latency dropped, the HTTP 500 disappeared permanently, and Glama's hourly introspection now reports Healthy with OAuth: Works in Glama.

latestDownloadUrl (or open open_starveil_studio) before chaining Page 2+. New verified accounts receive 1 free full-color 3:4 page + 1 free box-edit + 0-credit photo OC uploads (trial_v1). Never-expiring credit packs start at $6 Mini (1,000 credits, ~40 pages) and immediately unlock 100% watermark-free commercial PNG downloads across Web, MCP, CLI, and API.

com.starveilai/star-veil-ai@2.0.0)

── more in #ai-agents 4 stories · sorted by recency
── more on @starveil ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-a-stateful-…] indexed:0 read:3min 2026-11-24 · —