@sleeperhit/mcp-server
A Model Context Protocol server that exposes the
Sleeper Hit Studio B2B Story API (/api/v1) as MCP tools. Point any
MCP-capable agent — Claude Desktop, Claude Code, Cursor, etc. — at it and the
agent can build a story end-to-end: ingest sources, plan, approve, generate,
and refine artifacts.
It is a thin, faithful wrapper over the REST API. Tool names and endpoint paths
track docs/agents/api-reference.md. For
the authoritative, live feature list, read the capabilities resource (it
fetches GET /api/v1/capabilities).
What an agent can do with this
The Story API is a pipeline. The tools mirror each stage:
- Sources —
add_source(typetext|markdown|url|pdf). Inline text isREADYimmediately;url/pdfare fetched asynchronously, so pollget_sourceuntilstatus: READY. Each source then runs a structured digest (digestStatus). - Plan —
create_planagainst a project with atarget(audience / objective / outcome) and one or moreartifactRequests. Returns a credit quote and runs the planner asynchronously; pollget_plan. - Approve —
approve_planonce the plan reachesREQUIRES_APPROVAL(skip this by passingautoApprove: truetocreate_plan).reject_planis the terminal alternative. - Job —
create_jobfrom anAPPROVEDplan. This reserves Studio Credits and queues generation. Pollget_job(orlist_artifacts). - Artifact —
get_artifactreturns the manifest: share URLs for a table read, video status, etc.render_artifact_videotriggers the opt-in MP4 (separate charge). - Refine / finalize —
refine_artifact(natural-language instruction) andfinalize_artifact. These are forward-compatible: if the endpoint is not live in the current API phase, the tool returns the real server response (e.g. a 404 envelope) rather than faking success.
Discovery: read the capabilities resource (sleeperhit://capabilities)
first — it tells the agent which source types, artifact types, statuses, and
quote pricing are live right now.
Tool catalog
| Tool | Endpoint |
|---|---|
create_project | POST /story-projects |
list_projects | GET /story-projects |
add_source | POST /story-projects/{projectId}/sources |
get_source | GET /story-projects/{projectId}/sources/{sourceId} |
list_sources | GET /story-projects/{projectId}/sources |
create_plan | POST /story-projects/{projectId}/story-plans |
get_plan | GET /story-plans/{planId} |
list_plans | GET /story-projects/{projectId}/story-plans |
approve_plan | POST /story-plans/{planId}/approve |
reject_plan | POST /story-plans/{planId}/reject |
create_job | POST /story-jobs |
get_job | GET /story-jobs/{jobId} |
list_jobs | GET /story-jobs |
cancel_job | POST /story-jobs/{jobId}/cancel |
list_artifacts | GET /story-jobs/{jobId}/artifacts |
get_artifact | GET /artifacts/{artifactId} |
render_artifact_video | POST /artifacts/{artifactId}/render-video |
refine_artifact | POST /artifacts/{artifactId}/refine (forward-compatible) |
finalize_artifact | POST /artifacts/{artifactId}/finalize (forward-compatible) |
capabilities (resource) | GET /capabilities |
Every tool returns JSON as text content: { "ok": true, ... } on success, or
{ "ok": false, "error": { code, message, status, requestId, details? } } with
isError: true on failure — the same { error: { code, ... } } envelope the
API returns, so agents can branch on error.code.
Install & build
From the monorepo root (pnpm workspace):
pnpm --filter @sleeperhit/mcp-server install pnpm --filter @sleeperhit/mcp-server build
This compiles src/ to dist/ and exposes the sleeperhit-mcp binary
(dist/index.js). To run it directly for a smoke test:
SLEEPERHIT_API_KEY=sh_... node packages/mcp-server/dist/index.js
Environment variables
| Variable | Required | Default | Notes |
|---|---|---|---|
SLEEPERHIT_API_KEY | yes | — | Customer API key sh_<18hex>_<64hex>. Create one at https://sleeperhit.studio/dashboard/api . Sent as Authorization: Bearer. Needs scopes for what you call: story:read/write, source:read/write, artifact:read, credits:read. |
SLEEPERHIT_BASE_URL | no | https://sleeperhit.studio | Override for staging/local. |
Credit-reserving and generation POSTs (sources, plans, jobs, render-video)
automatically attach a generated Idempotency-Key for safe retries.
MCP client config
Claude Desktop / Claude Code
Add to your MCP servers config (Claude Desktop:
claude_desktop_config.json; Claude Code: .mcp.json or
claude mcp add-generated config):
{ "mcpServers": { "sleeperhit": { "command": "sleeperhit-mcp", "env": { "SLEEPERHIT_API_KEY": "sh_...", "SLEEPERHIT_BASE_URL": "https://sleeperhit.studio" } } } }
If sleeperhit-mcp is not on your PATH (e.g. you built locally without a
global link), point command at the built file instead:
{ "mcpServers": { "sleeperhit": { "command": "node", "args": ["/absolute/path/to/packages/mcp-server/dist/index.js"], "env": { "SLEEPERHIT_API_KEY": "sh_...", "SLEEPERHIT_BASE_URL": "https://sleeperhit.studio" } } } }
Notes
- stdout is reserved for the MCP wire protocol; the server logs to stderr.
- The server validates
SLEEPERHIT_API_KEYat startup and exits non-zero if it is missing, so misconfiguration fails loudly.