ShortsGen Docs

MCP Server

Connect Cursor, Claude Desktop, or any MCP-compatible client to ShortsGen. Generate shorts, manage jobs, and publish to Facebook from your AI assistant.

Overview

The ShortsGen MCP (Model Context Protocol) server exposes every user-facing REST API as MCP tools. Third-party applications — Cursor, Claude Desktop, custom agents, or your own backend — can generate shorts, check job status, manage credits, and publish to Facebook on behalf of a ShortsGen user account.

The MCP server lives in the mcp-server/ directory at the repo root. It proxies HTTP requests to your running ShortsGen app — it does not embed pipeline logic directly.

Architecture

MCP Client → MCP Server (stdio or HTTP) → ShortsGen REST API (/api/*) → your account

Prerequisites

  1. Node.js 20+ installed on the machine running the MCP server.
  2. A running ShortsGen app — locally with npm run dev or deployed to production.
  3. A ShortsGen account with credits (for generation tools).
  4. An API key created in the web app (see below). Keys are prefixed with sg_.
  5. Dependencies installed in both the repo root and mcp-server/ (npm install in each).

Quick start

  1. Start ShortsGen: npm run dev
  2. Sign in at /sign-in, open Settings → API keys, and create a key. Copy it immediately — it is shown only once.
  3. Set environment variables (see below).
  4. Run npm run mcp from the repo root.
  5. Add the server to Cursor or Claude Desktop (see configuration sections below).
  6. Test with the auth_health or get_credits tool in your MCP client.

Create an API key

API keys authenticate the MCP server (and any programmatic client) as your ShortsGen user. Each key is scoped to your account and can be revoked at any time.

  1. Sign in and navigate to Settings.
  2. Scroll to the API keys section.
  3. Enter a descriptive name (e.g. "Cursor MCP") and click Create key.
  4. Copy the full key (starts with sg_) and store it securely.
  5. Set it as SHORTSGEN_API_KEY in your MCP client configuration.

The MCP server sends Authorization: Bearer sg_… on every request. The app also accepts x-api-key.

Environment variables

Set your app URL once in NEXT_PUBLIC_APP_URL. In MCP client config (Cursor, Claude), pass the same URL as SHORTSGEN_BASE_URL.

VariableRequiredDescription
NEXT_PUBLIC_APP_URLYes (app)Set in your app .env (currently https://clips.adomicarts.com)
SHORTSGEN_BASE_URLYes (MCP)Set in MCP client config to the same value as NEXT_PUBLIC_APP_URL (https://clips.adomicarts.com)
SHORTSGEN_API_KEYYes*Your sg_… key from Settings. Not needed for auth_sign_up / auth_sign_in only.
MCP_HTTP_PORTNoHTTP transport port (default 3100)
MCP_HTTP_HOSTNoHTTP bind address (default 127.0.0.1)
MCP_HTTP_AUTH_TOKENRecommendedSeparate secret that protects the MCP HTTP endpoint (not the ShortsGen API)
.env for MCP server
# App .env — your public app URL
NEXT_PUBLIC_APP_URL=https://clips.adomicarts.com

# MCP client config — use the same URL as SHORTSGEN_BASE_URL
SHORTSGEN_BASE_URL=https://clips.adomicarts.com

# Required for most MCP tools — create in Settings → API keys
SHORTSGEN_API_KEY=sg_your_key_here

# Optional — HTTP transport (default 3100)
MCP_HTTP_PORT=3100
MCP_HTTP_HOST=127.0.0.1

# Recommended — protects the MCP HTTP endpoint itself
MCP_HTTP_AUTH_TOKEN=your-mcp-secret

Run the MCP server

stdio transport (default)

Used by Cursor, Claude Desktop, and most local MCP clients. The server communicates over stdin/stdout — no port binding required.

bash
# From the repo root (stdio — Cursor / Claude Desktop)
npm run mcp

HTTP transport

For remote third-party apps that connect over the network. Listens on port 3100 by default.

bash
# From the repo root (HTTP — remote clients)
MCP_HTTP_AUTH_TOKEN=your-mcp-secret npm run mcp:http

From mcp-server/ directly

bash
# Or from the mcp-server/ directory (loads NEXT_PUBLIC_APP_URL from parent .env)
cd mcp-server
npm install
SHORTSGEN_BASE_URL=https://clips.adomicarts.com SHORTSGEN_API_KEY=sg_your_key npm start
SHORTSGEN_BASE_URL=https://clips.adomicarts.com SHORTSGEN_API_KEY=sg_your_key npm run start:http

Cursor setup

Add the MCP server to Cursor via project or global MCP settings. Use the absolute path to your ShortsGen app directory for cwd.

.cursor/mcp.json
{
  "mcpServers": {
    "shotsgen": {
      "command": "npm",
      "args": ["run", "mcp"],
      "cwd": "C:/path/to/your/shotsgen/app",
      "env": {
        "SHORTSGEN_BASE_URL": "https://clips.adomicarts.com",
        "SHORTSGEN_API_KEY": "sg_your_key_here"
      }
    }
  }
}
  1. Create or edit .cursor/mcp.json in your project (or use Cursor Settings → MCP).
  2. Paste the configuration above — set SHORTSGEN_BASE_URL to your NEXT_PUBLIC_APP_URL (https://clips.adomicarts.com).
  3. Ensure ShortsGen is running before using MCP tools.
  4. Restart Cursor or reload MCP servers from settings.
  5. Open the MCP panel and verify shotsgen shows as connected.

Claude Desktop setup

Claude Desktop uses the same stdio configuration. Edit your Claude Desktop MCP config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "shotsgen": {
      "command": "npm",
      "args": ["run", "mcp"],
      "cwd": "/absolute/path/to/app",
      "env": {
        "SHORTSGEN_BASE_URL": "https://clips.adomicarts.com",
        "SHORTSGEN_API_KEY": "sg_your_key_here"
      }
    }
  }
}

Restart Claude Desktop after saving. Set SHORTSGEN_BASE_URL to your NEXT_PUBLIC_APP_URL (https://clips.adomicarts.com).

HTTP transport

Start the HTTP server with npm run mcp:http. Clients send MCP Streamable HTTP requests to:

MCP HTTP endpoint
POST http://127.0.0.1:3100/mcp
Authorization: Bearer your-mcp-secret
Content-Type: application/json

Health check (no auth required unless MCP_HTTP_AUTH_TOKEN is set on all routes — health is always open):

http
GET http://127.0.0.1:3100/health

When MCP_HTTP_AUTH_TOKEN is set, include Authorization: Bearer <token> on MCP requests. This token is separate from your ShortsGen API key — it only protects the MCP server endpoint.

Authentication

ShortsGen uses Better Auth with an API key plugin. When the MCP server sends a valid API key, the app treats the request as an authenticated session for your user — no browser cookies required.

  • Production use: always use an API key via SHORTSGEN_API_KEY.
  • Onboarding tools (auth_sign_up, auth_sign_in, api_key_create) can run without a key to create an account and first key.
  • Revoke compromised keys immediately in Settings → API keys.

Available tools

Each MCP tool maps to one ShortsGen REST endpoint. Tool responses are JSON returned as text content.

Auth & API keys

ToolHTTP endpoint
auth_healthGET /api/auth/ok
auth_sign_upPOST /api/auth/sign-up/email
auth_sign_inPOST /api/auth/sign-in/email
auth_sign_outPOST /api/auth/sign-out
auth_get_sessionGET /api/auth/get-session
api_key_createPOST /api/auth/api-key/create
api_key_listGET /api/auth/api-key/list
api_key_deletePOST /api/auth/api-key/delete

Generation & jobs

ToolHTTP endpoint
generate_shortsPOST /api/generate
get_job_statusGET /api/status/{jobId}
get_job_clipsGET /api/clips/{jobId}
list_jobsGET /api/jobs

generate_shorts accepts youtubeUrl, numVariations (1–8), and optional videoSettings (clipLength, exportQuality, captionStyle).

Credits & billing

ToolHTTP endpoint
get_creditsGET /api/credits
get_usageGET /api/usage
create_checkoutPOST /api/billing/checkout
confirm_checkoutPOST /api/billing/confirm

Facebook publishing

ToolHTTP endpoint
get_facebook_configGET /api/facebook/config
get_facebook_connect_urlGET /api/facebook/connect (returns OAuth URL)
get_facebook_statusGET /api/facebook/status
select_facebook_pagePOST /api/facebook/select-page
disconnect_facebookDELETE /api/facebook/disconnect
publish_to_facebookPOST /api/publish/facebook

Facebook publishing via MCP

Facebook OAuth requires a browser. The MCP flow uses a redirect URL returned by the API:

  1. Call get_facebook_connect_url — the response includes redirectUrl.
  2. Open that URL in a browser while signed in to ShortsGen and complete Meta OAuth.
  3. Call get_facebook_status to confirm connection and list Pages.
  4. Call select_facebook_page with the desired pageId.
  5. Generate shorts, then call publish_to_facebook with jobId and clipId. Uploads may take several minutes.

See also the Connections page for in-app Facebook setup.

Excluded endpoints

These endpoints are intentionally not exposed as MCP tools:

EndpointReason
POST /api/webhook/polarPolar payment webhook — server-to-server only
GET /api/webhook/polarInternal health probe
GET /api/facebook/callbackBrowser OAuth callback — not callable by agents

Troubleshooting

401 Unauthorized on API tools

Verify SHORTSGEN_API_KEY is set correctly, starts with sg_, and has not been revoked. Confirm SHORTSGEN_BASE_URL matches your NEXT_PUBLIC_APP_URL (https://clips.adomicarts.com).

MCP server fails to start

Run npm install in both the repo root and mcp-server/. Ensure Node.js 20+ is installed. Set NEXT_PUBLIC_APP_URL in your app .env and SHORTSGEN_BASE_URL in MCP config (https://clips.adomicarts.com).

Cursor shows disconnected

Use an absolute path for cwd. Ensure npm run dev is running. Restart Cursor after editing mcp.json. Check Cursor MCP logs for stderr output.

402 Insufficient credits

Purchase credits via the app or use create_checkout / confirm_checkout MCP tools.

HTTP transport connection refused

Confirm npm run mcp:http is running and MCP_HTTP_PORT is not blocked by a firewall. Test with GET /health first.