Skip to content

LLM pack: avatar API, MCP server, llms.txt, crawlable HTML#85

Open
bluerssen wants to merge 2 commits into
short-linksfrom
llm-pack
Open

LLM pack: avatar API, MCP server, llms.txt, crawlable HTML#85
bluerssen wants to merge 2 commits into
short-linksfrom
llm-pack

Conversation

@bluerssen

Copy link
Copy Markdown
Contributor

Summary

Makes Personas usable by LLMs and agents, not just browsers. Stacked on #84 (short links) — merge order: #83 (grid, independent) / #84 → this.

  • GET /api/avatar.svg — the avatar as a real image URL. Same query params as the site, plus ?code=<shortcode> and ?random=1. Server-side composition imports the app's own compiled SvgLoader.render (pure function extracted from the React component — the API can never drift from the app art). Invalid params → 400 with JSON naming the valid values. Deterministic URLs get immutable caching.
  • POST /mcp — stateless streamable-HTTP MCP server, hand-rolled JSON-RPC (~120 lines, no SDK, no Durable Objects). Tools: list_avatar_options, generate_avatar, random_avatar — each returns the share URL, SVG image URL, and a markdown embed. After deploy: claude mcp add --transport http personas https://personas.draftbit.com/mcp.
  • /llms.txt — concise agent-facing spec: URL param schema, /api/options discovery, image API, MCP endpoint, determinism/caching notes.
  • Crawlable HTML — schema.org WebApplication JSON-LD plus real descriptive content inside #root (visible to no-JS crawlers, replaced on mount).
  • README — "For LLMs & agents" section; documents that config.json option arrays are append-only.

Verification (wrangler dev + headless browser)

  • /api/avatar.svg with 13 pinned params renders pixel-identical to the app for the same URL (screenshots compared)
  • Bad params → 400 listing valid values; ?code= renders shared avatars
  • MCP: initializenotifications/initialized (202) → tools/listtools/call all correct, including isError on invalid tool args
  • /llms.txt serves; JSON-LD + fallback content present in raw HTML; app still mounts cleanly and replaces the fallback

⚠️ Do not merge — awaiting Brian's review.

🤖 Generated with Claude Code

bluerssen and others added 2 commits July 5, 2026 08:59
- GET /api/avatar.svg: server-composed avatar image with the same
  params as the site (or ?code= / ?random=1); strict validation with
  helpful 400s; immutable caching. Composition reuses the app's own
  art via a new pure SvgLoader.render function (extracted from the
  component, zero behavior change) layered in the app's z-order.
- POST /mcp: stateless streamable-HTTP MCP server (hand-rolled
  JSON-RPC, no SDK) with list_avatar_options, generate_avatar, and
  random_avatar tools returning share URL + image URL + markdown.
- public/llms.txt: concise spec of the URL params, API, short codes,
  and MCP endpoint for agents.
- index.html: schema.org WebApplication JSON-LD and pre-hydration
  descriptive content inside #root so no-JS crawlers see a real page.
- README: For LLMs & agents section; documents the append-only
  constraint on config.json option arrays.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New 'For developers & agents' card below the generator: copy-paste
examples for /api/avatar.svg (with a live example image rendered by
the API itself), the claude mcp add command, and short share links,
linking to /api/options, llms.txt, and GitHub. Layout-main becomes a
flex column so the two cards stack.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bluerssen

Copy link
Copy Markdown
Contributor Author

Added an on-page "For developers & agents" section per Brian — copy-paste examples for the image API (with a live API-rendered avatar), the MCP add command, and share links. Screenshots verified at desktop and mobile widths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant