A Model Context Protocol (MCP) server that provides programmatic access to js-libp2p universal-connectivity functionality, enabling AI assistants to interact with peer-to-peer networks, manage connections, send messages, and share files.
- Create and configure libp2p nodes with custom transports
- Start/stop nodes with graceful shutdown
- Monitor node status and addresses
- Support for WebRTC, WebSockets, and WebTransport
- Discover peers using pubsub peer discovery
- Connect to peers via multiaddr or peer ID
- Manage active connections
- Ping peers to test connectivity
- Access peer store information
- Send messages to pubsub topics (group chat)
- Send direct messages to specific peers
- Subscribe/unsubscribe to topics
- Retrieve message history
- Get topic subscriber lists
- Share files using the file exchange protocol
- Request files from peers
- Announce file availability to the network
- List shared files with metadata
- Real-time network statistics
- Protocol handler information
- Debug logging configuration
- Peer store insights
- Run the MCP Server in terminal
npm start- Connect with Claude Desktop App via
Edit ConfiginFileNavbar -->Settings-->DeveloperTab or just pressCtrl + ,to opensettings menuand edit the config file in any IDE as below:
claude_desktop_config.json
{
"mcpServers": {
"universal-connectivity": {
"command": "node",
"args": ["path-to-file-location/js-peer-mcp-server/dist/index.js"], // C:/js-peer-mcp-server/dist/index.js
"env": {}
}
}
}
- Close and Reopen the Claude Desktop App and a
New Chat, you will now be able to view theuniversal-connectivityoption insearch and toolsbutton of the input area.
ALWAYS ENSURE YOUR MCP SERVER IS RUNNING VIA
npm startTO ACTIVATE THE JS-LIBP2P related operations
- Go ahead and chat with Claude for any libp2p related commands and it will present you with relevant results seamlessly! incredible, right?
Try this commands to get started:-
create libp2p node, 'start libp2p node', 'stop libp2p node', 'get node status'
- You can Further change permission access for this mcp-server through the left-bottom Your Account tab --> Settings --> Integrations -->
universal-connectivity: tools and settings options:
{
"method": "create_libp2p_node",
"params": {
"transports": ["webrtc", "websockets", "webtransport"],
"enableRelay": true
}
}{
"method": "discover_peers",
"params": {
"timeout": 10000
}
}{
"method": "send_group_message",
"params": {
"topic": "universal-connectivity",
"message": "Hello from MCP!"
}
}{
"method": "share_file",
"params": {
"filePath": "/path/to/file.txt",
"announce": true
}
}create_libp2p_node- Initialize a new libp2p nodestart_libp2p_node- Start the libp2p nodestop_libp2p_node- Stop the libp2p nodeget_node_status- Get current node status
discover_peers- Discover peers on the networkconnect_to_peer- Connect to a specific peerdisconnect_from_peer- Disconnect from a peerlist_connections- List active connectionsget_peer_info- Get detailed peer informationping_peer- Ping a peer to test connectivity
send_group_message- Send message to a topicsend_direct_message- Send private message to a peersubscribe_to_topic- Subscribe to a pubsub topicunsubscribe_from_topic- Unsubscribe from a topicget_message_history- Retrieve message historyget_topic_subscribers- Get topic subscriber list
share_file- Share a file with the networkrequest_file- Request a file from a peerlist_shared_files- List available shared filesannounce_file- Announce file availability
get_network_stats- Get network statisticsget_protocol_handlers- List protocol handlersenable_debug_logging- Configure debug loggingget_peer_store_info- Get peer store information
connections://active- Current active connectionspeers://discovered- Recently discovered peersnetwork://stats- Network statisticsnode://info- Node information and statusfiles://shared- Shared files catalogmessages://topic/{topicName}- Messages for specific topicmessages://peer/{peerId}- Direct messages with specific peer
The server supports various configuration options:
interface NodeConfig {
transports?: string[] // ['webrtc', 'websockets', 'webtransport']
enableRelay?: boolean // Enable circuit relay (default: true)
bootstrapPeers?: string[] // Custom bootstrap peer multiaddrs
listenAddresses?: string[] // Custom listen addresses
}- WebRTC: Browser-to-browser connections
- WebSockets: Traditional WebSocket connections
- WebTransport: Modern QUIC-based transport
- Circuit Relay: NAT traversal and hole punching
- Gossipsub: Publish-subscribe messaging
- Direct Messages: Peer-to-peer messaging protocol
- File Exchange: Custom file sharing protocol
The server provides comprehensive error handling with descriptive messages:
- Connection failures and timeouts
- Invalid peer IDs or multiaddrs
- Network protocol errors
- File transfer interruptions
- Message delivery failures
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm run test
# Lint code
npm run lint
# Format code
npm run formatThe MCP server is built with a modular architecture:
- State Manager: Centralized state management
- Tool Handlers: Organized by functionality (node, peer, messaging, etc.)
- Resource Providers: Dynamic resource access
- Protocol Integration: Direct integration with libp2p protocols
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
- libp2p - Modular peer-to-peer networking stack
- universal-connectivity - Universal connectivity examples
- Model Context Protocol - MCP specification






