Commit Graph
31 Commits
Author SHA1 Message Date
PiersandClaude Opus 4.7 b3a5f23450 DD-338 Phase E.python — depend on stallari-mcp-helpers (delete local helpers)
Pure substrate swap. Local `domain_hint.py` (155 LOC) deleted; canonical
`Pattern`, `compute_domain_hint`, `load_patterns_from_yaml` are now imported
from `stallari-mcp-helpers>=0.1.0,<1.0.0`. Local `meta_envelope` +
`append_meta` helpers in `formatters.py` deleted; canonical implementations
re-exported from the lib for backward call-site compatibility.

Surfaced two API divergences vs the spec's "names stay identical" assumption:

1. The lib's `append_meta(body, meta_line)` takes a pre-built meta line; the
   prior blade-local `append_meta(payload, **kwargs)` built the envelope
   internally. All 11 call-sites in `tools/folders.py` (8), `tools/devices.py`
   (1), `tools/instances.py` (1), `tools/system.py` (1) refactored to the
   two-step `append_meta(payload, meta_envelope(...))` pattern.

2. The lib's `compute_domain_hint(record, patterns)` takes 2 args and uses
   built-in dot-path field resolution; the prior blade-local
   `compute_domain_hint(record, patterns, projector)` took a per-blade
   projector callable. The flat record shapes this blade emits (folders +
   devices) resolve identically under either approach. The blade's
   `_syncthing_field_projector` was removed (was only used as the 3rd arg).

Wire-shape change (test fixtures updated for 2 sites):
- `_meta` field order now follows lib convention (matched_total, returned,
  latency_ms, filtered_by, redactions, next_cursor, error_notes?,
  domain_hints?). Prior local helper emitted latency_ms last.
- `_meta.next_cursor` is now always present (defaults to `null`). Tests
  pinning "next_cursor not in meta" updated to "next_cursor is None".
- `_meta.redactions`, `filtered_by`, `error_notes?`, `domain_hints?` all
  unchanged in conditional-inclusion semantics.

Pure substrate swap — no behavioural change to any tool. Pack-spec catalog
declarations unchanged.

Version: 0.7.0 → 0.8.0.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 09:38:46 +10:00
Piers 2f630d9fe7 Merge pull request #6 from Groupthink-dev/feat/dd-338-c-w2
DD-338 Phase C Wave 2 — syncthing audit_surface promotion
2026-05-23 16:52:15 +10:00
PiersandClaude Opus 4.7 1051f6a1bb DD-338 Phase C Wave 2 — syncthing audit_surface promotion
Promotes 4 folder-scoped multi-record tools from `audit_surface: minimal` to
`audit_surface: structured` by wrapping their client calls in `time.perf_counter()`
and emitting a `_meta` envelope via the existing `append_meta()` helper:

- `syncthing_folder_errors` — `folder=` + optional `scope=` (membership
  precondition mirrors `syncthing_folder_status`; refusal carries
  `redactions=["folder_outside_scope"]`).
- `syncthing_browse_folder` — `folder=` + optional `prefix=`, `levels=`.
- `syncthing_folder_need` — `folder=`, `page=`, `perpage=` (page+perpage
  advance documented in tool description; `next_cursor` omitted per Wave 2 OQ-4).
- `syncthing_remote_need` — `device=`, `folder=`, `page=`, `perpage=`.

Test additions (+14): per-tool `_meta` shape + filtered_by content + scope
membership match/mismatch on `syncthing_folder_errors`; new
`TestRemoteNeed` covers `syncthing_remote_need`; N=3 byte-equal
determinism class per promoted tool in `test_determinism.py` (latency_ms
stripped before compare). Existing 4 tests updated from `json.loads(raw)`
to `split_meta` + payload parse.

165/165 tests green (151 before + 14 new).

Version: 0.6.1 → 0.7.0 (pyproject); 0.3.1 → 0.4.0 (__init__.py).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 16:37:48 +10:00
Piers 63115f3a91 Merge pull request #5 from Groupthink-dev/feat/dd-338-a2-syncthing-catB
DD-338 Phase A.2 (narrowed) — syncthing list_folders + recent_changes cat-B scope= promotion
2026-05-23 15:28:59 +10:00
PiersandClaude Opus 4.7 14ce0cafa1 DD-338 Phase A.2 (narrowed) — syncthing list_folders + recent_changes cat-B scope= promotion
Wire the existing A.1 _resolve_scope_folders substrate into the two
remaining cat-B tools surfaced by the spec's Phase 0 audit:

