mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Every MCP tool is now one /api/ai call with minimal text rendering;
the formatting, link building, and truncation logic it used to carry
untested lives (tested) in modules/ai. Tool names are unchanged for
external clients; a source-scan test guards the names and that the
proxy only reaches /api/ai. New lean blueprint endpoints back the two
tools that had no equivalent: GET archives/{id} (detail + snapshot
history) and GET videos/{id}/comments (paged author lines). Paged
content is read up to the old 50k-char bound. get_inventory_items now
takes the inventory slug (inventories are config-only; the old
numeric-id endpoint no longer exists). This also brings wrolpi_mcp
into version control (venv/ is already gitignored).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
"""HTTP client for the WROLPi API."""
|
|
import httpx
|
|
|
|
from wrolpi_mcp.config import API_BASE_URL, VERIFY_TLS
|
|
|
|
|
|
async def api_get(path: str, params: dict | None = None) -> dict:
|
|
"""GET request to the WROLPi API. Returns parsed JSON."""
|
|
async with httpx.AsyncClient(base_url=API_BASE_URL, verify=VERIFY_TLS, timeout=30.0) as client:
|
|
resp = await client.get(path, params=params)
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
|
|
async def api_post(path: str, json: dict | None = None) -> dict:
|
|
"""POST request to the WROLPi API. Returns parsed JSON."""
|
|
async with httpx.AsyncClient(base_url=API_BASE_URL, verify=VERIFY_TLS, timeout=30.0) as client:
|
|
resp = await client.post(path, json=json or {})
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
|
|
async def api_get_text(path: str) -> str:
|
|
"""GET request that returns raw text/HTML."""
|
|
async with httpx.AsyncClient(base_url=API_BASE_URL, verify=VERIFY_TLS, timeout=30.0) as client:
|
|
resp = await client.get(path)
|
|
resp.raise_for_status()
|
|
return resp.text
|