Repository navigation
feat(mcp): Space instance-sync MCP tool - #274
Conversation
Exposes a `Sync` MCP tool that registers a `{space}/_Sync/{id}` InstanceSyncConfig
node (remote URL/token/direction), starting bi-directional replication with a remote
MeshWeaver instance. The write goes through the caller's session hub, so it runs under
the caller's identity and is permission-checked (writing under `_Sync` requires
Editor/Update on the Space) — matching the GUI's Synchronizations node-menu path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new MCP tool (Sync) to the meshweaver MCP server (McpMeshPlugin) that programmatically creates an InstanceSyncConfig registration node under {space}/_Sync/{id}, enabling instance sync setup from an agent/assistant. It also wires in the required project reference so the MCP plugin can construct the typed config payload.
Changes:
- Add
MeshWeaver.InstanceSyncproject reference toMeshWeaver.Blazor.AI. - Introduce a new MCP tool
Sync(...)that writes anInstanceSyncConfignode via existingops.Create(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/MeshWeaver.Blazor.AI/MeshWeaver.Blazor.AI.csproj | Adds a reference to MeshWeaver.InstanceSync so the MCP plugin can use InstanceSyncConfig types/constants. |
| src/MeshWeaver.Blazor.AI/McpMeshPlugin.cs | Adds the Sync MCP tool that creates {space}/_Sync/{id} InstanceSyncConfig registration nodes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test Results (shard 1)773 tests +19 593 ✅ +18 3m 1s ⏱️ +23s Results for commit a801b38. ± Comparison against base commit aaa73da. This pull request removes 53 and adds 72 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Test Results (shard 0) 15 files ± 0 15 suites ±0 4m 0s ⏱️ -40s Results for commit a801b38. ± Comparison against base commit aaa73da. This pull request removes 198 tests.♻️ This comment has been updated with latest results. |
Test Results 56 files ± 0 56 suites ±0 20m 40s ⏱️ -2s Results for commit a801b38. ± Comparison against base commit aaa73da. This pull request removes 251 and adds 72 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
- Not Idempotent: ops.Create errors if {space}/_Sync/{id} already exists, so a retry
fails rather than being a safe no-op — the attribute now reflects that.
- Reject a nested `space`: instance sync only activates a registration at {space}/_Sync/{id}
with a single top-level {space}; a nested path was silently written and never picked up.
- Use InstanceSyncService.SanitizeSourceId (now public, case-preserving) instead of a
lower-cased copy, so GUI ("Partner") and MCP produce the SAME id — no duplicate
registration differing only by casing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds a
Synctool to themeshweaverMCP server (McpMeshPlugin) that configures instance sync for a Space from an agent/assistant: it registers a{space}/_Sync/{id}InstanceSyncConfignode (remote URL, remote token, direction, remote-space id), which starts bi-directional replication with a remote MeshWeaver instance — the same registration the GUI's Synchronizations node-menu item writes.Why it's safe
The write goes through the caller's session hub (
ops.Create(...)), so it runs under the caller's identity and is permission-checked: writing under{space}/_Syncrequires Editor (Update) on the Space. Viewers/commenters can't configure sync. No new mutation surface — just the existingCreatepath with a typedInstanceSyncConfigpayload.Notes
InstanceSyncConfig/InstanceSyncDirectionfromMeshWeaver.InstanceSync(added a project reference toMeshWeaver.Blazor.AI).Bidirectional.🤖 Generated with Claude Code