PDF · Free download
Keep this guide as a PDF
Multi-Machine AI Agent Mesh: M4 + M5 Setup with SLM, as one file you can read offline and share with your team.
Sign in with Google or GitHub to download.
Multi-Machine AI Agent Mesh: M4 + M5 with SLM
Two Macs. Multiple AI agents running on each. Until now, they lived in separate worlds — Claude on M4 couldn't see Cursor on M5. You couldn't coordinate a task across machines without copying context manually.
SuperLocalMemory v3.4.48 and SLM Mesh v1.3.0 change that.
Both products now ship with full multi-machine mesh support. Agents on M4 and M5 appear in the same peer list. Messages route cross-machine automatically. mDNS auto-discovery means zero manual IP config on most networks.
What You're Building
Mac M4 (192.168.1.100) Mac M5 (192.168.1.101)
━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━
Claude Code ────┐ Claude Code ────┐
Cursor ─────────┤ iTerm ──────────┤
│ │
SLM Mesh SLM Mesh
broker (:7899) ◄───WS───► broker (:7899)
│ │
SuperLocalMemory ◄──HTTP──► SuperLocalMemory
daemon (:8765) daemon (:8765)
Two independent stacks. One mesh. Agents coordinate as if they were on the same machine.
Prerequisites
- Both Macs on the same LAN (WiFi or Ethernet)
- Node.js 20+ on both (for SLM Mesh)
- Python 3.11+ on both (for SuperLocalMemory)
- SLM Mesh v1.3.0:
npm install -g slm-mesh - SuperLocalMemory v3.4.48:
pip install superlocalmemory
Step 1: Choose a Shared Secret
Generate a strong shared secret — same value on both machines:
openssl rand -hex 32
# e.g.: a3f9e2b1c7d4f8a2b6c9d3e7f1a4b8c2...
Store it in your shell profiles (~/.zshrc or ~/.bash_profile) on BOTH machines:
export SLM_MESH_SHARED_SECRET="a3f9e2b1c7d4f8a2..."
Never commit this to git.
Step 2: Start SLM Mesh on M4 (the Hub)
M4 runs the broker that both machines connect to:
# On M4
SLM_MESH_HOST=0.0.0.0 SLM_MESH_SHARED_SECRET=$SLM_MESH_SHARED_SECRET npx slm-mesh
Verify it's listening:
curl http://localhost:7899/health
# {"status":"ok","version":"1.3.0","uptime":5}
From M5, verify M4 is reachable:
curl http://192.168.1.100:7899/health
# Same response
Step 3: Configure M5 to Connect to M4's Broker
On M5, point the SLM Mesh MCP server at M4:
{
"mcpServers": {
"slm-mesh": {
"command": "npx",
"args": ["slm-mesh", "mcp"],
"env": {
"SLM_MESH_HOST": "192.168.1.100",
"SLM_MESH_SHARED_SECRET": "a3f9e2b1c7d4f8a2..."
}
}
}
}
M5's MCP server auto-discovers M4's broker. No separate broker needed on M5.
Step 4: Set Up SuperLocalMemory on Both Machines
On M4 — set the shared secret so remote callers can authenticate:
export SLM_MESH_SHARED_SECRET=$SLM_MESH_SHARED_SECRET
slm start # or however you start SLM
On M5 — point at M4's SLM and set the shared secret:
export SLM_MESH_PEER_URL=http://192.168.1.100:8765
export SLM_MESH_SHARED_SECRET=$SLM_MESH_SHARED_SECRET
In Claude Code config on M5:
{
"mcpServers": {
"superlocalmemory": {
"command": "slm",
"args": ["mcp"],
"env": {
"SLM_MESH_PEER_URL": "http://192.168.1.100:8765",
"SLM_MESH_SHARED_SECRET": "a3f9e2b1c7d4f8a2..."
}
}
}
}
Step 5: Verify End-to-End
Start Claude Code on M4. In a new terminal, check M5 can see M4's agents:
# On M5 — list all peers including remote
curl http://192.168.1.100:8765/mesh/peers \
-H "Authorization: Bearer $SLM_MESH_SHARED_SECRET"
You should see M4's local agents. After M5 starts its own Claude session, M4 agents should see M5 agents in mesh_peers.
Test cross-machine message delivery:
# In M4's Claude: call mesh_send to an M5 peer
mesh_send(to="<m5-peer-id>", content="hello from M4")
# In M5's Claude: check inbox
mesh_inbox() # → message from M4 peer appears
How Real-Time Push Works (SLM Mesh)
When M5's peer-listener starts, it:
- Connects to M4's WebSocket server on port 7900 (default: broker port + 1)
- Sends a hello message:
{"type":"hello","peerId":"<uuid>"} - M4's broker registers this WS connection against the peer ID
- When any agent sends to M5's peer, M4 routes the push notification directly via the WS connection — sub-100ms delivery, same as local mode
M4 Agent ──mesh_send──► M4 Broker ──WS.sendToPeer(m5-peer-id)──► M5 Agent
│
UDS push for M4's local peers
Optional: mDNS Auto-Discovery
With mDNS, you don't need to hardcode IPs. Both machines auto-discover each other:
SLM Mesh uses bonjour (npm) — works automatically when SLM_MESH_DISCOVERY=on (default).
SuperLocalMemory uses zeroconf (Python) — install it:
pip install zeroconf
# or
pip install "superlocalmemory[mesh]"
With mDNS enabled, both brokers announce _slm-mesh._tcp on the LAN and discover each other without manual IP configuration.
Firewall Ports
| Port | Protocol | Direction | Purpose |
|---|---|---|---|
| 7899 | TCP | Both | SLM Mesh broker HTTP |
| 7900 | TCP | Both | SLM Mesh WebSocket push |
| 8765 | TCP | Both | SuperLocalMemory HTTP API |
| 5353 | UDP | Both | mDNS (optional) |
On macOS, System Preferences → Firewall → Options → add exceptions for these ports if needed.
What Stays Local (By Design)
Multi-machine does NOT mean distributed:
- SQLite is per-machine. No shared database.
- File locks are per-machine. Cross-machine file locking requires a distributed filesystem.
- Memory recall —
remember/recallstays local. The mesh is for agent coordination, not memory sync. - LAN only. No internet exposure. No STUN/relay.
Troubleshooting
M5 can't reach M4's broker:
# Check M4's broker is listening on all interfaces, not just localhost
curl http://192.168.1.100:7899/health # from M5
If this fails, M4's broker may be bound to 127.0.0.1. Confirm SLM_MESH_HOST=0.0.0.0 on M4.
Auth failures (401 Unauthorized):
- Shared secret must be identical on both machines, character for character.
- No trailing spaces or newlines in the env var value.
Remote peers not appearing in mesh_peers:
- SLM sync runs every 30s. Wait and retry.
- Check
SLM_MESH_PEER_URLis set correctly on M5.
Push notifications not arriving:
- Confirm port 7900 is open between M4 and M5.
- Check M4's broker log for WS connection events.
Summary
| Feature | Status |
|---|---|
| Cross-machine peer discovery | ✅ SLM v3.4.48 (30s HTTP sync) + SLM Mesh v1.3.0 (mDNS) |
| Real-time push notifications | ✅ SLM Mesh v1.3.0 (WebSocket, sub-100ms) |
| Cross-machine message routing | ✅ Both products |
| mDNS auto-discovery | ✅ SLM Mesh (bonjour) + SLM (zeroconf, optional) |
| Shared memory (remember/recall) | Single-machine only (by design) |
| Internet mesh | Out of scope (LAN only) |
Both M4 and M5 are first-class citizens. Ship it.