Secure Local LLM Swarm over MCP
Project description
LLMesh
Secure Local LLM Swarm over MCP — a security-first peer-to-peer mesh for collaborative local LLM workflows.
LLMesh lets multiple local LLM nodes (Ollama, llama.cpp) cooperate on coding tasks — code generation, test generation, security review, output critique — over signed MCP (Model Context Protocol) calls, with a fail-closed firewall, schema-validated tool I/O, append-only audit trail, and SCA dependency gating built in from the start.
Status (local review): 526 tests passing · 0 failures · 0 Critical · 0 High security findings. Maturity: research / PoC. Designed for trusted LAN or single-operator multi-PC setups. Not yet hardened for untrusted public Internet deployment.
Why LLMesh
Most local-LLM "swarms" are built for convenience first and security later. LLMesh inverts that: every cross-node interaction is signature-bound, every tool response goes through a 7-stage validator, every secret-pattern in a prompt is fail-closed-blocked, and every accepted decision is logged into an HMAC-chained append-only audit trace.
You bring the GPUs and the models. LLMesh provides the trust boundary, the protocol, and the guardrails.
Highlights
- Ed25519 node identity with stable
peer:IDs and W3C-styledid:llmesh:1:decentralized identifiers. - Signed Capability Manifests with TTL — peers advertise tools, subnets, and policies under a verifiable signature.
- TOFU + signed P2P discovery via a rendezvous server (
POST /announce) and gossip pull (GET /registry/peers). Canonical signatures bindnode_id,endpoint, timestamp, public key, and DID together so MITM key substitution cannot succeed. - Request-level auth with Ed25519 signatures over
METHOD\nPATH\nNODE_ID\nTS\nBODY_SHA256, ±30s freshness, and a per-(node, nonce) replay store. - Fail-closed Prompt Firewall with two layers (regex secret detection, structural checks) — any exception in the pipeline returns L4/BLOCK.
- OutputValidator 7-stage gate — size cap → JSON-only parse → JSON Schema → nonce echo →
task_idUUIDv4 → server-side replay store → SCA Gate (OSV CRITICAL/HIGH ⇒ block). - HMAC append-only AuditTrace — sequential JSONL entries chained by HMAC-SHA256. Prompt bodies for L3/L4 are never stored, only their SHA-256.
- Container hardening —
--network=nonesandbox profile,cap_drop:[ALL],read_only,tmpfs:noexec,no-new-privileges, non-root UID 65532/65533. - Zero unsafe patterns by policy — no
shell=True, nopickle, no unsafeyaml.load, noeval/exec, no SQL string concatenation. Enforced via Bandit + Semgrep in CI.
Security-First Design Principles
- Fail-closed, not fail-open. Every guard component returns BLOCK on any unhandled exception.
- Untrusted-by-default. LLM responses, peer manifests, and rendezvous announcements are treated as untrusted until a validator clears them.
- No secret bodies in audit logs. L3/L4 prompts are recorded as SHA-256 only.
- Defence in depth. Transport TLS + request signing + body hashing + nonce store + manifest TTL + SCA gate are layered, not alternative.
- Explicit trust transitions. Initial peer addition is TOFU (manual fingerprint check). Gossip propagation is opt-out for operators who want strict control.
Quick Start (single host)
# 1. Install
pip install -e ".[dev]"
# 2. Run the test suite
python -m pytest # → 526 passed
# 3. Optional: static security scan
python -m bandit -r llmesh/ -ll
Running a single MCP node
uvicorn llmesh.mcp.server:app --host 127.0.0.1 --port 8001
Endpoints exposed: POST /tools/{generate_code|generate_tests|review_code|critique_output}, GET /health, GET /identity, plus the /registry/* peer discovery API.
See SETUP.md for full Ollama/llama.cpp configuration and environment variables (LLMESH_BACKEND, LLMESH_AUDIT_LOG_PATH, LLMESH_AUDIT_HMAC_KEY, etc.).
5-Node PoC Demo (Docker Compose)
docker compose -f docker-compose.poc.yml up --build
This brings up four worker nodes (generate_code, generate_tests, review_code, critique_output) plus an orchestrator on a hardened internal network. See docs/DEMO.md for the full reproducible flow including the L0 happy-path and the L3 secret-block scenario.
The PoC compose uses
internal: trueso containers cannot reach the public Internet. The OSV-backed SCA Gate therefore returnssca_network_error(fail-closed) unless you provide an OSV proxy on the internal network — seeSETUP.md§6.
Multi-PC Setup
For two or more physical machines on a LAN, see PEERING.md. It covers:
- Self-CA TLS bootstrap (
scripts/gen_certs.py) - TOFU peer addition with fingerprint verification
- Optional rendezvous server lookup by
node_idordid:llmesh:1: - Gossip auto-propagation (60-second pull interval)
- Threat-model table (eavesdropping, replay, impersonation, gossip pollution)
Documentation Map
| File | Contents |
|---|---|
README.md |
This file — entry point, status, quick start |
ARCHITECTURE.md |
Module map, OutputValidator 7-stage gate, dataflow, DataLevel taxonomy |
SETUP.md |
Install, single-node, Docker Compose PoC, troubleshooting |
PEERING.md |
Multi-PC, TLS, TOFU, rendezvous, gossip, threat model |
SECURITY.md |
Vulnerability reporting, forbidden-pattern policy, fail-closed contract |
docs/ROADMAP.md |
P0 baseline → P1 hardening → P2 hygiene → P3 community |
docs/DEMO.md |
Reproducible 5-node demo flow |
docs/PUBLICATION_CHECKLIST.md |
Pre-publication tasks across GitHub / PyPI / write-up venues |
docs/LAUNCH_KIT.md |
GitHub / PyPI / Qiita / LinkedIn launch copy and publication plan |
SESSION_SUMMARY_2026-05-05.md |
Historical snapshot of an earlier development session |
Project Status
| Metric | Value |
|---|---|
| Tests | 526 passed / 0 failed (local) |
| Critical findings | 0 |
| High findings | 0 |
| Medium findings | 5 (operational hardening — see ROADMAP P1) |
| Bandit (medium+) | 11 issues, all B310 / B104 false positives |
Forbidden patterns (shell=True, pickle, yaml.load unsafe, marshal, eval, exec, os.system, SQL concat) |
0 in source |
Contributing
Issues and pull requests are welcome. Please use the templates in .github/ISSUE_TEMPLATE/ (bug, security hardening, feature) and .github/pull_request_template.md. For security-impacting changes, prefer the Security Hardening issue template and reference the relevant ROADMAP item.
For coordinated disclosure, see SECURITY.md — please do not open a public issue for vulnerabilities.
Disclaimer
LLMesh is a research / proof-of-concept implementation. The current design targets:
- A trusted LAN, or
- A small set of explicitly TOFU-verified peers under a single operator.
It is not ready for deployment on the open Internet against arbitrary peers. Notably:
- Per-node rate limiting is implemented but global QoS / abuse mitigation is not.
- The NonceStore is in-memory only; a node restart re-opens a brief replay window.
- Gossip uses transitive trust by design — see PEERING.md for opt-out guidance.
- The Phase 2 AES-256-GCM endpoint encryption path is built but not yet wired into the rendezvous flow.
Use accordingly.
License
Apache License 2.0 — see LICENSE.
Copyright 2026 Kazufumi Furuse.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmesh_mcp-0.1.0.tar.gz.
File metadata
- Download URL: llmesh_mcp-0.1.0.tar.gz
- Upload date:
- Size: 136.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78259beac8574aad3cb1da0d21262be9198d3ff4684a9b486d77d2572227a77f
|
|
| MD5 |
e457181267b55a94b8a8eea7d92a4894
|
|
| BLAKE2b-256 |
33408b13650d26654f19360ef4a566d76ea1c9902911091560c040a136f14be6
|
Provenance
The following attestation bundles were made for llmesh_mcp-0.1.0.tar.gz:
Publisher:
publish.yml on furuse-kazufumi/llmesh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmesh_mcp-0.1.0.tar.gz -
Subject digest:
78259beac8574aad3cb1da0d21262be9198d3ff4684a9b486d77d2572227a77f - Sigstore transparency entry: 1439765932
- Sigstore integration time:
-
Permalink:
furuse-kazufumi/llmesh@edacc01e1dce5971c18e5978e7b06e4bcdf0a52d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/furuse-kazufumi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@edacc01e1dce5971c18e5978e7b06e4bcdf0a52d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file llmesh_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llmesh_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 88.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56157519420cc5521cbac26af37350881e4963a07813ca22fc278aec63d4be05
|
|
| MD5 |
32ed65f61ad324500bc29c98fd7f7569
|
|
| BLAKE2b-256 |
21d90c03ee997d549cff4038c3c68e678108d1d000cdc8c20d691ac380552329
|
Provenance
The following attestation bundles were made for llmesh_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on furuse-kazufumi/llmesh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmesh_mcp-0.1.0-py3-none-any.whl -
Subject digest:
56157519420cc5521cbac26af37350881e4963a07813ca22fc278aec63d4be05 - Sigstore transparency entry: 1439765938
- Sigstore integration time:
-
Permalink:
furuse-kazufumi/llmesh@edacc01e1dce5971c18e5978e7b06e4bcdf0a52d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/furuse-kazufumi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@edacc01e1dce5971c18e5978e7b06e4bcdf0a52d -
Trigger Event:
workflow_dispatch
-
Statement type: