Skip to content

feat(mcp): add media_upload tool for programmatic media management #620

@Vallhalen

Description

@Vallhalen

Problem

The MCP server currently has no way to upload media files. The only option is CLI (npx emdash media upload) or the admin UI. This blocks full automation of content creation workflows.

Use case

When programmatically creating blog posts (e.g., via Claude Code + MCP), we need to:

  1. Generate or download a cover image
  2. Upload it to EmDash media storage
  3. Reference it in featured_image / hero_image fields

Currently step 2 requires dropping to CLI or using raw API with CSRF headers and multipart form data, breaking the MCP-based workflow.

Proposed solution

Add a media_upload MCP tool that accepts:

  • file — base64-encoded file data, OR
  • url — URL to fetch the file from
  • filename — desired filename
  • alt — alt text
  • contentType — MIME type

Returns the media item with id, storageKey, and url — ready to use in content_create/content_update.

Current workaround

# Upload via raw API with CSRF headers (fragile, requires active session)
curl -X POST "https://site.workers.dev/_emdash/api/media" \
  -H "Cookie: astro-session=SESSION_ID" \
  -H "X-EmDash-Request: 1" \
  -H "Origin: https://site.workers.dev" \
  -F "file=@image.png;type=image/png"

This works but is not discoverable, requires session management, and can't be done through MCP.

Environment

  • EmDash 0.5.0
  • MCP server enabled
  • Cloudflare Workers deployment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions