R

mcp-client-rs

...
Created 12/2/2024bytim-schultz

Language:

Rust

Stars:

4

Forks:

0

MCP Protocol Client - Very Much a WIP

Rust client implementation for the Model Context Protocol - a structured communication protocol between language models and external tools.

Features

  • Client implementation to be used in rust projects that want to use the MCP protocol
  • Async/await support with tokio
  • Capability negotiation
  • Tool execution
  • Resource management
  • Prompt handling

Usage

use mcp_client_rs::{Protocol, ClientError};

#[tokio::main]
async fn main() -> Result {
    let client = Protocol::new(
        "0",  // Protocol version
        "npx", // Command
        vec!["-y", "@modelcontextprotocol/server-github"], // Args
        std::collections::HashMap::new(), // Environment variables
    ).await?;

    // Call tools
    let response = client
        .call_tool(
            "search_repositories",
            serde_json::json!({
                "query": "rust language:rust"
            }),
        )
        .await?;

    println!("{:?}", response);
    Ok(())
}

Installation

Add to your Cargo.toml:

[dependencies]
mcp-client-rs = { git = "https://github.com/tim-schultz/mcp-client-rs.git" }

License

MIT

Last updated: 2/24/2025

Publisher info

tim-schultz's avatar
96
followers
116
following
61
repos

More MCP servers built with Rust

cal2prompt

✨ Fetches your schedule (Google Calendar) and outputs it as a single LLM prompt, with an optional MCP server mode.

By shuntaka95764
mcp-sdk-rs

An MCP client/server library for Rust

By jgmartin3
mcp-server-runner

A WebSocket server implementation for running Model Context Protocol (MCP) servers. This application enables MCP servers to be accessed via WebSocket connections, facilitating integration with web applications and other network-enabled clients.

By yonaka153