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
- ID Generators
- Session Stores
- π Coming Soon
- Event Stores
- π Coming Soon
π 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 = new?;
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:
WorkOS AuthKit
An OAuth provider implementation for WorkOS Authkit.
- Example usage:
let auth_provider = new?;
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 = new
.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 SnowflakeIdGenerator;
let server = create_server;
πΎ 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