Skip to main content
Glama
README.md
# Peekaboop

Peekaboop publishes a local static prototype — a single HTML file, a small hand-written site, or the output of a static build — and returns a live URL such as `https://my-demo-7f3k.peekaboop.page`. The upload goes to a Cloudflare Worker. The machine that published does not have to stay on.

This repository is the agent install surface. It is a Claude Code plugin plus a local stdio MCP server. The server is the only part that reads the files. Nothing here is published to npm.

The server needs Node.js 20 or newer and has no runtime dependencies.

## Install in Claude Code

In a Claude Code session:

```text
/plugin marketplace add ldiazderamond/peekaboop-plugin
/plugin install peekaboop@peekaboop
```

The same marketplace add works from a shell:

```bash
claude plugin marketplace add ldiazderamond/peekaboop-plugin
claude plugin install peekaboop@peekaboop
```

The plugin registers the `peekaboop` stdio server from `.mcp.json` and the `/share-preview` skill. Claude Code also exposes the skill as `/peekaboop:share-preview`. `/share-preview` works when that short name is not already taken.

```text
/share-preview
/share-preview my-demo
```

`my-demo` is a preferred slug. The Worker appends a random suffix, so the public URL looks like `https://my-demo-7f3k.peekaboop.page`. Running `/share-preview` again republishes that same URL.

## Install in Cursor

