Skip to main content
Version: 1.1.0 (latest)

rust-mcp-extra

rust-mcp-extra is a companion crate to rust-mcp-sdk providing additional implementations of core traits. It includes ready-made auth providers, ID generators, and more.

[dependencies]
rust-mcp-extra = "1.0"

Default featuresโ€‹

The default feature set includes all ID generators and auth support.

ID Generatorsโ€‹

Use these to customize how session IDs are generated. They implement the IdGenerator trait and plug into AxumServerOptions or ActixServerOptions:

use rust_mcp_extra::id_generator::SnowflakeIdGenerator;
use std::sync::Arc;

let server = rust_mcp_axum::create_axum_server(
server_info, handler,
AxumServerOptions {
session_id_generator: Some(Arc::new(SnowflakeIdGenerator::new(1))), // machine ID = 1
..Default::default()
},
);
GeneratorFeature flagDescription
NanoIdGeneratornano_idShort, URL-safe random strings. Compact and user-friendly.
TimeBase64Generatortime_64_idTimestamp (ms) encoded as URL-safe Base64. Time-sortable.
RandomBase62Generatorrandom_62_idAlphanumeric [A-Za-z0-9] random strings.
SnowflakeIdGeneratorsnowflake_id64-bit time-ordered IDs with machine ID + sequence. Distributed-friendly.

Auth Providersโ€‹

Drop-in providers for common identity platforms - no need to build an AuthProvider implementation yourself:

ProviderModuleDocs
Keycloakauth_provider::keycloakKeycloak
WorkOS AuthKitauth_provider::work_osWorkOS
Scalekitauth_provider::scalekitScalekit

Each provider is a standalone AuthProvider implementation for MCP servers. They share the same building blocks from rust_mcp_sdk - AuthMetadataBuilder for discovery metadata and GenericOauthTokenVerifier for token verification - but none of them wraps RemoteAuthProvider, issues tokens, or performs registration. Token issuance and refresh always happen at the external identity provider; the providers here serve the OAuth discovery endpoints and verify incoming bearer tokens.

Token Verifiersโ€‹

GenericOauthTokenVerifier implements the OauthTokenVerifier trait from rust-mcp-sdk. To customize how tokens are validated, compose VerificationStrategies (JWKs, introspection, UserInfo) inside TokenVerifierOptions - or implement OauthTokenVerifier yourself.

use rust_mcp_extra::token_verifier::{GenericOauthTokenVerifier, TokenVerifierOptions};

let verifier = GenericOauthTokenVerifier::new(TokenVerifierOptions {
strategies: vec![/* JWKs / Introspection / UserInfo */],
validate_audience: None,
validate_issuer: None,
cache_capacity: None,
})?;

See Token Verification for details.

Coming Soonโ€‹

  • Session Store - persistent session management (SQLite, Redis)
  • Event Store - persistent event history for resumability
note

The sqlite module in rust-mcp-extra currently has placeholder implementations. These will be fleshed out in a future release.