JAI Pastebin Publisher
by whit3cat33
README.md
# JAI Pastebin Publisher
**English** | [Русский](README.ru.md)
A tiny, dependency-free **MCP server** that takes a JustMC (Creative+) module JSON
produced with the **@JAI** skill, uploads it to **Pastebin**, and returns a raw URL
that can be imported in-game. Please note that this is vibecoded and compatibility has
only been tested only for OpenCode so far.
- **Zero dependencies** — pure Python standard library (Python 3.8+).
- **Transport** — stdio JSON-RPC 2.0 (Model Context Protocol).
- **Privacy first** — the Pastebin API key is read from the environment or a
git-ignored file, never hard-coded.
## Tools
| Tool | Purpose |
|------|---------|
| `publish_module` | Upload a module to Pastebin and return `raw_url` + the `/module load-url` command. |
| `validate_module` | Validate module JSON without uploading. |
| `list_local_modules` | List modules cached locally in `modules/`. |
| `server_status` | Server state: modules folder, key availability, Pastebin API endpoint. |
### `publish_module` parameters
- `content` *(required)* — module JSON as text;
- `name` — paste title / file name (defaults to the module `id` / `name`);
- `api_dev_key` — Pastebin key (optional if set via env or file);
- `privacy` — `0` public, `1` unlisted *(default)*, `2` private;
- `expire` — `N` (never, default), `10M`, `1H`, `1D`, `1W`, `2W`, `1M`, `6M`, `1Y`.
## Install
No installation step is needed — just clone the repo:
```bash
git clone https://github.com/whit3cat33/JAI-pastebin-mcp.git
cd JAI-pastebin-mcp
```
Or just tell your AI-agent to install the MCP server for you. ;)
## Pastebin API key
You need a Pastebin `api_dev_key`
(get one at https://pastebin.com/doc_api — "Your Unique Developer API Key" in your
account). The key is resolved in this order (first hit wins):
1. tool argument `api_dev_key`;
2. environment variable `JMC_PASTEBIN_KEY`;
3. file `pastebin_key.txt` next to the script;
4. file `%USERPROFILE%\.pastebin_api_key` (or `~/.pastebin_api_key`).
Options 2 or 3 are recommended so the key never lands in your code or shell history.
```bash
# option 3: file next to the script
cp pastebin_key.example.txt pastebin_key.txt
# then edit pastebin_key.txt and paste your key
```
## Run
```bash
python jmc_pastebin_server.py
```
You normally don't start it by hand — your MCP client spawns the process from its
config. The server logs to **stderr**; **stdout** stays clean for the MCP protocol.
## Connect to OpenCode
Add the server to `opencode.json` (or your client's MCP config) under `mcp.servers`:
```json
{
"mcp": {
"servers": {
"jmc-pastebin-server": {
"type": "local",
"command": ["python", "/absolute/path/to/JAI-pastebin-mcp/jmc_pastebin_server.py"],
"environment": {
"JMC_PASTEBIN_KEY": "<your_api_dev_key>"
}
}
}
}
}
```
`environment` can be omitted if the key lives in `pastebin_key.txt`. Restart your
client after editing the config.
## Workflow with @JAI
1. Get a finished module JSON from the @JAI skill.
2. Call the **`publish_module`** MCP tool with `content` set to the JSON text.
3. The tool returns a `raw_url` and a ready command:
```
/module load-url https://pastebin.com/raw/AbCdEfGh
```
4. Run that command in-game on JustMC — the server downloads and imports the module.
## Example
See [`example/welcome.json`](example/welcome.json) — on player join, a welcome
message is sent to chat.
## Notes
- Every module is always saved locally to `modules/<name>.json` — even if the
Pastebin upload fails (then `status: "cached"` with an `errors` field).
- Pastebin limits paste size (free accounts ~512 KB) and request rate; very large
modules may fail to upload.
- The `privacy` / `expire` settings affect how long the link stays reachable.