This skill gives Claude full create, read, update, and delete control over short URLs on `mpm.to`, which runs YOURLS 1.10.2. Create and read always use the static signature token via `yourls-api.php`. Update and delete first attempt the signature token path (which requires the optional `mpm-api-extras` PHP plugin to be active on the server); if the plugin is not installed, they automatically fall back to an admin browser session authenticated via `admin/` with a time-limited login nonce. All credentials are stored in macOS Keychain under the service name `mpm.to-yourls`. The skill also includes the companion PHP plugin (`mpm-api-extras.php`) that extends the YOURLS API to support update and delete actions natively, eliminating the need for the session fallback.
---
## Skills
| Skill | What It Does |
|---|---|
| `mpm-url-shortener` | Manages short URLs on mpm.to. Triggers on: "shorten this URL", "create a short link", "make a short URL", "mpm.to", "short link for", "short URL for", "delete this short link", "update the short URL for", "what does mpm.to/XXX point to", "list our short URLs", "change the short code", "rename the keyword". Supports all CRUD operations: create (with optional keyword and title), read (expand + click stats), list (top/bottom/last/random), update (URL, keyword, and/or title), and delete (with confirmation prompt). |
**Keyword charset:**`mpm.to` is configured with a lowercase alphanumeric charset only. Uppercase letters, hyphens, underscores, and all other special characters are silently stripped by YOURLS. The script normalises keywords client-side before sending (`re.sub(r'[^a-z0-9]', '', raw.lower())`) and warns the user if normalisation changed their requested keyword.
**Admin login flow:** YOURLS 1.10.2 does not have a standalone `login.php`. The login form is served by `admin/` (index.php), which embeds a time-limited `<input name="nonce">` on the page. The script GETs `admin/` to extract this nonce, then POSTs to `admin/` with `{username, password, nonce, submit}`. Successful login is confirmed by the absence of `name="password"` in the response body.
**Admin page search:** With 671+ links in the database, the target keyword would not appear on page 1 of the admin table. The script searches the admin page using `?s=KEYWORD&search_in=keyword` so YOURLS filters the table to a single matching row before scraping nonce links from `admin-ajax.php` hrefs.
**Plugin detection:** On every update/delete attempt, the script probes for the `mpm-api-extras` plugin by checking whether YOURLS returns `errorCode: 400` with "unknown"/"missing"/"action" in the message body. If it does, the script falls back to the admin session path automatically.
**mpm.to root redirect:**`mpm.to/` 302-redirects to `www.mpmedia.tv` (WordPress). Admin session cookies are scoped to `.mpm.to`. Do not follow redirects when fetching `admin/` for the initial login nonce GET.
- YOURLS admin username + password (optional, for update/delete fallback without plugin)
---
## Troubleshooting
| Symptom | Fix |
|---|---|
| `Error: No signature token found` | Run `yourls_manager.py setup` and enter your signature token |
| `Error: Admin login failed` | Re-run `setup` and re-enter admin username + password; verify at mpm.to/admin/ |
| `Error: Could not find login nonce on admin page` | YOURLS admin page structure changed — check `mpm.to/admin/` manually; update regex if needed |
| `Error: Short code 'X' not found on admin page` | Keyword doesn't exist or was deleted; check with `read --keyword X` first |
| `requests` not found | Run `pip3 install requests --break-system-packages` |
| Update/delete via API returns "unknown action" | mpm-api-extras plugin is not active; either install it or ensure admin credentials are stored for session fallback |
| Admin cookies not persisting | `mpm.to/` root redirects to WordPress; do not follow redirects on the initial nonce GET (`allow_redirects=False`) |
| `Error: Could not extract edit-save nonce` | Admin page structure changed for the edit form; activate the plugin instead as a workaround |