跳到正文
DEV Community· kajian du·· 1 小時前AI 評分47

StarVeil AI 2.0 如何透過 Streamable HTTP MCP 構建有狀態 AI 漫畫工作室(適用於 Claude Code、Cursor 和 Antigravity)

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

AI 導讀

StarVeil AI 2.0 透過 Streamable HTTP MCP 構建有狀態 AI 漫畫工作室,以 4 階段狀態機和 18 個 MCP 工具處理角色一致性、連續頁面生成、局部修補及漫畫本地化。3 區域邊界框模型可修正文案而毋須重新生成整頁;Cloudflare Workers 的 JWKS 自我擷取問題則以本地 JWKS 查詢修復。

正文

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.

Why Stateless Image APIs Fail Multi-Page Comics

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:

  1. Identity drift: Repeating a character's name or prose description across four requests produces four subtly different people (which is why subject-personalization papers like DreamBooth and StoryDiffusion treat sequence consistency as a distinct problem).
  2. The 95%-finished trap: Three panels look great, one speech bubble misspells a name, and regenerating the whole page breaks the three panels you already liked.
  3. Text expansion during localization: Per the W3C Internationalization text-size guidelines, translating compact Chinese or Japanese comic dialogue into English or Spanish expands text length by 30%–60%, causing naive OCR white-box overlays to clip or wreck hand-drawn art.

The 4-Stage Agent Comic State Machine

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 on trial_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 on trial_v1)
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)

Connect in 10 Seconds

# Claude Code (OAuth 2.1 — one-click browser approval, no secrets in chat)
claude mcp add --transport http starveil https://starveilai.com/api/mcp

# Antigravity / Cursor / Codex / CLI (installs plugin, starveil-cli, and SKILL.md)
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.

Reproducible JSON Loop

1. Lock a Photo OC at 0 Credits

{
  "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"
  }
}

2. Render Page 1, Then Chain Page 2 via 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."
  }
}

StarVeil 2.0 Page 2 chained via previousTaskId preserving tabby OC identity

3. Fix One Speech Bubble with the 3-Zone Bounding-Box Model

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 }
  }
}

Production War Story: OAuth 2.1 JWKS Self-Fetch on Cloudflare Workers

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.

Honest Limits

  • Visual inspection is still mandatory: Crowded four-character panels or tricky hand/prop occlusions can still drift; inspect latestDownloadUrl (or open open_starveil_studio) before chaining Page 2+.
  • Not a replacement for print prepress: If you need layered CMYK PSD/CLIP files for physical publishing, use a human artist.
  • Keep bubbles concise: Sub-12px text or long paragraphs inside narrow balloons degrade readability across every model.

Try It & Explore the Specs

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.

來源:DEV Community · dev.to