Files

48 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2026-07-09 23:38:31 +02:00
# Plex Age Limit Setter
A FastAPI service that automatically sets content ratings on Plex media library items. Runs on a schedule and exposes an MCP (Model Context Protocol) endpoint for AI-agent-driven library management.
## Features
- **Scheduled sync** — Periodically applies a target content rating to all items in a specified library
- **Manual trigger** — `POST /trigger` to run an immediate sync (rate-limited to 1 req/min)
- **MCP tool server** — `POST /mcp` exposes Plex operations as MCP tools for AI agents (list libraries, search movies, set ratings, batch update, manage collections, refresh/analyze libraries)
- **Health endpoint** — `GET /health`
## Configuration
Config via environment variables (`.env` file):
| Variable | Default | Description |
|---|---|---|
| `PLEX_BASEURL` | `http://host.containers.internal:32400` | Plex server URL |
| `PLEX_TOKEN` | — | Plex auth token |
| `PLEX_USERNAME` | — | Plex username (fallback auth) |
| `PLEX_PASSWORD` | — | Plex password (fallback auth) |
| `TARGET_LIBRARY` | `BorneVideo` | Library section to manage |
| `TARGET_CONTENT_RATING` | `2` | Rating to apply to all items |
| `SCHEDULE_INTERVAL_MINUTES` | `5` | How often to run sync |
| `TRIGGER_RATE_LIMIT` | `60` | Max manual triggers per minute |
| `LOG_LEVEL` | `INFO` | Logging level |
## Quick start
```bash
cp .env.example .env # edit with your Plex details
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000
```
## Container (Podman Quadlet)
```bash
make build # podman build -t localhost/plex-age-setter:latest
make install # cp quadlet file + systemctl daemon-reload
make start # systemctl start plex-age-setter.service
make stop # systemctl stop plex-age-setter.service
make logs # journalctl -u plex-age-setter.service -f
```
## MCP Tools
The service speaks the [Model Context Protocol](https://modelcontextprotocol.io) at `POST /mcp`. Tools include: `list_libraries`, `get_library_stats`, `list_content_ratings`, `search_movies`, `set_content_rating`, `batch_set_content_rating`, `update_all_content_ratings`, `list_collections`, `refresh_library`, `analyze_library`, and more.