Skip to main content
Glama
yoru-studio-mcp

yoru-studio-mcp

by yoruuuchan
README.md
# Yoru Studio

A self-hosted execution studio for a single creator.

Read this in [Simplified Chinese](README.zh-CN.md).

Yoru Studio is one person's workspace for turning ideas into finished creative work. You catch a spark in the inbox, pull it into a mother project, and break that into sub-projects: video, photo essay, long-form article, asset delivery. Then you plan storyboards, run field shoots with an offline-safe queue, log what actually happened, and close the loop with a retrospective. Deliverables live under platform versions, so the same cut can ship to Douyin, Bilibili or as a Xiaohongshu image set without duplicating the project.

It's written for one person, the creator. Install it and the whole system lives on one machine you control. No multi-tenant story, no team seats, no SaaS backend.

![Schedule page: a month calendar with shoots, deadlines and a review, fuzzy items like "the weekend", and the next 14 days on the right](docs/images/schedule.png)

<sub>Screenshots use demo data.</sub>

## What it does

The source is the final word on what it actually does. This list is a map, not the territory.

- **Inbox → mother project → sub-project → platform version.** That's the spine of the workflow. When you already know where a good idea belongs, a fast track drops it straight into an active sub-project.
- **Storyboards** with a list view and a board view. Drag to reorder, attach reference images to each shot, export to XLSX, or print a version for the set.
- **Schedule and calendar.** Exact times, all-day dates and fuzzy windows ("this week", "the weekend") share one calendar. Overdue is computed, not remembered, so nothing quietly rots.
- **Reminders and in-site notifications**, deduplicated in the database so a restart never fires the same alert twice.
- **Execution records** for shoots, re-shoots, screen recordings and writing sessions. Attach each record to the project layer that matches what you actually did.
- **Retrospectives**, light or full, with every field optional.
- **Attachments** in four shapes: uploaded images (with thumbnails), path pointers (e.g. `NAS/2026/Aug shoots/`), external links and text snippets. Soft-deleted files sit in a recycle bin for 30 days.
- **Field mode**, a mobile-first page for the set. If the network drops, edits queue in IndexedDB and sync when you're back online.
- **Full export**: a JSON + uploads bundle for takeout. Run it from the CLI or the settings page.
- **Backups**: scheduled online SQLite backups, plus optional restic scripts for encrypted off-site copies, with a real restore-drill runner.
- **MCP channel** for AI agents (Claude, ChatGPT, Codex, …). See [Connect AI agents over MCP](#connect-ai-agents-over-mcp).

![A video sub-project: lifecycle buttons, the checklist, and a five-shot storyboard with shot size, camera movement and status](docs/images/storyboard.png)

## Design choices

- Single user, single account. The data model has a workspace column, so a future multi-user version won't need to rebuild the schema. But everything in the shipped code assumes exactly one user.
- No external services required. SQLite on disk, files on disk. No Redis, no message queue, no third-party auth. You can run it on a $5/month VPS.
- Small footprint. The targets are 512 MiB for the app, 256 MiB for the scheduler and 128 MiB for the optional reverse-proxy sidecar. A 2 GiB VM is enough.
- The server doesn't build the frontend. The Vite bundle is built locally (or in CI) and shipped as pre-built files. Deployment machines never need Node.
- Content over ceremony. The retro form has no required fields. The schema is there to remind you what to think about, not to stop you from saving.

## Tech stack

- Backend: Python 3.12, FastAPI, SQLite, with `uv` for dependency management.
- Frontend: React 19 + TypeScript, built with Vite.
- Deployment: Docker Compose on a single host. Reverse proxy and TLS are your call; the options are under [Docker Compose](#docker-compose).
- Tests: pytest for the backend, vitest for the frontend.

## Connect AI agents over MCP

Yoru Studio runs a Model Context Protocol (MCP) server. Agents that speak MCP, like Claude Desktop, ChatGPT desktop, Codex CLI and Claude Code, can read your studio and append to it without you copy-pasting.

There are eight tools. Every write is append-only and idempotent.

Read (5):

- `list_projects`: mother-project list with counts.
- `get_project`: one mother project in full, including its sub-projects.
- `get_sub_project`: one sub-project, with its storyboard, execution records and retrospective folded in.
- `get_schedule`: upcoming events (14 or 30 days), everything overdue, and near-term fuzzy events.
- `get_inbox`: pending or discarded inbox items.

Write (3, all append-only, all idempotent):

- `capture_inspiration`: drop a spark into the inbox.
- `append_storyboard_shots`: atomically add N shots to a video sub-project's storyboard.
- `append_execution_record`: log a shoot, writing session or test.

Every write tool takes an `idempotency_key`. A retry with the same key returns the first result. A different payload with the same key is a hard conflict. Nothing an agent does can silently overwrite work you already have.

Two auth paths sit behind the same `/mcp` endpoint (spec §5.1 of `docs/spec/` in the source):

- A static Bearer token, for personal or single-agent use. You mint one long random string, store its `sha256` in the environment, and give the token to the agent. See [Generating hashed tokens](#generating-hashed-tokens).
- OAuth 2.0 with PKCE + Dynamic Client Registration, for connectors that expect it. ChatGPT's connector currently requires it.

You can run both at once. Both are optional: leave both unset and the `/mcp` route never mounts.

## Install and run

There are two ways to run it. From source suits development, or managing Python yourself. Docker Compose suits a stable single-host install.

### From source

Requires Python 3.12 and [`uv`](https://docs.astral.sh/uv/), plus Node 20+ for the frontend.

```bash
# 1. Install Python deps and set up the venv
uv sync

# 2. Initialize / migrate the database (creates ./data/studio.sqlite3)
uv run studio init-db

# 3. Start the API server on http://127.0.0.1:8000 (local mode — no auth)
uv run studio serve

# 4. In another terminal, run the frontend dev server
cd frontend
npm install
npm run dev        # http://localhost:5173, proxies to the API
```

Local mode binds to loopback and skips authentication, for developer convenience. To try the auth flow locally, see [Enabling remote mode](#enabling-remote-mode).

Other CLI commands:

```bash
uv run studio db-backup            # verified online SQLite backup
uv run studio db-restore <path> --confirm-database ./data/studio.sqlite3
uv run studio export               # full JSON + uploads takeout
uv run studio schedule-tick        # run the periodic maintenance jobs once
uv run studio hash-password        # interactively hash a password for STUDIO_AUTH_PASSWORD_HASH
```

Run the tests:

```bash
uv run pytest                      # backend
cd frontend && npm test            # frontend
```

### Docker Compose

The `docker-compose.yml` in this repo defines three services:

- `app`: FastAPI plus the built SPA.
- `scheduler`: a loop that ticks every 60 seconds and runs backups, reminders and retention.
- `cloudflared`: a reference reverse-proxy sidecar. Swap it for whatever fits your infrastructure.

Reverse proxy and TLS are deliberately left out of the app. Pick your own. Reasonable choices:

- Cloudflare Tunnel: the reference `cloudflared` service in `docker-compose.yml`, provisioned by `scripts/provision-cloudflare-tunnel.py`.
- Caddy or Nginx as a host-level reverse proxy, terminating TLS with your own certs.
- Tailscale Funnel for private-first hosting.
- Plain SSH forwarding with `-L 8000`, if you only want it on your own machine.

If you use Cloudflare Tunnel, keep or edit the `cloudflared` service. If you use another proxy, remove `cloudflared` from the compose file and set `STUDIO_TRUSTED_PROXY_IPS` in `.env.production` to your proxy's IP, so real client IPs land in the audit log.

Once your Docker host is ready, deploy like this:

```bash
# 1. Build the frontend locally — the server never builds it.
cd frontend && npm ci && npm run build && cd ..

# 2. Copy the env template and fill in the required secrets.
cp deploy/env.production.example .env.production
chmod 600 .env.production
$EDITOR .env.production

# 3. Generate a scrypt-hashed password for STUDIO_AUTH_PASSWORD_HASH.
uv run studio hash-password
# Paste the "password_hash" value into .env.production, single-quoted.

# 4. Build and start.
docker compose --env-file .env.production build
docker compose --env-file .env.production up -d
```

[`docs/deploy.md`](docs/deploy.md) has a longer walkthrough. It covers the reference layout, the backup automation scripts under `scripts/`, and the operation lock that the deploy and backup jobs share.

### Enabling remote mode

Remote mode turns the app from "local dev with no auth" into "public URL behind a proxy, with session cookies". At minimum, set:

- `STUDIO_MODE=remote`
- `STUDIO_SESSION_SECRET`: a random string, at least 32 characters.
- `STUDIO_AUTH_PASSWORD_HASH`: the output of `uv run studio hash-password`.
- `STUDIO_ALLOWED_HOSTS`: the exact hostname(s) the app will answer on. No wildcards; the app refuses to boot with `*`.
- `STUDIO_TRUSTED_PROXY_IPS`: if a reverse proxy sits in front, the IP(s) it uses to talk to the app.

In remote mode, the app refuses to boot if any required secret is missing or `allowed_hosts` is empty. This is deliberate. There is no "silently open" configuration.

## Configuration

Most values are environment variables, which keeps production Docker-friendly. Some can also live in a TOML file loaded with `--config` or `STUDIO_CONFIG`. See [`config/config.example.toml`](config/config.example.toml) for the shape.

Secrets are **env-only** by design. They are never read from the TOML config, so bundling the config file with a deployment can't leak them.

| Variable | Purpose | Default |
|---|---|---|
| `STUDIO_MODE` | `local` (loopback-only, no auth) or `remote` (session cookies + password) | `local` |
| `STUDIO_BIND_HOST` | Address the server binds to | `127.0.0.1` |
| `STUDIO_BIND_PORT` | Port the server binds to | `8000` |
| `STUDIO_ALLOWED_HOSTS` | Comma-separated list of hostnames accepted in `Host:` header (required in remote mode) | *(empty)* |
| `STUDIO_TRUSTED_PROXY_IPS` | Comma-separated list of proxy IPs whose `CF-Connecting-IP` / `X-Forwarded-For` to trust | *(empty)* |
| `STUDIO_SESSION_SECRET` | Random string ≥32 chars used to sign session cookies (required in remote mode) | *(empty)* |
| `STUDIO_AUTH_PASSWORD_HASH` | scrypt-hashed login password from `studio hash-password` (required in remote mode) | *(empty)* |
| `STUDIO_DATA_DIR` | Where the SQLite database lives | `./data` |
| `STUDIO_UPLOADS_DIR` | Where uploaded attachments live | `<data-dir>/uploads` |
| `STUDIO_BACKUPS_DIR` | Where SQLite online backups are written | `./backups` |
| `STUDIO_LOGS_DIR` | Where app logs go | `./logs` |
| `STUDIO_BACKUP_STATE_DIR` | Optional read-only path where the host's backup jobs drop `capacity.json` for the in-app status widget | *(unset — status shows `unknown`)* |
| `STUDIO_UPLOAD_MAX_FILE_BYTES` | Per-file upload cap | `26214400` (25 MiB) |
| `STUDIO_UPLOAD_QUOTA_BYTES` | Total upload quota per mother-project subtree | `2147483648` (2 GiB) |
| `STUDIO_UPLOAD_MAX_IMAGE_PIXELS` | Decompression-bomb guard | `40000000` (40M px) |
| `STUDIO_RADAR_TOKEN_HASH` | `sha256` hex of the intake channel's bearer token; unset disables the intake endpoint | *(unset)* |
| `STUDIO_MCP_TOKEN_HASH` | `sha256` hex of the MCP static-bearer token; unset disables the static-Bearer path | *(unset)* |
| `STUDIO_MCP_OAUTH_ISSUER_URL` | Public URL that hosts the OAuth AS metadata; setting it wakes the OAuth path | *(unset)* |
| `STUDIO_MCP_OAUTH_ALLOWED_REDIRECT_HOSTS` | Comma-separated hostnames allowed in DCR redirect URIs (loopback always allowed) | `chatgpt.com` |
| `STUDIO_MCP_OAUTH_ACCESS_TOKEN_TTL_SECONDS` | OAuth access-token lifetime | `3600` |
| `STUDIO_MCP_OAUTH_REFRESH_TOKEN_TTL_SECONDS` | OAuth refresh-token lifetime | `2592000` (30 days) |
| `STUDIO_MCP_OAUTH_CODE_TTL_SECONDS` | OAuth authorization-code lifetime | `300` |

### Generating hashed tokens

The intake endpoint and the MCP static-Bearer path both store `sha256(token)`, never the token itself. A leaked `.env.production` yields nothing replayable.

```bash
# Generate a token and its hash. The token goes to whichever caller needs it
# (your external intake, your MCP client). The hash goes into .env.production.
TOKEN=$(python -c "import secrets; print(secrets.token_urlsafe(32))")
printf %s "$TOKEN" | sha256sum | cut -d' ' -f1   # → STUDIO_RADAR_TOKEN_HASH / STUDIO_MCP_TOKEN_HASH
echo "$TOKEN"                                     # → give to the caller, nowhere else
```

## Feed the inbox from outside

An HTTP endpoint takes items from an external feeder: an RSS scraper, a topic-radar tool, a scheduled scrape job, whatever ingests content on your behalf. Bring your own upstream, wire it here, and items land in the inbox for you to triage.

The codebase nicknames this channel "radar" because it was first wired to an external content-radar tool. The endpoint itself is generic and works with any feeder that can speak HTTP.

Endpoint: `POST /api/inbox`

Authentication: `Authorization: Bearer <token>`. The server compares `sha256(token)` against `STUDIO_RADAR_TOKEN_HASH` in constant time. If that env var is unset, every Bearer call gets a 401 and the intake stays fully closed.

CSRF is not required on this path. The CSRF cookie defends against browser session replay, which is not a threat when the caller supplies its own bearer header.

Request body (JSON):

| Field | Type | Notes |
|---|---|---|
| `title` | string, required, ≤500 chars | The inbox item title. Blank / missing → `400`. |
| `first_reaction` | string, optional | Your one-line hot take. |
| `links` | string, optional | Free text. Pasted URLs are fine. |
| `radar_topic_id` | string, optional, ≤500 chars | Your feeder's identifier for this topic. Second-strongest dedup key. |
| `canonical_url` | string, optional, ≤2000 chars | Canonical URL of the item. Third-strongest dedup key. |
| `idempotency_key` | string, optional, ≤500 chars | Per-delivery unique key. Strongest dedup key. |

Dedup priority: `idempotency_key` > `radar_topic_id` > `canonical_url`. On a repeat delivery, the server returns the row that already exists instead of creating a second one, even if you already discarded or converted that row. A re-delivery must not overturn your triage decision.

Responses:

- `201 Created`: a brand-new row was inserted.
- `200 OK`: a repeat delivery matched an existing row (any status, including discarded or converted). Same body shape.
- `400 Bad Request`: `title` is missing or invalid.
- `401 Unauthorized`: bad or missing bearer token, or intake not configured.

Response body:

```json
{
  "item": {
    "id": 42,
    "title": "…",
    "source": "radar",
    "status": "pending",
    "created_at": "2026-08-12T12:34:56Z",
    "…": "…"
  },
  "deduplicated": false
}
```

Curl example:

```bash
curl -X POST https://studio.example.com/api/inbox \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Interesting minisite on typography systems",
    "first_reaction": "worth a look for the next essay",
    "links": "https://example.com/article",
    "canonical_url": "https://example.com/article",
    "idempotency_key": "myfeed-2026-08-12-a3f9"
  }'
```

## License

Copyright (C) 2026 yoruuuchan.

Yoru Studio is licensed under **GNU Affero General Public License, version 3, only** (AGPL-3.0-only). `LICENSE` contains the verbatim license text.

The short version: you may self-host, use and modify the code freely for your own creative work. If you run a modified version as a network service that other people interact with, you must offer them the source of that modified version. That is exactly what AGPL is designed to enforce. Its "network use" clause (§13) makes the reciprocal obligation trigger on running the software, not just on distributing it.

## What to expect

This is a personal project. It exists because one creator needed it and decided to share it.

- It's not a product. There is no roadmap anyone else is entitled to, no support SLA, and no promise that the next release won't break your setup.
- It's maintained on the author's own rhythm. Issues and pull requests are welcome, but replies come when they come.
- You self-host it. No hosted version exists, and there is no plan for one.
- Your data lives on your machine. Nothing calls home. Nothing is sent to a third party. That's the point of self-hosting, and it's also why nobody is going to rescue your data if you lose it. Take backups.

If any of that reads as "not for me", that's the honest signal. Please pick something else, no hard feelings.

## Contributing

Bug reports are welcome. Include enough detail that the bug can be reproduced on a clean checkout.

Feature requests: the project stays small on purpose and adds features only after real use exposes a need. A request that reads like "here is what I actually hit trying to use the app" is far more likely to land than one that reads like "here is a nice thing to have".

Pull requests: for anything larger than a one-file bug fix, open an issue first to check that the direction fits. The project is AGPL-3.0-only, so contributions must be compatible with that license. By opening a pull request, you agree that your contribution is under the same terms as the rest of the project.

## Attribution

Built by Yoru, Claude Fable 5, and GPT 5.6 Sol — the three of us.