MCP Mesh
Decentralized peer-to-peer federation for MCP servers, enabling a single client to bridge and communicate with multiple servers through a mesh network.
README
MCP Mesh
DEPRECATED: This package has been absorbed into mcp-iot-gateway. The federation functionality is now built-in to the gateway as the
@mcp-iot-gateway/corefederation module. This repository is archived for reference only.
Peer-to-peer federation for MCP servers.
MCP Mesh enables decentralized, peer-to-peer communication between MCP servers. It solves the fundamental limitation of MCP's client-server model: a single client can only connect to one server at a time.
┌─────────────┐
│ Claude │
└──────┬──────┘
│
┌──────▼──────┐
│ mcp-mesh │ ← One connection
└──────┬──────┘
│ bridges to many
┌────────────┴────────────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ factory │◀────────▶│ edge │
│ gateway │ peers │ gateway │
└─────────────┘ └─────────────┘
Features
- Bridge Mode - Re-export remote tools locally with prefixes (
factory_iot_discover) - P2P Connections - Direct node-to-node communication
- Hub Mode - Optional central coordinator for network management
- meshctl CLI - Hamachi-style network management
- Pure MCP - No protocol extensions, works with any MCP client
Installation
npm install mcp-mesh
Or run directly:
npx mcp-mesh --help
Quick Start
P2P Mode (Direct Connections)
Start a mesh node that bridges to other gateways:
# Start mesh node bridging to factory and edge gateways
mcp-mesh --port 45679 --name "my-mesh" --bridge factory --bridge edge
The bridged tools become available with prefixes:
factory_iot_discover→ callsiot_discoveron factoryedge_gateway_status→ callsgateway_statuson edge
Hub Mode (Centralized Network)
Start a hub for network coordination:
# Start hub
mcp-mesh --hub --port 45679 --name "central" --network "mycompany"
# Join from other nodes
mcp-mesh --port 45680 --name "factory-gw" --join http://hub:45679/mcp
Claude Desktop Integration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mcp-mesh": {
"command": "npx",
"args": [
"mcp-mesh",
"--stdio",
"--name", "claude-desktop",
"--bridge", "factory",
"--bridge", "edge"
]
}
}
}
CLI Reference
mcp-mesh
mcp-mesh [options]
Options:
--stdio Use stdio transport (for MCP clients)
--port <port> HTTP server port (default: 45679)
--name <name> Human-readable name for this node
--bridge <spec> Bridge to a peer (UUID, name, or URL). Repeatable.
--peer <key=url> Connect to a peer without bridging. Repeatable.
--hub Run as hub (central coordinator)
--join <url> Join a hub network by URL
--network <id> Network ID (for hub mode)
meshctl
Network management CLI (Hamachi-style):
meshctl status Show local node status
meshctl list List all nodes in directory
meshctl networks List available hubs
meshctl network <hub-url> Show network details
meshctl join <hub-url> Join a network
meshctl connect <peer> Connect to peer
meshctl disconnect <peer> Disconnect from peer
API Usage
Basic Node
import { MeshNode, registerMeshTools } from "mcp-mesh";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
// Create mesh node
const node = new MeshNode({
name: "my-server",
url: "http://localhost:45678/mcp",
});
// Add mesh tools to your MCP server
const server = new McpServer({ name: "my-server", version: "1.0" });
registerMeshTools(server, node);
// Connect to peers
await node.bridge("factory"); // Bridge with prefix
await node.connectPeer({ key: "edge", url: "http://edge:45678/mcp" });
Hub Mode
const hub = new MeshNode({
name: "central-hub",
hub: true,
networkId: "mycompany",
});
// Nodes register automatically via mesh_hub_register tool
// Or programmatically:
hub.hubRegister({
id: "node-uuid",
name: "factory",
url: "http://factory:45678/mcp",
});
// Get network status
const stats = hub.hubStats();
const nodes = hub.hubListNodes({ onlineOnly: true });
Directory Lookup
import { MeshDirectory } from "mcp-mesh";
const directory = new MeshDirectory();
// List all known nodes
const nodes = directory.list();
// Look up by name or UUID
const factory = directory.lookup("factory");
console.log(factory?.url); // http://127.0.0.1:45678/mcp
// Resolve any specifier (URL, UUID, or name)
const entry = directory.resolve("factory");
MCP Tools
When registerMeshTools() is called, these tools are added:
Peer Management
| Tool | Description |
|---|---|
mesh_list_peers |
List all peer connections |
mesh_add_peer |
Connect to a peer |
mesh_remove_peer |
Disconnect from a peer |
mesh_call_peer |
Call a tool on a peer |
mesh_list_peer_tools |
List tools on a peer |
Bridge Mode
| Tool | Description |
|---|---|
mesh_list_bridged_tools |
List tools from bridge peers |
mesh_call_bridged |
Call a bridged tool |
Directory
| Tool | Description |
|---|---|
mesh_directory_list |
List all nodes in directory |
mesh_directory_lookup |
Look up a node |
mesh_node_info |
Get this node's info |
Hub Mode (when --hub)
| Tool | Description |
|---|---|
mesh_hub_register |
Register a node with hub |
mesh_hub_heartbeat |
Send heartbeat |
mesh_hub_list_nodes |
List registered nodes |
mesh_hub_stats |
Get hub statistics |
mesh_hub_connect_node |
Connect to a registered node |
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
MCP_MESH_DATA_DIR |
Data directory | ~/.config/mcp-mesh |
MCP_MESH_PEERS |
Peers file path | ~/.config/mcp-mesh/peers |
Peers File
The directory file at ~/.config/mcp-mesh/peers uses a hosts-style format:
# MCP Mesh Peers
# Format: UUID URL [NAME]
#
a7196323-dcc1-4109-abf5-b47c2f99f920 http://127.0.0.1:45678/mcp factory
9f157a51-7aaa-4f2c-bc38-3c791b604892 http://127.0.0.1:45679/mcp edge
Architecture
See ARCHITECTURE.md for detailed design documentation.
Topology Options
P2P (Decentralized)
A ←──→ B
↑ ↑
│ │
↓ ↓
C ←──→ D
- No single point of failure
- Works offline/air-gapped
- Each node manages its own connections
Hub (Centralized)
Hub
/ | \
A B C
- Central registry and coordination
- Easier network management
- Better for enterprise/audit requirements
Hybrid
Hub
/ | \
Site Site Site
/\ | /\
A B C D E
- Hub for cross-site coordination
- P2P within sites
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。