Add this to `~/.cursor/mcp.json` (or the project `.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "peekaboop": {
      "command": "npx",
      "args": ["-y", "github:ldiazderamond/peekaboop-plugin"]
    }
  }
}
```

Cursor does not load Claude Code skills on its own. The `publish`, `rotate_token`, and `delete_site` tool descriptions tell the agent to call the MCP server instead of zipping the site itself. You can also copy `skills/share-preview` into the project's Cursor skills directory if you want the `/share-preview` instructions loaded as a skill.

## Other stdio MCP clients

Any client that can spawn a stdio MCP server can use the same command:

```json
{
  "command": "npx",
  "args": ["-y", "github:ldiazderamond/peekaboop-plugin"]
}
```

From a checkout:

```bash
node bin/peekaboop.js
```

The process speaks newline-delimited JSON-RPC on stdin/stdout and does not write logs to stdout. Tools:

| Tool | Arguments | What it does |
| --- | --- | --- |
| `publish` | optional `path`, optional `slug` | Discover or take the given file/directory, zip it, upload it, and return the URL, expiry, and whether the site was created or replaced. |
| `rotate_token` | optional `path`, optional `slug` | Ask the Worker for a new bearer token and store it outside the project. |
| `delete_site` | optional `path`, optional `slug` | Delete the remote site and the local slug record. |

## What gets published

`publish` chooses the directory in this order:

1. The `path` argument, if you passed one. It must stay inside the project after both the project root and the target are canonicalized. A symlink anywhere in that path is rejected. A file publishes that file. A directory publishes the files inside it.
2. The first unique hit among `dist/index.html`, `build/index.html`, and `out/index.html`. If more than one of those exists, the tool lists them and uploads nothing.
3. `index.html` in the project root.
4. A single `.html` or `.htm` file anywhere else in the project. Several HTML files are listed so the agent can call `publish` again with `path`.

`node_modules`, `.git`, and dotfiles are skipped, including when `path` names them directly. Every path segment is checked, so `path: ".env"` and `path: "src/.env"` are refused. `.well-known/` is the exception, so `.well-known/security.txt` is included. Symlinks are rejected rather than followed when they are the requested path or a parent of it. A symlink found inside a real directory is skipped. `peekaboop.json` is not put in the zip. Drive-letter paths such as `C:/x` and `C:x` are refused.

v1 does not honour `.gitignore`. A gitignored file is still published when it is not a dotfile and does not sit under `node_modules` or `.git`. The plugin does not edit `.gitignore`.

A lone HTML file that is not already named `index.html` is stored in the zip as `index.html`, so the preview root renders it. Sibling assets are not included unless you pass the directory.

The zip is STORE mode (compression method 0). The Worker does not inflate. CRC-32 and sizes are written in the local file header. There is no data descriptor. File count and unpacked size are checked before file bytes are read. The zip is then built in memory and is not sent when it is over the cap: 500 files, 26,214,400 zip bytes (25 MiB), or 52,428,800 unpacked bytes (50 MiB).

## Slug, token, and project file

A successful publish writes `peekaboop.json` in the project directory:

```json
{
  "slug": "my-demo-7f3k"
}
```

That file is only the slug. Commit it so a teammate republishes the same URL.

The bearer token comes back on the first publish only. It is stored in `$XDG_CONFIG_HOME/peekaboop/tokens.json` when `XDG_CONFIG_HOME` is set, and otherwise in `~/.config/peekaboop/tokens.json`, keyed by slug. The directory is mode `700` and the file is mode `600`. It is never written into the project, and `rotate_token` does not return it. Print the stored token locally with:

```bash
peekaboop token
peekaboop token my-demo-7f3k
```

If `peekaboop.json` contains any other key, including a token, that key is removed and is not used as a credential.

`PEEKABOOP_TOKEN`, when set, overrides the token file for republish, rotate, and delete. That is the CI and teammate path. It is not sent on the first publish of a project that has no slug yet. A value left in the environment keeps overriding the file after `rotate_token`; update the variable to the new token. `peekaboop token` prints the file, not the environment variable.

If `peekaboop.json` has a slug and neither the environment variable nor the token file has a token, the publish is still sent. The Worker answers `401 token_required`. The tool tells the agent to get the token from whoever published first, set `PEEKABOOP_TOKEN`, or delete `peekaboop.json` to publish a new site.

## Environment

| Variable | Default | Role |
| --- | --- | --- |
| `PEEKABOOP_API` | `https://api.peekaboop.dev` | Origin of the Worker, without `/v1` and without a username or password. `https` is required. `http` is allowed only for `localhost`, `127.0.0.1`, and `::1`. |
| `PEEKABOOP_TOKEN` | unset | Bearer token that overrides the token file for an existing slug. |
| `XDG_CONFIG_HOME` | unset | When set, tokens are stored in `$XDG_CONFIG_HOME/peekaboop/tokens.json` instead of `~/.config/peekaboop/tokens.json`. |
| `CLAUDE_PROJECT_DIR` | process working directory | Project root Claude Code gives the plugin server. `peekaboop.json` is written here when the site lives inside it. |

## API contract

The Worker implements the fixtures in [`contract/`](contract/manifest.json). Summary:

- `POST /v1/publish` with `Content-Type: application/zip`. Optional `X-Peekaboop-Slug` and `Authorization: Bearer <token>`. Response `{ url, slug, token?, expiresAt, version, notice? }`. `token` is present on the first publish only. `notice`, when present, is shown to the user.
- `POST /v1/rotate` with the bearer token and `X-Peekaboop-Slug`. Response `{ token }`.
- `DELETE /v1/sites/:slug` with the bearer token. Success is `204` with an empty body. This client treats any `2xx` as success.
- Errors are `{ "error": { "code", "message" } }` with these statuses:

| Status | `error.code` |
| --- | --- |
| 400 | `invalid_zip`, `compressed_entry`, `unsafe_path`, `invalid_slug` |
| 401 | `token_required` |
| 403 | `invalid_token` |
| 404 | `site_not_found` |
| 410 | `site_expired` |
| 413 | `too_large`, `too_many_files` |
| 429 | `rate_limited` |

A preferred slug always receives a random suffix. Republishing with the token keeps the same URL. The preview goes idle 72 hours after the latest publish, and a republish before the 14-day limit revives that same URL. Only the 14-day hard cap returns `410 site_expired`. Then delete `peekaboop.json` and publish again for a new URL. The client shows the `expiresAt` the server returns and does not compute the deadline itself.

## Assumptions

- 25 MB and 50 MB are the byte counts in `contract/manifest.json`: 26,214,400 and 52,428,800.
- `DELETE` success in the fixture is `204` and an empty body. Any other `2xx` is also treated as success, and the body is ignored.
- `version` is returned to the agent when the server sends it. It is not stored in `peekaboop.json`.
- `PEEKABOOP_TOKEN` overrides the stored token only for a site that already has a slug. A first publish does not send it.
- On `site_not_found` or `site_expired` from delete, the local slug file and stored token are removed, and the server error is still returned.
- The public URL is whatever `url` the Worker returns. This client does not build the hostname.
- Header names are the ones in the fixtures. HTTP treats them as case-insensitive.
- v1 does not honour `.gitignore`.
- `PEEKABOOP_API` rejects `http` except for localhost, `127.0.0.1`, and `::1`, and rejects URLs that contain a username or password. Errors do not echo those credentials.

## Develop

```bash
npm test
npm run demo
```

`npm test` covers discovery, STORE-mode zips, the caps, token storage, and every error fixture against a local HTTP server. `npm run demo` publishes `samples/hello` through the stdio server to a mock that answers with the contract fixtures.