MCP ExplorerExplorer

Commune

@jgmartinon a year ago
3 MIT
FreeCommunity
AI Systems
#client#mcp#model-context-protocol#rust#sdk#server
A Rust library designed to support the development of discoverable networks of AI agents.

Overview

What is Commune

Commune is a Rust library designed to facilitate the development of discoverable networks of AI agents, enhancing peer discovery and resource utilization within Model Context Protocol (MCP) networks.

Use cases

Use cases include building applications that require resource sharing among AI agents, managing notifications for resource updates, and simplifying interactions with inference APIs.

How to use

To use Commune, include it in your Cargo.toml file and utilize its API to create peers for MCP servers, aggregate resources, and manage communication through WebSocket.

Key features

Key features include peer discovery, resource aggregation, WebSocket communication support (with and without TLS), and type conversion for various inference APIs like AWS and OpenAI.

Where to use

Commune can be used in fields such as AI development, distributed systems, and any application requiring collaborative AI agent networks.

Content

Commune

Commune is a Rust library designed to support the development of discoverable networks of AI agents. It serves as a wrapper over mcp-sdk-rs, providing enhanced functionality for peer discovery and resource utilization within Model Context Protocol (MCP) networks.

Features

  • Discover and maintain a list of peer MCP servers
  • Utilize available tools, prompts, and resources from peer servers
  • Support for WebSocket communication (with and without TLS encryption)
  • Type conversion for AWS, OpenAI, and other inference APIs, simplifying their usage

Installation

Add the following to your Cargo.toml:

[dependencies]
commune = { package = "mcp-commune", version = "0.1.2" }

Usage

use commune::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a peer for each MCP server
    let peer1 = PeerBuilder::new()
        .with_name("everything".to_string())
        .with_url("ws://localhost:8780".to_string())
        .with_description("various example resources".to_string())
        .build()
        .await?;
    let peer2 = PeerBuilder::new()
        .with_name("memory".to_string())
        .with_url("ws://localhost:8781".to_string())
        .with_description("memory based on a knowledge graph".to_string())
        .build()
        .await?;

    // Optionally create a commune client
    let commune_client = ClientBuilder::new()
        .with_peers(vec![peer1.clone(), peer2])
        .build()
        .await?;

    // Use the client to aggregate resources
    // Get all tools
    let peer_tools = commune_client.all_tools().await?;
    log::info!("found {} tools", peer_tools.len());

    // Get all resources
    let peer_resources = commune_client.all_resources().await?;
    log::info!("found {} resources!", peer_resources.len());

    // Get all prompts
    let peer_prompts = commune_client.all_prompts().await?;
    log::info!("found {} prompts!", peer_prompts.len());

    // Use peers to utilize them, subscribe to notifications etc
    // Subscribe to resource updates
    peer1.subscribe("test://static/resource/2").await?;

    Ok(())
}

Type Conversion

Commune provides convenient type conversion implementations for various inference APIs, including:

  • AWS Bedrock
  • OpenAI (coming soon)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers