netresearch/matrix-skill / skills/matrix-administration
matrix-administration
VerifiedUse when administering a Synapse / Matrix homeserver — list or snapshot all rooms, rate room health (public, unencrypted, orphaned), render a Graphviz map of the room/space tree, force-join users, promote room admins, harden rooms (add-to-space + restrict + encrypt), deactivate Matrix users (with GDPR erase), find biggest rooms by DB size, audit where a user is admin or member, replay join/leave timelines, or search unencrypted history. Trigger on any '/_synapse/admin', server-wide room operation, Matrix user offboarding, or anything requiring a homeserver-admin token — even without 'admin API' in the prompt. Companion to matrix-communication.
scripts/synapse-fetch-rooms.py
View on GitHub#!/usr/bin/env -S uv run --script
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""Snapshot every visible room on a Synapse homeserver.
Pages through ``GET /_synapse/admin/v1/rooms`` and, for each room, fetches
its full state via ``/v1/rooms/{room_id}/state``. Writes the result as a
JSON list of ``{"room": …, "states": […]}`` entries — the format consumed
by the other scripts (rating, graph, member listings).
Apply an optional server-suffix filter via ``--server`` (e.g.
``--server :example.com``) or the ``room_filter`` config field. Without a
filter every visible room is included.
Usage:
synapse-fetch-rooms.py [--output rooms.json] [--server :example.com]
"""
from __future__ import annotations
import argparse
import json
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _lib import admin_request, load_config, quote
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
parser.add_argument(
"-o", "--output", default="rooms.json", help="Output path (default rooms.json)"
)
parser.add_argument(
"--server",
default=None,
help="Optional server suffix to filter on (e.g. ':example.com'). "
"Defaults to the 'room_filter' config field.",
)
args = parser.parse_args()
config = load_config()
suffix = args.server if args.server is not None else config.get("room_filter", "")
from_token: int | str = 0
rooms: list[dict] = []
while True:
# `order_by=name` is a documented Synapse query parameter; the
# original tool used a bare `&sort` flag that produced an
# empty-valued query parameter (parsed inconsistently by some
# proxies). See:
# https://element-hq.github.io/synapse/latest/admin_api/rooms.html
result = admin_request(
config,
"GET",
f"/v1/rooms?from={quote(str(from_token))}&order_by=name",
)
if "error" in result:
print(f"Error fetching rooms: {result['error']}", file=sys.stderr)
return 1
page = result.get("rooms", []) or []
if suffix:
page = [r for r in page if r.get("room_id", "").endswith(suffix)]
for room in page:
state_res = admin_request(
config, "GET", f"/v1/rooms/{quote(room['room_id'])}/state"
)
if "error" in state_res:
print(
f"Warning: failed to fetch state for {room['room_id']}: "
f"{state_res['error']}",
file=sys.stderr,
)
continue
states = sorted(
state_res.get("state", []) or [],
key=lambda s: s.get("origin_server_ts", 0),
)
rooms.append({"room": room, "states": states})
next_batch = result.get("next_batch")
if next_batch is None:
break
from_token = next_batch
with open(args.output, "w") as f:
json.dump(rooms, f, indent=2)
print(f"Wrote {len(rooms)} rooms to {args.output}")
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |