Fifth phase 1 PR from the plan on #1. Stacked on #8 (UI): this branch contains #8's commit, so merge #8 first; after that this PR shows only its own commit.
What it is
Thor's MCP server, built into the Flask app, following the wiki's checklist (Architecture/mcp-servers) like the Tinker, Wiki and Kuma servers:
Transport: stateless Streamable HTTP, POST https://thor.lotusguild.org/mcp, JSON-RPC 2.0 (single and batch). GET/DELETE answer 405, since there are no sessions or streams.
Discovery:/.well-known/oauth-protected-resource[/mcp] (RFC 9728). Without a token you get a 401 whose WWW-Authenticate names resource_metadata and the scopes.
Token checks, done by Thor itself against Authelia's JWKS: RS256 signature, isshttps://auth.lotusguild.org, audhttps://thor.lotusguild.org/mcp, exp, typ: at+jwt, client_id: thor-mcp, and scopes from the scp array. Group admin only, like the Kuma MCP.
Remote-* headers are never trusted. Every tool call is logged as one JSON line with the user, sub, tool, arguments and ok.
Tools
Tool
Scope
What
list_incidents
thor:read
active incidents and the last 7 days
get_incident
thor:read
everything on the incident page, plus attached tickets
what_covers
thor:read
Gandalf's and hwmonDaemon's pre-check for a host or scope ("what would Thor do")
thor_status
thor:read
last cycle, catching up, each source answering or blind, blind periods
list_known_conditions
thor:read
add_known_condition
thor:write
kind, subject (old host names work), optional ticket, and a reason (required, shown in every note)
end_known_condition
thor:write
attach_ticket / detach_ticket
thor:write
attach another app's symptom ticket to a Thor incident. Live, Thor comments "Root cause" on it; in shadow it's only recorded. Timeline-only incidents are refused.
Tools a token's scopes can't use aren't listed. Maintenance stays in Gandalf (thor#1).
Migration 4:incident_links (who attached which ticket, and when).
After merge (production setup; I'll do these step by step, like the Kuma MCP setup)
Authelia: add client thor-mcp: public, PKCE S256, two_factor, group admin; scopes thor:read/thor:write; audience https://thor.lotusguild.org/mcp; callback port 47826, or 47827 if the Gandalf MCP already took 47826. Back up first, validate-config, restart, check health.
NPM host 60: add location = /mcp and location ^~ /.well-known/oauth-protected-resource ahead of the Authelia-protected location /, with the Remote-* headers blanked. Back up the DB, nginx -t, reload.
Wiki: add a Thor row and the callback port to Architecture/mcp-servers.
Verify: a no-token POST gives 401 with resource_metadata; then claude mcp add ... thor and one read and one write.
Verification
147 tests pass, including 16 MCP tests: bad audience, client, typ, signer, expiry and scope all give 401; a non-admin gets 403; scopes filter tools/list; validation; attach and detach; DB away; batches.
Coverage is 98% with MariaDB. flake8, bandit and pip-audit are clean. No em or en dashes.
Fifth phase 1 PR from the plan on #1. **Stacked on #8 (UI)**: this branch contains #8's commit, so merge #8 first; after that this PR shows only its own commit.
## What it is
Thor's MCP server, built into the Flask app, following the wiki's checklist (`Architecture/mcp-servers`) like the Tinker, Wiki and Kuma servers:
- **Transport:** stateless Streamable HTTP, `POST https://thor.lotusguild.org/mcp`, JSON-RPC 2.0 (single and batch). `GET`/`DELETE` answer 405, since there are no sessions or streams.
- **Discovery:** `/.well-known/oauth-protected-resource[/mcp]` (RFC 9728). Without a token you get a 401 whose `WWW-Authenticate` names `resource_metadata` and the scopes.
- **Token checks**, done by Thor itself against Authelia's JWKS: RS256 signature, `iss` https://auth.lotusguild.org, `aud` https://thor.lotusguild.org/mcp, `exp`, `typ: at+jwt`, `client_id: thor-mcp`, and scopes from the `scp` array. **Group `admin` only**, like the Kuma MCP.
- `Remote-*` headers are never trusted. Every tool call is logged as one JSON line with the user, `sub`, tool, arguments and ok.
## Tools
| Tool | Scope | What |
|---|---|---|
| `list_incidents` | thor:read | active incidents and the last 7 days |
| `get_incident` | thor:read | everything on the incident page, plus attached tickets |
| `what_covers` | thor:read | Gandalf's and hwmonDaemon's pre-check for a host or scope ("what would Thor do") |
| `thor_status` | thor:read | last cycle, catching up, each source answering or blind, blind periods |
| `list_known_conditions` | thor:read | |
| `add_known_condition` | thor:write | kind, subject (old host names work), optional ticket, and a reason (required, shown in every note) |
| `end_known_condition` | thor:write | |
| `attach_ticket` / `detach_ticket` | thor:write | attach another app's symptom ticket to a Thor incident. Live, Thor comments "Root cause" on it; in shadow it's only recorded. Timeline-only incidents are refused. |
Tools a token's scopes can't use aren't listed. Maintenance stays in Gandalf (thor#1).
**Migration 4:** `incident_links` (who attached which ticket, and when).
## After merge (production setup; I'll do these step by step, like the Kuma MCP setup)
1. **Authelia:** add client `thor-mcp`: public, PKCE S256, `two_factor`, group `admin`; scopes `thor:read`/`thor:write`; audience `https://thor.lotusguild.org/mcp`; callback port 47826, or 47827 if the Gandalf MCP already took 47826. Back up first, `validate-config`, restart, check health.
2. **NPM host 60:** add `location = /mcp` and `location ^~ /.well-known/oauth-protected-resource` ahead of the Authelia-protected `location /`, with the `Remote-*` headers blanked. Back up the DB, `nginx -t`, reload.
3. **Wiki:** add a Thor row and the callback port to `Architecture/mcp-servers`.
4. **Verify:** a no-token POST gives 401 with `resource_metadata`; then `claude mcp add ... thor` and one read and one write.
## Verification
- 147 tests pass, including 16 MCP tests: bad audience, client, `typ`, signer, expiry and scope all give 401; a non-admin gets 403; scopes filter `tools/list`; validation; attach and detach; DB away; batches.
- Coverage is 98% with MariaDB. flake8, bandit and pip-audit are clean. No em or en dashes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- thor/web/mcp.py: stateless Streamable HTTP at POST /mcp (JSON-RPC 2.0), RFC 9728 metadata at
/.well-known/oauth-protected-resource[/mcp], 401 with resource_metadata. Tokens checked
against Authelia's JWKS: RS256, iss, aud (this server), exp, typ at+jwt, client_id thor-mcp,
scp array; group admin only; Remote-* headers never trusted; every tool call logged with the
user.
- Read tools (thor:read): list_incidents, get_incident, what_covers, thor_status,
list_known_conditions. Write tools (thor:write): add_known_condition, end_known_condition,
attach_ticket, detach_ticket. Tools a token's scopes can't use aren't listed.
- Migration 4: incident_links (who attached which ticket to which incident). attach_ticket
records an 'attach' action; in shadow nothing is sent, live sends a 'Root cause' comment.
- Incident page lists attached tickets. PyJWT[crypto] added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- screenshots.py waited for network idle, which never comes when Google Fonts hangs in the CI
container. Wait for the DOM, give the network 10 s, then screenshot either way; a 4xx/5xx
still fails the job.
- semgrep flagged 'MCP token refused: %s' as a possible credential leak. It only ever logged
PyJWT's reason; reworded so the rule is satisfied without a suppression.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The APC UPS was replaced by a UniFi UPS 2U Pro on 2026-08-08 (Tinker 387982348, closed
2026-09-25); the 'old battery' entry seeded in migration 3 came from Grafana silences that
predate it. Ended, not deleted, so the history stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared
merged commit 2e3d74d608 into main2026-11-26 17:32:03 -05:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fifth phase 1 PR from the plan on #1. Stacked on #8 (UI): this branch contains #8's commit, so merge #8 first; after that this PR shows only its own commit.
What it is
Thor's MCP server, built into the Flask app, following the wiki's checklist (
Architecture/mcp-servers) like the Tinker, Wiki and Kuma servers:POST https://thor.lotusguild.org/mcp, JSON-RPC 2.0 (single and batch).GET/DELETEanswer 405, since there are no sessions or streams./.well-known/oauth-protected-resource[/mcp](RFC 9728). Without a token you get a 401 whoseWWW-Authenticatenamesresource_metadataand the scopes.isshttps://auth.lotusguild.org,audhttps://thor.lotusguild.org/mcp,exp,typ: at+jwt,client_id: thor-mcp, and scopes from thescparray. Groupadminonly, like the Kuma MCP.Remote-*headers are never trusted. Every tool call is logged as one JSON line with the user,sub, tool, arguments and ok.Tools
list_incidentsget_incidentwhat_coversthor_statuslist_known_conditionsadd_known_conditionend_known_conditionattach_ticket/detach_ticketTools a token's scopes can't use aren't listed. Maintenance stays in Gandalf (thor#1).
Migration 4:
incident_links(who attached which ticket, and when).After merge (production setup; I'll do these step by step, like the Kuma MCP setup)
thor-mcp: public, PKCE S256,two_factor, groupadmin; scopesthor:read/thor:write; audiencehttps://thor.lotusguild.org/mcp; callback port 47826, or 47827 if the Gandalf MCP already took 47826. Back up first,validate-config, restart, check health.location = /mcpandlocation ^~ /.well-known/oauth-protected-resourceahead of the Authelia-protectedlocation /, with theRemote-*headers blanked. Back up the DB,nginx -t, reload.Architecture/mcp-servers.resource_metadata; thenclaude mcp add ... thorand one read and one write.Verification
typ, signer, expiry and scope all give 401; a non-admin gets 403; scopes filtertools/list; validation; attach and detach; DB away; batches.🤖 Generated with Claude Code
9f993dabf1to45afd6e24745afd6e247toaf5fb0c609