mcp-p2p-swarm-mesh
README.md
# `mcp-p2p-swarm-mesh`
[](https://python.org)
[](https://modelcontextprotocol.io)
[](LICENSE)
[-success.svg)]()
A decentralized, multi-agent peer-to-peer (P2P) Model Context Protocol (MCP) router built strictly in **Python 3.10+**. It bridges physically distributed, independent MCP servers into an encrypted, self-healing swarm mesh, complete with an interactive **Streamlit Web Application Control Center**.
---
## ๐ Key Architecture & Capabilities
* **๐ Gateway Node Lifecycle (`FR-01`)**: Bridges upstream MCP clients (Claude Desktop, Cursor, Autonomous Agents) over standard Stdio and SSE transports.
* **๐ P2P Transport & Dynamic Discovery (`FR-02`)**: Decentralized node discovery over asynchronous UDP gossip protocol and encrypted mutual TLS 1.3 socket streams.
* **๐ Dynamic Capability Registry (`FR-03`)**: Aggregates tools, resources, and prompt templates into a unified catalog exposed via `mesh://capabilities/registry`.
* **โก Distributed Task Delegation (`FR-04`)**: Routes execution payloads via `mesh_delegate_task` to specific or auto-selected peers with progress streaming.
* **๐ค Swarm Consensus Orchestration (`FR-05`)**: Coordinates multi-agent deliberation routines (`swarm_consensus_review`) with customizable quorum thresholds and variance synthesis.
* **๐ Zero-Trust Security (`NFR-02`)**: Cryptographic Ed25519 identity, ephemeral TLS X.509 certs, and EdDSA-signed capability JWT tokens with replay-attack nonce caching.
* **๐ก๏ธ Fault Tolerance & Isolation (`NFR-03`)**: Heartbeat decay failure detector isolating `SUSPECT` nodes at 10s and evicting `DEAD` nodes at 15s with automatic split-brain recovery.
* **โก High Performance (`NFR-04`)**: Verified intra-mesh routing overhead strictly `< 50ms` (measured ~3.5ms on localhost).
---
## ๐ฅ๏ธ Streamlit Control Center (`app.py`)
The repository includes a modern, operator-grade Streamlit web application with 5 interactive views:
1. **Mesh Topology Matrix**: Live Graphviz network graph and node status table with color-coded health states (`ALIVE`, `SUSPECT`, `DEAD`).
2. **Capability Registry Browser**: Searchable tools inventory, schema inspector, and live `mesh://capabilities/registry` JSON manifest viewer.
3. **Task Delegation Workbench**: Real-time form to issue delegated calls, generate signed EdDSA JWT tokens, and monitor execution latencies.
4. **Swarm Consensus Chamber**: Interactive multi-agent consensus prompts, quorum adjustments, and score synthesis.
5. **Security & Framing Telemetry**: Cryptographic key inspector, wire frame codec diagrams, and replay nonce cache monitor.
---
## ๐ Quick Start
### 1. Installation
```bash
git clone https://github.com/shinevijayan03/mcp-p2p-swarm-mesh.git
cd mcp-p2p-swarm-mesh
# Create virtualenv
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install package
pip install -e ".[dev]"
```
### 2. Launch the Streamlit Control Center
```bash
streamlit run app.py
```
Open your browser at `http://127.0.0.1:8501`.
### 3. Run Gateway Server
```bash
# Stdio transport mode (e.g. for Claude Desktop)
python -m mcp_mesh.gateway.server --mcp-mode stdio
# SSE transport mode
python -m mcp_mesh.gateway.server --mcp-mode sse --mcp-port 8000
```
---
## ๐งช Testing
The repository maintains an exhaustive test suite covering unit tests, integration tests, chaos network simulations, and security penetration vectors:
```bash
# Run all tests
pytest -v
# Run with test coverage report
pytest --cov=mcp_mesh --cov-report=term-missing tests/
```
**Result**: 28 passed, 0 failed (100% pass rate).
---
## ๐ Technical Specifications
* [IMPLEMENTATION_PLAN.md](IMPLEMENTATION_PLAN.md) โ Implementation roadmap, WBS, and risk mitigations.
* [ARCHITECTURE.md](ARCHITECTURE.md) โ Topology, wire framing format, gossip state machines, and sequence diagrams.
* [SOFTWARE_DESIGN.md](SOFTWARE_DESIGN.md) โ Module hierarchy, Pydantic schemas, event loops, and wire protocols.
* [TEST_STRATEGY.md](TEST_STRATEGY.md) โ Testing pyramid, async mocks, chaos injection, and benchmark setups.
* [TEST_CASES.md](TEST_CASES.md) โ Granular test cases mapping to `FR-01`..`FR-05`, `NFR-01`..`NFR-04`, and `EC-01`..`EC-04`.
* [DEPLOYMENT_PLAN.md](DEPLOYMENT_PLAN.md) โ Virtualenv cluster guide, Docker, Docker Compose, and monitoring specs.
* [USAGE_GUIDE.md](USAGE_GUIDE.md) โ Claude Desktop integration, Python MCP client SDK, and custom worker node creation.
* [PRIORITIZED_PLAN.md](PRIORITIZED_PLAN.md) โ 7-stage prioritized implementation roadmap.
---
## ๐ License
MIT License.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues