Skip to main content
Version: 1.1.0 (latest)

Axum Backend

Add rust-mcp-axum to your dependencies:

[dependencies]
rust-mcp-axum = "1.0"
rust-mcp-sdk = { version = "1.0", default-features = false, features = ["server", "macros"] }

Creating an Axum MCP Serverโ€‹

use rust_mcp_axum::{create_axum_server, AxumServerOptions};

let server = create_axum_server(
server_info,
handler.to_mcp_server_handler(),
AxumServerOptions {
host: "127.0.0.1".into(),
port: 8080,
event_store: Some(Arc::new(InMemoryEventStore::default())),
task_store: Some(Arc::new(InMemoryTaskStore::new(None))),
auth: None, // or Some(Arc::new(auth_provider))
health_endpoint: Some("/health".into()),
sse_support: true,
..Default::default()
},
);
server.start().await?;

AxumServerOptionsโ€‹

FieldTypeDefaultDescription
hostString"127.0.0.1"Bind address
portu168080Port number
event_storeOption<Arc<dyn EventStore>>NoneFor resumability
task_storeOption<Arc<ServerTaskStore>>NoneServer-side tasks
client_task_storeOption<Arc<ClientTaskStore>>NoneClient-side tasks
authOption<Arc<dyn AuthProvider>>NoneOAuth provider
health_endpointOption<String>NoneHealth check path
health_handlerOption<Arc<dyn HealthHandler>>NoneCustom health handler
max_request_body_sizeOption<usize>None (4 MiB)Max request body size in bytes
session_storeOption<Arc<dyn SessionStore>>NoneCustom session backend
enable_ssl / ssl_cert_path / ssl_key_pathsee TLS/SSLdisabledTLS configuration
dns_rebindingDnsRebindingOptionsenabledDNS rebinding protection (allowed_hosts, allowed_origins)
sse_supportbooltrueEnable SSE fallback

See AxumServerOptions for all fields.