* syncthing_list_folders — filter config.folders to the resolved
  SYNCTHING_<SCOPE>_FOLDERS[_<INSTANCE>] set; honest matched_total /
  returned / filtered_by counts via the existing append_meta envelope
  (already shipped for domain_hints in A.2.dom.c).
* syncthing_recent_changes — filter the /rest/events stream to events
  whose data.folderID is in the scoped set; gain _meta envelope via
  append_meta. Events without a folderID (system-level events) drop out
  under an active scope filter — system events do not partition by
  folder scope.

OQ-4 resolution (Syncthing event key): events carry `data.folderID` not
`data.folder` (confirmed at branch checkout against the existing concise
projection at tools/system.py:158 + Syncthing 1.27.x REST schema). Filter
keys on `e.get("data", {}).get("folderID")`.

Reuses A.1 substrate verbatim — no greenfield scope mechanism.

Tests: +15 cases in tests/test_a2_catB.py (7 list_folders + 8
recent_changes), incl. determinism harnesses (N=5 byte-equal modulo
latency_ms). 1 modified existing recent_changes test in
test_tools_system.py to use split_meta after the envelope addition.
Suite: 133 → 151 (all green).

Per architect amendment 2026-05-23: spec narrowed from 34-tool sweep to
this 2-tool cat-B promotion. The 32 cat-A (honest scope_none) + cat-D
(write verb) tools in the original spec are already conformant via
pack-spec v4.4.0's honest-declaration path; no edits to those rows.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 15:27:19 +10:00
Piers 453a14fd86 Merge pull request #4 from Groupthink-dev/feat/dd-338-b1b-syncthing
DD-338 Phase B.1.b — syncthing sort-before-return
2026-05-23 14:21:36 +10:00
PiersandClaude Opus 4.7 5e575d2fb4 DD-338 Phase B.1.b: canonical sort-before-return on syncthing_connections
Adds handler-level deterministic ordering to the one multi-record tool in
this blade. Sort key is canonical deviceID ascending (dict key from the
Syncthing REST API's `/rest/system/connections` response).

Implementer-verified shape (architect OQ-5 deferred): the upstream Syncthing
REST API returns `connections.connections` as a dict keyed by canonical
deviceID — a fixed 64-character base32-shaped hex-class string (e.g.
`AAAAAAA-AAAAAAA-...`). The dict key IS the canonical id; `format_connection`
consumes `did` as its first positional arg and renders the device's name
(or first 8 chars of the deviceID as fallback) at the top of each per-device
section. Sort by `kv[0]` (the deviceID) is the canonical Track 2 contract.

The change is in-place — a `sorted(..., key=lambda kv: kv[0])` wraps the
existing `.items()` view inside the list-comprehension. No LOC delta.

Adds tests/test_determinism.py with N=5 byte-equal harness, sort-key
correctness, and empty-connections edge case (3 new cases / 136 total).

Catalog declaration flip from `unstable → stable` lands in the paired
stallari-plugins PR.

Version bump 0.6.0 → 0.6.1 (patch — single-tool additive contract).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 14:13:06 +10:00
Piers d59aa3c902 Merge pull request #3 from Groupthink-dev/feat/dd-338-a2-dom-c-domain-hint
DD-338 A.2.dom.c — domain_hint patterns + per-record _meta.domain_hints
2026-05-23 12:50:09 +10:00
PiersandClaude Opus 4.7 06217b6fdc DD-338 A.2.dom.c — domain_hint patterns + per-record _meta.domain_hints
New per-blade lib (src/syncthing_mcp/domain_hint.py, ~155 LOC) implementing
the shared DD-338 Pattern engine: equals / contains / glob ops, first-match-
wins, YAML pattern loading with graceful degradation (Convention #22).

Server module gains a BladeConfigStore reader honouring STALLARI_STATE_ROOT
override + the sanitized blade-id directory layout the Swift writer ships
(Convention #23 reader-side compliance), plus a polymorphic Syncthing field
projector covering both folder records (id/label/path/type) and device
records (deviceID/name/addresses).

Wired into the two list-returning read tools:
  - syncthing_list_folders (instances.py — newly gains _meta envelope; was
    previously bare fmt(); start time now tracked for latency_ms)
  - syncthing_list_devices (devices.py — extends existing envelope with
    domain_hints kwarg)

formatters.{meta_envelope,append_meta} extended with an optional
domain_hints kwarg; key omitted from the JSON tail when empty / None.

stallari-plugin.yaml gains a blade_domain_hint_patterns: { patterns: [] }
block (0 defaults; users layer their own via the Settings → Blade Domain
Hints editor). No tools[] block exists in this manifest — per-tool
domain_scope flips land in the catalog mirror at stallari-plugins/plugins/
in a separate parent-session action.

pyyaml>=6.0 added to runtime dependencies (gated by ImportError inside
load_patterns_from_yaml so the blade still boots if the wheel is absent).
Version bump 0.5.0 → 0.6.0 (minor — new substrate capability).

Tests: 13 new cases in tests/test_domain_hint.py covering empty-patterns,
folder+device matches, first-match-wins, glob wildcards, unknown-field
projector handoff, YAML well-formed / partial / malformed / non-mapping
root / missing-patterns-key. Full suite 133/133 green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 12:46:47 +10:00
PiersandClaude Opus 4.7 d3e364a18f chore: harden MCP_HOST default to 127.0.0.1 per DD-242
Brings syncthing-blade-mcp into compliance with DD-242 transport policy
(directives/access-policy.md): blade MCPs invoked manually with HTTP
enabled MUST default to 127.0.0.1, never 0.0.0.0. Users who want to
expose the server beyond loopback set MCP_HOST=0.0.0.0 explicitly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 10:04:14 +10:00
Piers e915e6da01 Merge pull request #2 from Groupthink-dev/feat/dd-338-a1-syncthing
DD-338 A.1 — scope= arg + sort-before-return + _meta envelope on 3 read tools
2026-05-21 22:03:34 +10:00
PiersandClaude Opus 4.7 0bd5d1ce06 DD-338 A.1 — syncthing scope= arg + sort-before-return + _meta envelope on 3 read tools
Combined Track 1 + Track 2 + Track 3 single-PR (heaviest A.1 spec, only
top-5 blade in both scope AND determinism gap).

Track 1: scope= arg with env-var folder-ID list indirection
         (SYNCTHING_{WORK,PERSONAL,FAMILY,HOME,INFRASTRUCTURE}_FOLDERS
         comma-separated; per-instance _<INSTANCE> override). Server-side
         from blade-process perspective (Syncthing REST has no native
         folder filter; blade-internal filter IS the over-fetch boundary
         per DD-333).
Track 2: canonical sort on device.deviceID + folder id tie-breaker on
         replication_report (fixes sort-key collision case).
Track 3: structured _meta envelope (canonical JSON-tail wire shape per
         architect amendment 2026-05-21) with matched_total / returned /
         filtered_by / redactions / latency_ms; filtered_by alphabetised
         for hash reproducibility.

Touched tools: syncthing_list_devices, syncthing_folder_status,
syncthing_replication_report. Other 35 tools unchanged.

scope=public raises through the standard error path (folders are not
public in Syncthing's model). Unconfigured scope passes through with a
honest scope=<name>_unconfigured redaction.

Tests: 120 pass (97 baseline + 23 new). Determinism check is N=5
byte-equal (modulo latency_ms) per tool.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 21:58:19 +10:00
PiersandClaude Opus 4.7 11b4d40a57 chore: add PyPI publish workflow + bump 0.4.0
DD-182 Python Wave A backfill. OIDC trusted publishing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 14:31:36 +10:00
PiersandClaude Opus 4.6 e171f05bee Standardize on US license spelling in manifest
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-24 12:11:18 +10:00
PiersandClaude Opus 4.6 71ae753556 Add setup.fields, remove internal transport config from UI
- Add setup.fields with labels, placeholders, and help text
- Remove MCP_TRANSPORT, MCP_AUTH_TOKEN from env

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-21 20:34:56 +10:00
PiersandClaude Opus 4.6 a3d11898aa Add stallari-plugin.yaml
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-21 19:55:40 +10:00
PiersandClaude Opus 4.6 631f22d6c3 Rename syncthing-mcp to syncthing-blade-mcp
Align naming with the Blade MCP server convention used across the
Sidereal platform. Updates package name, console script entry point,
Docker configs, deploy script, and documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-12 12:19:11 +10:00
Piers 78ffb8bd49 Merge pull request #1 from piersdd/claude/improve-syncthing-mcp-JS2P5
Claude/improve syncthing mcp js2 p5
2026-02-17 14:51:10 +11:00
Claude bafb450a69 Add uv.lock for reproducible dependency resolution
https://claude.ai/code/session_018efEinU8ypT2jHeex6o9PC
2026-02-17 03:45:35 +00:00
Claude 41f1018477 Token-efficient output, SKILL.md, Cloudflare Tunnel, new tools (v0.3.0)
Major improvements following best-in-class MCP patterns:

- Token efficiency: new formatters.py with compact JSON (no indent),
  short device IDs, character-limit truncation; all read tools gain
  concise=true (default) / concise=false toggle via ReadParams base
- Models: ReadParams/WriteParams hierarchy replaces flat models;
  backward-compatible aliases preserved for tests
- New tools: syncthing_remote_need (debug remote sync gaps),
  syncthing_device_stats (per-device statistics)
- SKILL.md: LLM skill guide with token rules, quick-start table,
  workflows, tool reference, and troubleshooting
- Cloudflare Tunnel: docker-compose.tunnel.yml for zero-trust HTTP
  deployment alongside existing Traefik/ACME support
- Fix duplicate dependencies in pyproject.toml; bump to v0.3.0

https://claude.ai/code/session_018efEinU8ypT2jHeex6o9PC
2026-02-17 03:44:48 +00:00
PiersandClaude Opus 4.6 39d6994738 Add Streamable HTTP transport, bearer auth, and Docker deployment
- Enable stateless_http + json_response on FastMCP for scalable HTTP
  serving without sticky sessions (Traefik-friendly)
- Add MCP_TRANSPORT env var to select stdio (default) vs streamable-http
- Add bearer token auth middleware (MCP_AUTH_TOKEN) with /health bypass
- Add Dockerfile (Python 3.12-slim + uv) and docker-compose.yml with
  Traefik v2/v3 labels, ACME TLS, and health check routing
- Add .env.example with multi-instance config for mini/tn-sb/tn-mr2/p-mba
- Add uvicorn + starlette as runtime dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 19:31:45 +11:00
PiersandClaude Opus 4.6 5ca58735eb Add Streamable HTTP transport, bearer auth, and Docker deployment
- Enable stateless_http + json_response on FastMCP for scalable HTTP
  serving without sticky sessions (Traefik-friendly)
- Add MCP_TRANSPORT env var to select stdio (default) vs streamable-http
- Add bearer token auth middleware (MCP_AUTH_TOKEN) with /health bypass
- Add Dockerfile (Python 3.12-slim + uv) and docker-compose.yml with
  Traefik v2/v3 labels, ACME TLS, and health check routing
- Add .env.example with multi-instance config for mini/tn-sb/tn-mr2/p-mba
- Add uvicorn + starlette as runtime dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 03:54:43 +00:00
Piers Dawson-DamerandClaude Opus 4.6 3a33d34bd1 Refactor into package, add 6 new tools, add 96 tests
Split the monolithic syncthing_mcp.py into a proper src/syncthing_mcp/
package with focused modules: client, models, registry, server, and
tool submodules (system, folders, devices, config, instances).

New tools: browse_folder, file_info, folder_need (file-level queries),
override_folder, revert_folder (conflict resolution), check_upgrade
(system management). Bumps tool count from 30 to 36.

Adds comprehensive test suite (96 tests) using pytest + respx for
HTTP mocking, covering client methods, registry logic, model validation,
and all tool functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 10:13:37 +11:00
Piers Dawson-Damer 5b54c09cd5 Add multi-instance support, config mutation tools, and expanded monitoring
Refactor single-instance architecture into a SyncthingClient class that
supports connecting to multiple Syncthing nodes simultaneously via a
SYNCTHING_INSTANCES JSON env var (backward-compatible with existing
single-instance SYNCTHING_URL + SYNCTHING_API_KEY).

New tools (18, bringing total to 30):
- Instance management: list_instances
- Pending config: pending_devices/folders, accept/reject device/folder
- Restart: restart_required, restart
- Ignore patterns: get/set_ignores, get/set_default_ignores
- Monitoring: system_errors, clear_errors, system_log, recent_changes,
  health_summary
2026-02-14 18:31:28 +11:00
Piers Dawson-Damer 3da2a9f63c fix: lifespan handler must accept app argument from FastMCP 2026-02-14 13:33:08 +11:00
Piers Dawson-Damer c7c40be257 improve deploy-local 2026-02-14 13:28:05 +11:00
Piers Dawson-Damer 2ee6231871 add pyproject 2026-02-14 13:28:02 +11:00
Piers Dawson-Damer df73a595f8 improve deploy-local 2026-02-14 13:25:45 +11:00
Piers Dawson-Damer 1afbc9684b add lightweight deploy script 2026-02-14 13:20:25 +11:00
Piers Dawson-Damer 1b7e26d615 add readme 2026-02-14 13:15:24 +11:00
Piers Dawson-Damer 9ccc6a510c Initial commit: Syncthing MCP server 2026-02-14 10:03:15 +11:00