Skip to content

Request Flow ​

Detailed sequence diagrams for all request types.

MCP Request Flow ​

Image Generation ​

Image Generation Request Flow

Complete request flow from MCP client through Gemini API to storage

Continue Editing ​

Continue Editing Flow

Edit last image: get session, download, edit, update session

Character Generation ​

Character Generation Flow

Load character, fetch references, build prompt, generate

REST API Flow ​

Get Images List ​

REST API Get Images Flow

Authenticate, query D1 with filters, return JSON response

Admin Create Tenant ​

Admin Create Tenant Flow

Validate admin, generate credentials, insert into D1 and KV

Authentication Flow ​

API Key Validation ​

API Key Validation Flow

Extract key, validate format, check cache/D1, decrypt, return tenant

Admin Token Validation ​

Admin Token Validation

Check admin token header, validate, process or reject

Error Handling Flow ​

Error Handling Flow

Auth → Rate limit → Quota → Tool execution → Response

Transport Protocols ​

Streamable HTTP Transport

POST /mcp with streaming response for progress updates

Server-Sent Events (Legacy) ​

SSE Transport

GET /sse opens connection, events pushed to client

Parallel Processing ​

Multi-Image Generation ​

Multi-Image Parallel Generation

Generate n=4 images in parallel from Gemini API

Multi-Character Scene ​

Multi-Character Scene Processing

Parallel load characters, fetch refs, combine prompts

Response Formats ​

Success Response ​

json
{
  "content": [
    {
      "type": "text",
      "text": "Generated successfully\n\nImage #342\nURL: https://..."
    }
  ]
}

Error Response ​

json
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded",
    "details": {
      "limit": 60,
      "window": "1 minute",
      "retry_after": 30
    }
  }
}

Next Steps ​

Released under the MIT License.