Skip to main content
Glama
README.md
# EmpirePanel MCP

![EmpirePanel MCP — your game servers, run by your AI assistant, with your permissions](marketing/readme/social-preview.png)

A [Pterodactyl 2.0](https://pterodactyl.io) panel extension that turns your panel into a remote
[Model Context Protocol](https://modelcontextprotocol.io) (MCP) server. Panel users connect an AI agent (Claude Code,
Claude Desktop, Cursor, VS Code, Codex and others) to the game servers they already have access to. Sign-in is done in
the browser (OAuth), and every user decides what their agent may do. Administrators get one page to control it all.

> Português: [docs/README.pt-BR.md](docs/README.pt-BR.md)

**Status:** `0.1.3`, in development. Not ready for production.

## How it works (for users)

1. Open the panel, go to **Account → AI Agent** and press **Copy prompt**.
2. Paste the prompt into your AI agent. It adds the panel as an MCP server in your settings.
3. The first time the agent uses it, a browser window opens on the panel. Check the agent name and press **Approve**.
4. Ask the agent things like "restart my Minecraft server" or "make a backup and then update the modpack".

You can change what the agent may do (which servers, how much power, which tool groups) or disconnect it at any time
on the same screen. Per-client instructions are in [docs/clients.md](docs/clients.md).

## Screenshots

**Account → AI Agent:** connect in one paste, then decide what the agent may touch.

<p>
  <img src="marketing/readme/connect.png" alt="Connect your agent: copy prompt and per-app commands" width="49%">
  <img src="marketing/readme/permissions.png" alt="What the agent can do: allowed servers, level and tool groups" width="49%">
</p>

**Approve in your browser** and see every tool, agent and action:

<p>
  <img src="marketing/readme/consent.png" alt="Consent screen shown in the browser" width="38%">
  <img src="marketing/readme/agents-activity.png" alt="Connected agents and recent agent actions" width="60%">
</p>

![Available tools, grouped and explained](marketing/readme/tools.png)

**Admin → MCP:** usage overview, who can use it, tool groups, limits and safety.

<p>
  <img src="marketing/readme/admin.png" alt="Admin overview and general settings" width="55%">
  <img src="marketing/readme/admin-limits.png" alt="Admin security and limits" width="43%">
</p>

## Features

- **57 tools in 12 groups** for users (listed below), plus **12 administrator tools** that are **off by default**.
  Besides the basics, the agent can read big files in pages or with a filter, edit a file safely (it refuses if the file
  changed meanwhile), search through a server's files, wait for a console line after a command or a power action,
  look inside a mod `.jar` (what mod it is, its dependencies, a `.class` outline) and get a ready-to-use upload link for
  large files.
- **Three levels per user**: `read` (look only), `standard` (change things, nothing that destroys data) and `full`
  (delete, restore, reinstall, kill). Admins set the highest level anyone may pick.
- **Per-user allowed servers**, including "All servers (includes new ones)" or a hand-picked list.
- **Per-user tool groups**: turn off whole areas (for example databases) for your own agent.
- **Connected agents list** with a Disconnect button, and a list of recent agent actions (audit).
- **Confirmation for risky tools**: tools that change something need an explicit confirmation from the agent.
- **Admin page**: kill switch, who may use it, limits, download domains and the addresses shown to users, plus usage
  overview and all connections.
- Everything goes through the panel's own Client API, so panel permissions and the activity log still apply. Entries
  an agent causes are tagged **via MCP** in the panel's activity log.
- A server that is suspended, installing, restoring a backup, being transferred or on a node in maintenance is not
  changed by the agent; it is told why.
- **E-mail notice** when a new agent connects to your account (needs the panel's mail to be configured).
- Honors the panel's **two-factor** requirement: an account that must have 2FA cannot connect an agent without it.

### Tools

| Group | Tools |
|---|---|
| `servers` | `list_servers`, `server_details`, `server_status`, `server_activity`, `rename_server` |
| `power` | `power` (start, stop, restart, kill; can wait until the state is reached) |
| `console` | `read_console`, `send_command`, `wait_for_console` |
| `startup` | `list_startup`, `set_startup_variable`, `set_docker_image` |
| `files` | `list_files`, `read_file`, `search_files`, `inspect_archive`, `write_file`, `edit_file`, `create_folder`, `move`, `copy_file`, `compress`, `decompress`, `chmod`, `delete_files`, `file_download_link`, `upload_file_url` |
| `mods` | `pull_url` |
| `backups` | `list_backups`, `create_backup`, `backup_download_link`, `lock_backup`, `restore_backup`, `delete_backup` |
| `databases` | `list_databases`, `create_database`, `rotate_database_password`, `delete_database` |
| `schedules` | `list_schedules`, `create_schedule`, `update_schedule`, `run_schedule`, `delete_schedule`, `create_task`, `update_task`, `delete_task` |
| `network` | `list_allocations`, `add_allocation`, `set_allocation_note`, `set_primary_allocation`, `remove_allocation` |
| `users` | `list_permissions`, `list_subusers`, `create_subuser`, `update_subuser`, `remove_subuser` |
| `reinstall` | `reinstall_server` |
| `admin` | `admin_list_nodes`, `admin_list_eggs`, `admin_list_users`, `admin_list_all_servers`, `admin_server_info`, `admin_create_server`, `admin_update_build`, `admin_update_startup`, `admin_suspend_server`, `admin_unsuspend_server`, `admin_reinstall_server`, `admin_delete_server` |

> **Administrator tools act on the whole panel, not on one server** (create and delete servers, change limits, suspend,
> list every user). They are hidden and refused unless **all three** hold: the admin setting `allow_admin_tools` is on
> (default **off**), the user is a root administrator, and that user switched on the `admin` group on their own AI Agent
> screen. They use the user's own key through the Application API, and deleting a server needs its exact name. Turn
> them on only if you want an agent to administer the panel.
- English and Brazilian Portuguese (follows the panel language).

## Requirements

- Pterodactyl panel **2.0.0-beta.2 or newer** (tested on 2.0.0-beta.4), PHP 8.3+.
- The panel must be reachable over HTTPS at its `APP_URL`.
- One small change in the panel's own nginx config is required (see "Required: the panel's own nginx" below).

## Install

Get the `.pteroext` package: the ready-to-install file is distributed on BuiltByBit, or build it yourself from this
source with `scripts/package.sh` (see [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)). GitHub releases contain the source
code only. Then either:

- **Admin → Extensions → Install**, choose the file, tick **Enable after install**; or
- on the panel host:

  ```bash
  php artisan p:extension:install /path/to/empire-mcp.pteroext --enable
  chown -R www-data:www-data /var/www/pterodactyl/extensions /var/www/pterodactyl/public/assets/extensions
  ```

To **update** to a newer version, install the new file with `--replace` (settings, connections and the enabled state
are kept): `php artisan p:extension:install /path/to/empire-mcp-<new>.pteroext --replace`. In the official Docker image
the web user is `nginx`, so use `chown -R nginx:nginx /app/extensions /app/public/assets/extensions`.

If you run the panel in Docker, keep `/app/extensions` and `/app/public/assets/extensions` on volumes, or the
extension disappears when the container is recreated (the panel's example Compose file already does this). Users must
reload the panel after the install.

### Required: the panel's own nginx

Strict MCP clients ask for their OAuth discovery documents at the **site root** (`/.well-known/oauth-protected-resource/mcp`,
`/.well-known/oauth-authorization-server/mcp`, `/.well-known/openid-configuration/mcp` and the same two without `/mcp`).
The extension serves those routes itself, but the panel's own nginx config (the official Docker image and the documented
native config) has `location ~ /\. { deny all; }`, which answers **403** for `/.well-known/...` and
`/mcp/.well-known/...` before PHP sees them. `/mcp` itself works, so only OAuth discovery fails. Add these blocks to the
panel's nginx config, **before** the `location ~ \.php$` block:

```nginx
    # EmpirePanel MCP: OAuth discovery and MCP routes. Prefix (^~) matches skip the dotfile deny below,
    # which would otherwise block /.well-known/ and /mcp/.well-known/. Everything still goes to PHP.
    location ^~ /.well-known/oauth- {
        try_files $uri /index.php?$query_string;
    }
    location ^~ /.well-known/openid-configuration {
        try_files $uri /index.php?$query_string;
    }
    location ^~ /mcp/ {
        try_files $uri /index.php?$query_string;
    }
```

Then test and reload (Docker image: `docker exec <panel> nginx -t && docker exec <panel> nginx -s reload`). Where the file
lives and the details are in [docs/reverse-proxy.md](docs/reverse-proxy.md). Check:

```bash
curl -s https://panel.example.com/.well-known/oauth-authorization-server/mcp
```

It must return JSON that contains the `issuer`. A 403, HTML or a 404 means the step is missing. Rewrites for a proxy in
front of the panel (Traefik, Caddy, Apache) are optional and also in that file.

### First configuration

By default only **root administrators** can use MCP (`access_mode = admins`). Open **Admin → MCP**, choose who may
use it, review the limits, and save.

## Configuration

Admin → MCP. Defaults in the second column.

| Setting | Default | Meaning |
|---|---|---|
| `enabled` | on | Kill switch. Off: `/mcp` answers 503 and no new connections are granted. |
| `access_mode` | `admins` | Who may use MCP: `all` users, `listed` users, or `admins` only. |
| `allowed_users` | empty | Usernames or emails (comma or new line) for `listed`. |
| `max_level` | `full` | Highest level any user may choose: `read`, `standard` or `full`. |
| `enabled_groups` | all | Tool groups available at all. |
| `accept_api_keys` | on | Also accept a raw `ptlc_` Client API key as Bearer token (for clients without OAuth). |
| `access_token_ttl` | 3600 s | OAuth access token lifetime (300-86400). |
| `refresh_token_ttl_days` | 30 | Refresh token lifetime, renewed on use (1-365). |
| `max_connections_per_user` | 10 | Active connections per user (1-100). |
| `rate_limit_per_minute` | 120 | Tool calls per user per minute. |
| `max_read_kb` | 256 | Largest file `read_file` returns. |
| `max_write_kb` | 512 | Largest file `write_file` writes. |
| `download_domains` | Modrinth, CurseForge, GitHub, NeoForge, Forge, Fabric hosts | Hosts the URL-download tool accepts (exact or subdomain). Empty disables the tool. |
| `sftp_host` | empty | Overrides the SFTP host shown to users (`host` or `host:port`). |
| `database_host_note` | empty | Text added after database host output, e.g. "internal only". |
| `server_name` | `pterodactyl` | Name of the MCP server in prompts and instructions. |
| `extra_instructions` | empty | Extra text appended to the instructions sent to agents. |
| `internal_api_url` | empty (= `APP_URL`) | Base URL for the extension's own calls to the panel API, e.g. `http://127.0.0.1`. |
| `internal_api_host` | empty (= host of `APP_URL`) | `Host` header for those calls when `internal_api_url` is an IP. |
| `audit_retention_days` | 180 | Audit rows older than this are deleted. |
| `allow_admin_tools` | off | Lets root administrators use the 12 `admin` tools (they must also switch the group on). Off hides them from everyone. |
| `notify_on_connect` | on | E-mail the user when a new agent connects. Skipped silently when the panel's mail is not configured. |

## Security model

- **OAuth 2.1 with PKCE (S256)**, dynamic client registration for public clients, exact redirect URI match, rotating
  refresh tokens (reuse of an old one revokes the connection; older access tokens die at each refresh). Tokens are
  stored **hashed**. Issuer identification (RFC 9207) and strict resource indicators (RFC 8707) are enforced.
- Approving a connection creates **one panel Client API key** for that user. It shows in **Account → API
  Credentials** (memo `MCP — <client>`) and disconnecting deletes it.
- Approval works only from a signed-in browser session, never from an API key.
- **The panel's permissions are always enforced**: the agent can do only what that user can do in the panel, further
  limited by the user's own choices and the admin's limits.
- Destructive or changing tools need an explicit `confirm`; `kill`, delete, restore and reinstall need level `full`.
- Text that comes from game servers (files, logs, console, activity) is marked as **untrusted** so agents do not obey
  instructions hidden in it.
- No outbound calls except to the panel itself (loopback), `HEAD` checks of allow-listed download hosts, and one
  exception: `inspect_archive` downloads the archive once from the signed link the panel returns for that server's node
  (no redirects, size-capped at 16 MB, kept in memory, never executed or written to disk).
- Regular expressions, archives and paths coming from an agent are validated and bounded (length, size, time).
- Requests with a foreign `Origin` header are rejected. Request bodies are limited to 1 MB.
- The audit log records user, tool, server and result, never arguments or file contents.

Report vulnerabilities as described in [SECURITY.md](SECURITY.md).

## Limitations

- `read_console` returns at most the **last 100 lines** (a Wings limit); it is not a live stream.
- The panel rate-limits root routes at **120 requests per minute per client IP**. Behind Cloudflare or another proxy,
  configure the panel's trusted proxies so the real IP is used, or every user shares one limit.
- Responses are plain JSON (no server-sent events); GET on `/mcp` answers 405.
- Pterodactyl 2.0 is in beta; extension APIs may change.

## Uninstall

Admin → Extensions → remove, or `php artisan p:extension:remove empire-mcp`. The tables `ext_empire_mcp_*` and the
settings are **kept** so a reinstall brings them back. Delete the tables by hand to remove the data. Panel API keys
named `MCP — …` can be deleted in API Credentials.

## Development

See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) and [docs/SPEC.md](docs/SPEC.md).

## Support

Discord: <https://empirecommunity.org/discord>. Issues: the GitHub issue tracker. Security: see
[SECURITY.md](SECURITY.md).

## License

GNU General Public License v3.0. Made by [EmpireCommunity](https://github.com/EmpireCommunity).