MCP v1: Thor's tools for Claude Code, behind Authelia OAuth (thor#1)
CI / Test (pytest) (pull_request) Successful in 1m13s
CI / Integration (MariaDB) (pull_request) Successful in 2m36s
CI / Security (bandit, pip-audit) (pull_request) Successful in 1m25s
CI / UI (screenshots) (pull_request) Failing after 8s
CI / Lint (flake8, house style) (pull_request) Successful in 58s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Failing after 1m26s
CI / Deploy (pull_request) Skipped

- 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>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-25 23:28:37 -05:00
1 parent ab4b20d15f
commit 9f993dabf1
10 files changed
+593 -3

No files matched your search

+31
View File
@@ -21,6 +21,7 @@ class FakeStore:
self.incidents: Dict[str, dict] = {}
self.actions: List[dict] = []
self.observations: Dict[str, dict] = {}
self.links: List[dict] = []
self.known: List[dict] = [
{'id': 1, 'kind': 'reboot', 'subject': 'compute-storage-02', 'ticket_id': '693930698',
'reason': 'compute-storage-02 reboots every 2 to 3 days from a failing DIMM.'},
@@ -135,6 +136,36 @@ class FakeStore:
return [dict(o, first_seen=o['start'], last_seen=o['end'], k=o['key'])
for o in self.observations.values() if o['end'] >= since]
def add_known_condition(self, kind, subject, ticket_id, reason, created_by, now):
self._check('add_known_condition')
new = {'id': max([k['id'] for k in self.known] + [0]) + 1, 'kind': kind, 'subject': subject,
'ticket_id': ticket_id, 'reason': reason, 'created_by': created_by, 'created_at': now}
self.known.append(new)
return new['id']
def end_known_condition(self, condition_id, ended_by, now):
self._check('end_known_condition')
for k in self.known:
if k['id'] == condition_id and not k.get('ended'):
k['ended'] = now
return 1
return 0
def add_incident_link(self, key, ticket_id, who, now):
self._check('add_incident_link')
self.links.append({'incident_key': key, 'ticket_id': ticket_id, 'added_by': who, 'added_at': now})
return len(self.links)
def remove_incident_link(self, key, ticket_id, who, now):
self._check('remove_incident_link')
before = len(self.links)
self.links = [x for x in self.links if not (x['incident_key'] == key and x['ticket_id'] == ticket_id)]
return before - len(self.links)
def incident_links(self, key):
self._check('incident_links')
return [dict(x) for x in self.links if x['incident_key'] == key]
def known_conditions(self):
self._check('known_conditions')
return [dict(k) for k in self.known if not k.get('ended')]