rust-mcp-sdk 0.9.0

An asynchronous SDK and framework for building MCP-Servers and MCP-Clients, leveraging the rust-mcp-schema for type safe MCP Schema Objects.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::mcp_traits::IdGenerator;
use uuid::Uuid;

/// An [`IdGenerator`] implementation that uses UUID v4 to create unique identifiers.
///
/// This generator produces random UUIDs (version 4), which are highly unlikely
/// to collide and difficult to predict. It is therefore well-suited for
/// generating identifiers such as `SessionId` or other values where uniqueness is important.
pub struct UuidGenerator;

impl<T> IdGenerator<T> for UuidGenerator
where
    T: From<String>,
{
    fn generate(&self) -> T {
        T::from(Uuid::new_v4().to_string())
    }
}