Files
Eric Jungbauer 607168815b The Pirate Phase 1.b extension: Plex tools
Adds 4 read-only Plex tools using a new plex_get helper that sends
X-Plex-Token as a query param and Accept: application/json:
- plex_library_sections: per-section item counts
- plex_on_deck: in-progress items across all libraries
- plex_watch_history: recent watches with user-name resolution via /accounts
- plex_recently_added: latest additions across sections

Token sourced from Plex registry on Darrow (HKU per-user hive). Stored
in service_configs.plex. Plex paginated counts require BOTH
X-Plex-Container-Start and X-Plex-Container-Size in query string to
return totalSize — dropping Start makes Plex return the full library.

Pirate catalog: 20 → 24 tools.
2026-04-20 23:02:44 +00:00

26 lines
877 B
Python

"""Pirate tools — read-only functions the LLM can call.
Each tool module exports a TOOLS list of dicts shaped for Anthropic tool use:
{"name": str, "description": str, "input_schema": {...}, "read_only": True, "fn": callable}
The runtime loads all modules here and builds a combined catalog. The LLM picks
which tool to call; the runtime executes it and returns the result as a tool message.
"""
from . import sonarr, radarr, lidarr, whisparr, qbittorrent, storage, overseerr, plex
def build_catalog():
"""Return a list of all available tools across all modules."""
catalog = []
for mod in (sonarr, radarr, lidarr, whisparr, qbittorrent, storage, overseerr, plex):
catalog.extend(getattr(mod, "TOOLS", []))
return catalog
def find_tool(name):
for t in build_catalog():
if t["name"] == name:
return t
return None