pebblehost-mcp
# pebblehost-mcp
An [MCP](https://modelcontextprotocol.io) server that lets Claude run a Minecraft server hosted on [PebbleHost](https://pebblehost.com): power, status, console, files, backups, startup settings and server versions, players, and schedules. It was built for a Paper server with plugins such as LuckPerms, EaglercraftXServer, and ViaVersion, but works with any PebbleHost game server.
By default every tool acts only on the one server set in `PEBBLEHOST_SERVER_ID`.
## Tools
Tools marked **destructive** start their description with `DESTRUCTIVE:` and say what can be lost, so Claude and MCP clients that ask for approval treat them with care.
### Power and status
| Tool | What it does |
| --- | --- |
| `get_server_status` | Online state (offline, starting, running, stopping), uptime, CPU, RAM, disk, and network usage against the plan's limits. |
| `set_power` | `start`, `stop`, or `restart`. Stop and restart shut down cleanly, saving the world. |
| `kill_server` | **Destructive.** Ends the process without saving. Only for when stop hangs. |
| `list_servers` | Lists the servers the tools may act on (only the configured one unless all servers are allowed). |
### Console and players
| Tool | What it does |
| --- | --- |
| `read_console` | The most recent console lines, up to a `lines` limit (the node keeps about the last 150), plus anything printed while listening. |
| `send_command` | Runs a console command, such as `lp user Steve parent set admin`, and returns the output printed over the next few seconds. |
| `list_players` | Online players, by running `list` and reading its output. |
For older output, or when the server is offline, use `read_file` on `logs/latest.log` with `tail_lines`.
### Files
| Tool | What it does |
| --- | --- |
| `list_files` | Lists a directory with sizes and modification times. |
| `read_file` | Returns a text file (configs, logs); `tail_lines` reads the end of long logs. Output is cut at 100,000 characters. |
| `write_file` | **Destructive** (replaces the whole file). Creates or overwrites a text file. |
| `edit_file` | Replaces exact text in a file. Writes nothing if the text is missing, or appears more than once without `replace_all`. |
| `upload_file_from_url` | Has the server download a URL into a folder, such as a plugin jar into `plugins/`. |
| `upload_local_file` | Uploads a file from the computer running this MCP server. |
| `get_file_download_link` | One-time browser download link for a file. |
| `create_folder` | Creates a directory. |
| `move_file` | Renames or moves a file or folder. |
| `delete_files` | **Destructive.** Moves files to PebbleHost's trash (restorable for 24 hours), or deletes permanently with `permanent`. |
| `restore_files` | Restores files deleted to the trash. |
| `compress_files` | Zips files or folders from one folder into an archive in that folder. |
| `extract_archive` | **Destructive** (overwrites files with the same names). Unzips an archive into its folder. |
File paths are relative to the server root, such as `server.properties` or `plugins/LuckPerms/config.yml`. Binary files (jars, worlds) can be uploaded, moved, archived, and deleted, but not read or written as text.
### Backups
| Tool | What it does |
| --- | --- |
| `list_backups` | Backups with size, export state, and restore fee, plus operations in progress. |
| `create_backup` | Starts a backup. |
| `get_backup_download_link` | Download link for a backup. PebbleHost only serves exported backups, so the first call on an unexported backup starts the export; call again once it finishes. |
| `restore_backup` | **Destructive.** Replaces the current files with the backup. If PebbleHost lists a restore fee, it refuses unless `accept_restore_fee` is set. |
| `delete_backup` | **Destructive.** Permanently deletes a backup. |
### Server settings and version
| Tool | What it does |
| --- | --- |
| `get_startup_settings` | Startup variables with current values, allowed options, and rules: on Minecraft servers these include the server jar and, where PebbleHost exposes them, version and Java settings. |
| `set_startup_variable` | **Destructive.** Changes one startup variable (such as the jar file or Java version). Takes effect on restart. |
| `list_server_versions` | Server software PebbleHost can install (such as Paper) and their version IDs. |
| `install_server_version` | **Destructive.** Installs another server software or Minecraft version. |
### Schedules
| Tool | What it does |
| --- | --- |
| `list_schedules` | Scheduled tasks with cron timing, state, and steps. |
| `create_schedule` | Creates a schedule with ordered steps (console commands or power actions with delays), such as a daily 4:00 restart with a warning. |
| `delete_schedule` | Deletes a schedule and its steps. |
## What the PebbleHost API does not support
These parts of the requested feature set are missing or limited because PebbleHost's API ([spec](https://api.pebblehost.com/)) does not offer them:
- **Java version as its own setting.** The API has no endpoint to choose the Java runtime or Docker image. Java can only be changed if PebbleHost exposes it as a startup variable on your server; `get_startup_settings` shows whether it does. Otherwise change it in the panel.
- **Online player list.** The API has no documented endpoint for players currently online. Its `/minecraft/players` endpoint lists players who have ever joined, without a documented format, so `list_players` uses the console `list` command instead and needs the server running. The Minecraft query protocol is not used.
- **Console history.** There is no REST endpoint for console output. The console comes from the node's websocket, which keeps only about the last 150 lines and nothing while the server is offline.
- **Backup options.** Creating a backup takes no name, file exclusions, or lock option. Download needs an export step first.
- **Archives.** Compress and extract run in the background with no completion signal, so check with `list_files`. The archive name is chosen by PebbleHost.
- **Binary file editing.** Files are read and written as text; jars and world files can only be uploaded, moved, archived, or deleted.
### Not yet verified against a live server
The tools were tested against a fake panel built from PebbleHost's API spec, and the live panel was checked to answer auth correctly, but not with a real server. Most likely to need adjustment:
- `upload_local_file` passes the destination folder as a `directory` parameter on the signed upload URL, as the Pterodactyl panel does; PebbleHost's spec does not document it.
- `list_server_versions` shows version fields as PebbleHost returns them, since the spec leaves them unspecified.
- `restore_files` passes the files' original paths; the spec does not say exactly how to name trashed files.
## Setup
Requires Node.js 20 or newer.
```sh
git clone https://github.com/numycode/pebblehost-mcp
cd pebblehost-mcp
npm install
npm run build
```
### Get an API key
1. Sign in to the [PebbleHost game panel](https://panel.pebblehost.com).
2. Open your account settings and generate an API key (PebbleHost's API docs: "visit your dashboard and click Generate API token").
3. Copy the key into your MCP client's config (below).
The key acts as your panel account: it can control every server your account can access, beyond what this MCP server does. Keep it out of the repository and out of chat transcripts, and revoke it in the panel if it leaks. If the panel offers an allowed-IPs field for the key, restrict it to the machine that runs this server.
### Configuration
The server reads its settings from environment variables only; nothing is stored in this repository.
| Variable | Required | Description |
| --- | --- | --- |
| `PEBBLEHOST_API_KEY` | Yes | Your panel API key. |
| `PEBBLEHOST_SERVER_ID` | Yes, for everything except `list_servers` | The server the tools act on: its 8-character identifier or UUID. Run `list_servers` once without it to find the identifier. |
| `PEBBLEHOST_ALLOW_ALL_SERVERS` | No | Set to `true` to let tools act on other servers on the account through their `server` argument. Off by default. |
| `PEBBLEHOST_PANEL_URL` | No | Panel base URL. Defaults to `https://panel.pebblehost.com`. |
`.env.example` lists them. `.env` files are git-ignored, but this server does not load them itself; your MCP client passes the variables.
### Claude Code
```sh
claude mcp add pebblehost \
-e PEBBLEHOST_API_KEY=your-key \
-e PEBBLEHOST_SERVER_ID=5f1680e2 \
-- node /absolute/path/to/pebblehost-mcp/dist/src/index.js
```
`claude mcp add` stores the key in your local Claude Code config (`~/.claude.json` by default), not in a project file. Avoid `--scope project`, which writes `.mcp.json` into the project you may commit.
### Claude Desktop
Add this to `claude_desktop_config.json` (Settings → Developer → Edit Config) and restart Claude Desktop:
```json
{
"mcpServers": {
"pebblehost": {
"command": "node",
"args": ["/absolute/path/to/pebblehost-mcp/dist/src/index.js"],
"env": {
"PEBBLEHOST_API_KEY": "your-key",
"PEBBLEHOST_SERVER_ID": "5f1680e2"
}
}
}
}
```
## Remote connector for claude.ai (Streamable HTTP)
With `MCP_TRANSPORT=http` the server speaks MCP's Streamable HTTP transport at `/mcp` instead of stdio, so claude.ai (web, Desktop, and mobile) can use it as a custom connector. The PebbleHost API key stays in the server's environment; Claude never sees it.
### How sign-in works
The server is its own OAuth 2.1 authorization server, built for one owner:
- **One pre-configured client.** You choose a client ID and secret and enter both in claude.ai under "Use your own OAuth client". Dynamic client registration is off and public clients (no secret) are refused, so nobody else can register a client.
- **Owner password.** When you click Connect in claude.ai, the server shows a sign-in page that asks for `MCP_OWNER_PASSWORD`. Only then does it issue an authorization code (S256 PKCE required, single use, 5 minutes) to `https://claude.ai/api/mcp/auth_callback`.
- **Tokens.** Access tokens last 1 hour and refresh tokens 30 days. They are HMAC-signed and bound to this server's `/mcp` URL, so they survive restarts. Changing the client secret or the owner password revokes every token.
- **Every `/mcp` request needs a valid access token.** Without one the server answers `401` with a `WWW-Authenticate` header pointing at its OAuth metadata, which is how Claude starts sign-in.
### HTTP configuration
These are in addition to the `PEBBLEHOST_*` variables above.
| Variable | Required | Description |
| --- | --- | --- |
| `MCP_TRANSPORT` | Yes | `http`. Defaults to `stdio`. The Docker image sets it. |
| `MCP_PUBLIC_URL` | Yes | Public HTTPS origin, no path, such as `https://mcp.example.com`. The connector URL is this plus `/mcp`. |
| `MCP_OAUTH_CLIENT_ID` | Yes | Any client ID you choose, such as `claude`. |
| `MCP_OAUTH_CLIENT_SECRET` | Yes | At least 32 characters. Generate with `openssl rand -base64 48`. |
| `MCP_OWNER_PASSWORD` | Yes | At least 12 characters; asked for on the sign-in page. Use a long random one. |
| `HOST`, `PORT` | No | Listen address. Default `127.0.0.1:3000`; the Docker image uses `0.0.0.0:3000`. |
### Run it with Docker behind a Cloudflare Tunnel
These steps are for a Linux machine at home (such as Fedora) with Docker. The tunnel makes an outbound connection to Cloudflare, so no router ports are opened and the container publishes no ports.
1. **Build the image** in a clone of this repository:
```sh
docker build -t pebblehost-mcp .
```
2. **Write an env file outside the repository**, readable only by you:
```sh
mkdir -p ~/.config/pebblehost-mcp
install -m 600 /dev/null ~/.config/pebblehost-mcp/env
```
Then fill it in:
```ini
PEBBLEHOST_API_KEY=...
PEBBLEHOST_SERVER_ID=...
MCP_PUBLIC_URL=https://mcp.example.com
MCP_OAUTH_CLIENT_ID=claude
MCP_OAUTH_CLIENT_SECRET=...
MCP_OWNER_PASSWORD=...
```
3. **Create the tunnel** in the Cloudflare dashboard (Zero Trust → Networks → Tunnels → Create a tunnel → Cloudflared). Copy its token. Add a public hostname, such as `mcp.example.com`, with service `http://pebblehost-mcp:3000`.
4. **Run the server and `cloudflared` on one Docker network:**
```sh
docker network create mcp
docker run -d --name pebblehost-mcp --network mcp --restart unless-stopped \
--env-file ~/.config/pebblehost-mcp/env pebblehost-mcp
docker run -d --name cloudflared --network mcp --restart unless-stopped \
cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <tunnel-token>
```
5. **Check it:** `curl -i https://mcp.example.com/mcp -X POST` should return `401` with a `WWW-Authenticate: Bearer ... resource_metadata=...` header.
Notes:
- Don't put Cloudflare Access, Bot Fight Mode, or a WAF challenge in front of this hostname. Claude connects from Anthropic's servers (`160.79.104.0/21`) and can't pass a browser challenge. The OAuth sign-in protects it instead. If you add WAF rules, allow that range.
- Rate limits use the client IP from `cloudflared`'s `X-Forwarded-For`, which the server trusts only from private and loopback addresses.
- To revoke Claude's access, change `MCP_OAUTH_CLIENT_SECRET` or `MCP_OWNER_PASSWORD` and restart the container.
### Add it in claude.ai
1. Open **Settings → Connectors** (for a Team or Enterprise plan, an Owner uses **Organization settings → Connectors**). Click **Add custom connector**.
2. Enter a name and the URL `https://mcp.example.com/mcp`.
3. Under **Advanced** (or the authentication step), choose **Use your own OAuth client** and enter the client ID and client secret from the env file.
4. Click **Add**, then **Connect**. A page from your server asks for the owner password; enter it and click **Approve**. Claude returns to the connector page, connected.
The connector works the same in Claude Desktop and mobile once added. Claude Code can keep using the stdio setup above.
## How it works
PebbleHost's current game panel exposes a Pterodactyl-style Client API at `https://panel.pebblehost.com/api/client`, documented in PebbleHost's OpenAPI spec at [api.pebblehost.com](https://api.pebblehost.com/) ([`api.yaml`](https://api.pebblehost.com/api.yaml)). Requests authenticate with `Authorization: Bearer <API key>`. Each tool maps to endpoints under `/api/client/servers/{server}/`: `resources`, `power`, `command`, `files/*`, `backups/*`, `startup/*`, `projects/*`, and `schedules/*`.
The console uses `GET /websocket`, which returns a short-lived token and the node's console websocket. `read_console`, `send_command`, and `list_players` connect to it using the [Pterodactyl Wings console protocol](https://docs.pterodactyl.io/v1/api/client-server/get-console-details): send `auth` with the token, then `send logs` for recent history, and collect `console output` events. The connection sends the panel URL as its `Origin`, as the daemon requires.
`edit_file` reads the file, replaces the text locally, and writes the whole file back, so an edit made in the panel between those two calls would be overwritten.
The older PebbleHost knowledge base article about a Multicraft-based "Game Panel API" (`help.pebblehost.com`) is marked deprecated by PebbleHost and does not apply to the current panel.
## Development
```sh
npm test # builds, then runs the tests against a fake panel and console websocket, and the HTTP transport's OAuth flow
```
TDQS
Scored across 32 tools
Most tools target clearly distinct resource+action pairs (set_power vs kill_server, write_file vs edit_file, delete_files vs restore_files, backups vs files), and destructive semantics are spelled out. The main overlap is install_server_version versus set_startup_variable, both of which can change the server jar/Minecraft version, and upload_local_file vs upload_file_from_url only differ by source.
Nearly all names follow consistent snake_case verb_noun (list_backups, create_backup, restore_backup, read_file). Minor deviations: singular/plural noun mixing (delete_files, list_servers, list_files vs read_file) and get_startup_settings vs set_startup_variable use different nouns for the same object.
32 tools is heavy, though the domain genuinely spans power, console, files, backups, schedules, and startup config. Some pairs could be consolidated (upload_local_file/upload_file_from_url, install_server_version/set_startup_variable), and a flat 32-tool surface raises selection cost.
Coverage is strong: lifecycle (power/kill/status), console/commands, full file CRUD plus upload/download/archive/trash, backups with restore and export, schedules, and startup/version management. Gaps: schedules can only be created or deleted (no edit/inspect of an existing schedule's steps) and there is no way to handle binary file content or local downloads beyond a one-time link.