{"slug": "building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code", "title": "Building a Stateful AI Comic Studio Over Streamable HTTP MCP (for Claude Code, Cursor & Antigravity)", "summary": "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.", "body_md": "**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.\n\nAI 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**:\n\nFollowing the open [Model Context Protocol specification](https://modelcontextprotocol.io/specification) and [IETF RFC 9728](https://datatracker.ietf.org/doc/rfc9728/) 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):\n\n| Stage | MCP Tool(s) | What State It Locks | Cost | \n|---|---|---|---|\n| **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) | \n| **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 on`trial_v1` ) | \n| **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 on`trial_v1` ) | \n| **4. Art-Preserving Localization** | `translate_comic` ,`get_translation_status` | Downstream 6-language derivatives ( `en` ,`zh-CN` ,`zh-TW` ,`ja` ,`ko` ,`es` ) from`sourceVersionId` | **10 cr** per page (~$0.06 on`$6` pack) | \n\n```\n# Claude Code (OAuth 2.1 — one-click browser approval, no secrets in chat)\nclaude mcp add --transport http starveil https://starveilai.com/api/mcp\n\n# Antigravity / Cursor / Codex / CLI (installs plugin, starveil-cli, and SKILL.md)\ncurl -fsSL https://starveilai.com/install.sh | bash\n```\n\nFor 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.\n\n```\n{\n  \"tool\": \"create_character\",\n  \"arguments\": {\n    \"name\": \"Mochi the Tabby\",\n    \"description\": \"Warm orange tabby kitten wearing an indigo developer hoodie\",\n    \"referenceImageUrl\": \"https://example.com/mochi-photo.jpg\"\n  }\n}\n```\n\n`previousTaskId`\n\n```\n{\n  \"tool\": \"create_comic_page\",\n  \"arguments\": {\n    \"title\": \"The Yarn Ball Incident - Page 2\",\n    \"characterIds\": [\"chr_mochi_01\"],\n    \"previousTaskId\": \"task_page1_id\",\n    \"artStyle\": \"warm watercolor healing storybook comic\",\n    \"language\": \"en\",\n    \"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.\"\n  }\n}\n```\n\nInformed by masked diffusion inpainting ([RePaint, arXiv:2201.09865](https://arxiv.org/abs/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:\n\n```\n{\n  \"tool\": \"edit_comic_page\",\n  \"arguments\": {\n    \"taskId\": \"task_noir_page1\",\n    \"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.\",\n    \"region\": { \"x\": 0.54, \"y\": 0.06, \"width\": 0.40, \"height\": 0.16 }\n  }\n}\n```\n\nWhen we submitted StarVeil MCP to [Glama's connector directory](https://glama.ai/mcp/connectors/com.starveilai/star-veil-ai), OAuth authorization succeeded in the browser, yet hourly `tools/list` health checks returned `HTTP 500`.\n\nThe 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.\n\nThe 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**.\n\n`latestDownloadUrl` (or open `open_starveil_studio`) before chaining Page 2+.\nNew 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.\n\n`com.starveilai/star-veil-ai@2.0.0`)", "url": "https://wpnews.pro/news/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code", "canonical_source": "https://dev.to/kajian_du_5c58aead7d2bc8e/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code-cursor-antigravity-d8h", "published_at": "2026-11-24 04:31:33+00:00", "updated_at": "2026-11-24 04:42:25.760845+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "generative-ai", "developer-tools"], "entities": ["StarVeil AI", "Claude Code", "Cursor", "Antigravity", "OpenClaw", "Cloudflare Workers", "Glama", "Model Context Protocol"], "also_reported_by": [], "takeaway": "Splitting comic generation into four MCP state transitions — a character vault, chained pages via previousTaskId, 3-zone bounding-box edits with a 2%–3% halo buffer, and art-preserving translation — keeps characters and lettering consistent across sequential pages without full rerolls.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code", "markdown": "https://wpnews.pro/news/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code.md", "text": "https://wpnews.pro/news/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code.txt", "jsonld": "https://wpnews.pro/news/building-a-stateful-ai-comic-studio-over-streamable-http-mcp-for-claude-code.jsonld"}}