rust-mcp-extra

Crates.iorust-mcp-extra
lib.rsrust-mcp-extra
version0.2.2
created_at2025-10-13 22:37:03.579877+00
updated_at2026-01-18 22:37:07.272136+00
descriptionA companion crate to rust-mcp-sdk offering extra implementations of core traits like SessionStore and EventStore, enabling integration with various database backends and third-party platforms such as AWS Lambda for serverless and cloud-native MCP applications.
homepage
repositoryhttps://github.com/rust-mcp-stack/rust-mcp-sdk
max_upload_size
id1881253
size178,873
Ali Hashemi (hashemix)

documentation

https://docs.rs/rust-mcp-extra

README

rust-mcp-extra

A companion crate to rust-mcp-sdk providing additional implementations for core traits like AuthProvider, IdGenerator, SessionStore and EventStore.

πŸ“– Table of Contents


πŸ” Authentication Providers

A collection of authentication providers that integrate seamlessly with the rust-mcp-sdk. These providers offer a ready-to-use integration with common identity systems, so developers don’t have to build an AuthProvider implementation for each provider themselves.

Keycloak

A full OAuth2/OpenID Connect provider integration for Keycloak backed identity systems. Useful for enterprise environments or self-hosted identity setups.

  • Example usage:
let auth_provider = KeycloakAuthProvider::new(KeycloakAuthOptions {
    keycloak_base_url: "http://localhost:8080/realms/master".to_string(),
    mcp_server_url: "http://localhost:3000".to_string(),
    resource_name: Some("Keycloak Oauth Test MCP Server".to_string()),
    required_scopes: None,
    client_id: "keycloak-client-id".to_string(),
    client_secret: "keycloak-client-secret".to_string(),
    token_verifier: None,
    resource_documentation: None,
})?;

Before running the example, ensure you have a Keycloak instance properly configured.
Follow the official MCP authorization tutorial for Keycloak setup:Keycloak Setup Guide

By default, the example assumes Keycloak is running at http://localhost:8080.

configure a confidential client in Keycloak and provide credentials as environment variables:

export AUTH_SERVER=http://localhost:8080/realms/master
export CLIENT_ID=your-confidential-client-id
export CLIENT_SECRET=your-client-secret
cargo run -p rust-mcp-extra --example keycloak-auth

WorkOS AuthKit

An OAuth provider implementation for WorkOS Authkit.

  • Example usage:
let auth_provider = WorkOsAuthProvider::new(WorkOSAuthOptions {
        authkit_domain: "https://stalwart-opera-85-staging.authkit.app".to_string(),
        mcp_server_url: "http://127.0.0.1:3000/mcp".to_string(),
        required_scopes: Some(vec!["openid", "profile"]),
        resource_name: Some("Workos Oauth Test MCP Server".to_string()),
        resource_documentation: None,
        token_verifier: None,
    })?;

Before running the example, make sure you enabled DCR (Dynamic Client Registration) in your WorkOS Authkit dashboard.

Set the AUTH_SERVER environment variable and start the example:

export AUTH_SERVER=https://stalwart-opera-85-staging.authkit.app
cargo run -p rust-mcp-extra --example workos-auth

Scalekit

An OAuth provider implementation for Scalekit.

  • Example usage:
let auth_provider = ScalekitAuthProvider::new(ScalekitAuthOptions {
    mcp_server_url: "http://127.0.0.1:3000/mcp".to_string(),
    required_scopes: Some(vec!["profile"]),
    token_verifier: None,
    resource_name: Some("Scalekit Oauth Test MCP Server".to_string()),
    resource_documentation: None,
    environment_url: "yourapp.scalekit.dev".to_string(),
    resource_id: "res_your-resource_id".to_string(),
})
.await?;

Set the ENVIRONMENT_URL and RESOURCE_ID environment variable and start the example:

export ENVIRONMENT_URL=yourapp.scalekit.dev
export RESOURCE_ID=res_your-resource_id
cargo run -p rust-mcp-extra --example scalekit-auth

πŸ”’ ID Generators

Various implementations of the IdGenerator trait (from rust-mcp-sdk) for generating unique identifiers.

| 🧩 All ID generators in this crate can be used as SessionId generators in rust-mcp-sdk).

Generator Description
NanoIdGenerator Generates short, URL-safe, random string IDs using the nanoid crate. Ideal for user-friendly, compact identifiers.
TimeBase64Generator Encodes the current timestamp (in milliseconds) into a URL-safe Base64 string. Useful when IDs should be time-sortable and compact.
RandomBase62Generator Generates alphanumeric [A–Z, a–z, 0–9] strings using random bytes. A simple, reliable option for random unique IDs.
SnowflakeIdGenerator Inspired by Twitter’s Snowflake algorithm. Generates 64-bit time-ordered IDs containing timestamp, machine ID, and sequence. Best for distributed or high-throughput systems.

How to use

Provide an instance of your chosen ID generator in the HyperServerOptions when initializing the server.

For example to use SnowflakeIdGenerator :

use rust_mcp_extra::id_generator::SnowflakeIdGenerator;


let server = hyper_server::create_server(
    server_details,
    handler,
    HyperServerOptions {
        host: "127.0.0.1".to_string(),
        session_id_generator: Some(Arc::new(SnowflakeIdGenerator::new(1015))), // use SnowflakeIdGenerator
        ..Default::default()
    },
);


πŸ’Ύ Session Stores

SessionStore implementations are available for managing MCP sessions effectively.

πŸ”œ Coming Soon


πŸ’½ Event Stores

EventStore implementations to enable resumability on MCP servers by reliably storing and replaying event histories.

πŸ”œ Coming Soon

Commit count: 191

cargo fmt