Skip to content

Temporary download URL delivery (deliver:'url')#8

Merged
flocom merged 1 commit into
mainfrom
feat/temp-download-url
Jun 7, 2026
Merged

Temporary download URL delivery (deliver:'url')#8
flocom merged 1 commit into
mainfrom
feat/temp-download-url

Conversation

@flocom

@flocom flocom commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Why

For remote use, returning a big base64 blob inline is heavy. This adds the option to host the rendered PNG temporarily and return a short download URL that auto-deletes after a TTL — so a client (Claude, a browser, your Mac) fetches it instead.

What

generate_screenshot / generate_batch gain:

  • deliver: inline (default, base64 image block) · url (temporary link) · both
  • ttlSeconds: lifetime of the URL (default 600, 10–86400)

Implementation:

  • filestore.ts — in-memory store keyed by an unguessable id, auto-evicted after the TTL (nothing on disk; gone on restart).
  • GET /files/:id serves the PNG (Cache-Control: no-store), 404 once expired. CORS-enabled so a browser can fetch it.
  • Public base URL resolved from X-Forwarded-Proto/Host (works behind the Cloudflare Tunnel) or PUBLIC_BASE_URL.
  • Over stdio (no HTTP server) url gracefully falls back to inline with a note.

Verified

  • deliver:'url' → tiny text response; fetching the link returns a valid image/png (200); unknown id → 404.
  • Auto-expiry: present immediately, gone after the TTL.
  • deliver:'both' → image + URL; stdio url → inline + note.

🤖 Generated with Claude Code

generate_screenshot / generate_batch gain a `deliver` mode:
- inline (default): PNG as a base64 image block, as before
- url: store the PNG in an in-memory TTL cache and return a temporary
  https://<host>/files/<id>.png link that auto-deletes after ttlSeconds
  (default 600). Keeps the MCP response tiny and is fetchable from a browser
  or another machine (reachable through the Cloudflare Tunnel).
- both: inline image + URL

New filestore.ts (memory-only, auto-eviction), a GET /files/:id endpoint, and
a public-base-URL resolver honoring X-Forwarded-* or PUBLIC_BASE_URL. Over stdio
(no HTTP server) url falls back to inline with a note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@flocom
flocom merged commit 322884d into main Jun 7, 2026
@flocom
flocom deleted the feat/temp-download-url branch June 7, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant