feat(mcp): hosted-asset upload + reference for the remote HTTP connector (tracking)

Open
#87 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
typescript

Research direction

This is a tracking issue for design work: it proposes a hosted-asset upload tool for the remote /mcp connector and explicitly says not to implement until decomposed and approved. Read the remote MCP tool definitions for primer_create_document and primer_add_version, plus the CSP/sanitizer config referenced in #68. Done means the open design questions (storage, CSP allowlist, access model, size caps) are answered and split into sub-issues.

Written by the indexing model from the issue text.

Description

enhancement triage

Problem

On the remote HTTP connector (type: "http" → /mcp, used by Claude Web and Desktop) the upload tools are inline-only:

primer_create_document.inputSchema = { title, description?, content: z.string(), format }
primer_add_version.inputSchema     = { documentId, content: z.string(), format, versionNote? }

The remote server runs on Primer's box and has no filesystem access, so the contentPath disk round-trip added in #76 cannot apply there. In the remote-connector topology the model is the only data path to the server — every byte that arrives as content was emitted by the model as tool-call output tokens. A document with a few hundred KB of inline SVG (or data: images) therefore pays that cost as output tokens on every version, and the whole payload re-transits on each primer_add_version.

This is the root cause behind "Claude Web still uploads hundreds of KB for documents with SVGs" — #76 solved it for the local stdio server (Claude Code / Codex) but the remote connector was never addressed and can't be addressed the same way.

Proposed direction (needs design + approval before implementation)

A hosted-asset upload + reference mechanism, extending the precedent set by #68 (Polygon brand fonts / hex-art served from /brand, referenced by URL from sandboxed artifacts):

  • A remote MCP tool (e.g. primer_upload_asset) that stores an asset once and returns a Primer-hosted URL (e.g. /assets/<id>) the artifact HTML references instead of inlining bytes.
  • Artifacts reference assets by same-origin URL; the sandbox/CSP already permits same-origin img/font loads (proven by #68).

What this does and does not buy us:

  • ✅ De-duplicates assets reused across versions; keeps the document small so re-versioning is cheap.
  • ✅ Consistent with the existing sandbox/CSP model.
  • ❌ Does not eliminate the first transmission — the model still emits the asset bytes once when calling the upload tool. There is no side channel around the model in the pure Claude Web case.

Open design questions (why this is triage, not agent-ready)

  • Storage: reuse the existing version-content storage (v1/<versionId>.html key scheme) or a new asset namespace? Lifecycle / GC for orphaned assets?
  • CSP / sanitizer: exact allowlist changes to permit /assets/<id> references from the sandboxed iframe. This touches CSP/sanitizer and per repo policy requires explicit approval before any change.
  • Access model: assets inherit the document's share-by-URL model, or separate?
  • Ownership / size caps / content-type allowlist for uploaded assets.

Next step

Decompose into session-sized sub-issues once the design questions above are answered. Do not implement until decomposed and approved.

Related: skill-guidance sub-task (steer Claude Web away from large inline SVG in the meantime) — see the linked issue. Root-caused in the investigation of #76 / #77.

Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
13h 38m
Merged PRs (30d)
24

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 0xPolygon/primer

All issues in 0xPolygon/primer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.