Skip to main content
Glama
README.md
# plex-mcp-server

An [MCP](https://modelcontextprotocol.io) server for a Plex Media Server, built on the official
**Plex Media Server OpenAPI spec** (v1.2.3, 260 operations). The spec is bundled in the package, so
you install nothing and point at nothing except your own Plex server: run it with `npx`, giving it
your server URL and token.

## Quick start

```bash
npx -y plex-mcp-server --url http://192.168.1.10:32400 --token YOUR_PLEX_TOKEN
```

### Claude Code

```bash
claude mcp add plex -- npx -y plex-mcp-server --url http://192.168.1.10:32400 --token YOUR_PLEX_TOKEN
```

### Claude Desktop (and other MCP clients)

```json
{
  "mcpServers": {
    "plex": {
      "command": "npx",
      "args": ["-y", "plex-mcp-server", "--url", "http://192.168.1.10:32400", "--token", "YOUR_PLEX_TOKEN"]
    }
  }
}
```

To keep the token out of the arguments, use environment variables instead:

```json
{
  "mcpServers": {
    "plex": {
      "command": "npx",
      "args": ["-y", "plex-mcp-server"],
      "env": { "PLEX_URL": "http://192.168.1.10:32400", "PLEX_TOKEN": "YOUR_PLEX_TOKEN" }
    }
  }
}
```

### Finding your token

See Plex's guide: [Finding an authentication token / X-Plex-Token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/).

## Options

| Flag | Environment variable | Meaning |
| --- | --- | --- |
| `--url`, `-u` | `PLEX_URL` | Server URL, e.g. `http://192.168.1.10:32400`. `http://` is assumed if no scheme is given. |
| `--token`, `-t` | `PLEX_TOKEN` | Your X-Plex-Token. |
| `--read-only` | `PLEX_READ_ONLY=1` | Register only tools that cannot change anything on the server. |
| `--timeout <ms>` | `PLEX_TIMEOUT_MS` | Request timeout (default 30000). |
| | `PLEX_API_VERSION` | Override the `X-Plex-Pms-Api-Version` header (default: the spec's version). |

The URL and token may also be given as positional arguments: `npx -y plex-mcp-server http://host:32400 TOKEN`.

## Tools

**Everyday tools**

| Tool | What it does |
| --- | --- |
| `plex_server_info` | Server name, version, platform and capabilities |
| `plex_list_libraries` | Libraries with their section ids, types and item counts |
| `plex_search` | Search across all libraries |
| `plex_browse_library` | Browse a library with filters (genre, year, rating, unwatched…) and sorting; genre/actor names are resolved to ids automatically |
| `plex_library_filters` | The filters and sorts a library supports, or the values of one field |
| `plex_get_item` | Full details: cast, ratings, files, audio and subtitle tracks |
| `plex_get_children` | Seasons of a show, episodes of a season, tracks of an album (or all leaves) |
| `plex_recently_added` | Recently added items per library |
| `plex_continue_watching` | The On Deck / continue watching hub |
| `plex_now_playing` | Active playback sessions |
| `plex_watch_history` | Watch history, optionally since a date or for one item |
| `plex_playlists` | Playlists, or the items in one |
| `plex_mark_played` ✎ | Mark an item played or unplayed |
| `plex_rate_item` ✎ | Rate an item |
| `plex_scan_library` ✎ | Scan one library or all libraries for new files |
| `plex_create_playlist` ✎ | Create a playlist from items |
| `plex_add_to_playlist` ✎ | Add items to a playlist |

**The whole API**

| Tool | What it does |
| --- | --- |
| `plex_list_operations` | Browse the spec's operations by tag, or search them |
| `plex_describe_operation` | Parameters, examples and response shape of one operation |
| `plex_api_read` | Call any GET operation by its operationId |
| `plex_api_write` ✎ | Call any operation that changes the server |
| `plex_api_docs` | The spec's guides, e.g. the media query filter syntax |

✎ = not registered with `--read-only`.

## Security notes

- The token is sent only to the server URL you give; redirects are followed only within that origin.
- The token is redacted from all tool output and error messages.
- Event-stream and websocket endpoints are not exposed; binary downloads are never fetched.

## Development

```bash
npm install
npm test
```

`npm test` builds the server and runs unit tests plus end-to-end tests that launch it over stdio
against a fake Plex server answering from the spec's own examples.

To run straight from GitHub without publishing to npm: `npx -y github:<owner>/<repo> --url … --token …`.

## License

MIT for this server's code. The bundled `spec/plex-media-server.openapi.json` is the Plex Media
Server OpenAPI specification, licensed under Apache-2.0; see [NOTICE](NOTICE).