Expand description
Server module
Provides MCP server implementation with multiple transport protocols (stdio, HTTP, SSE, Hybrid).
§Main Components
CratesDocsServer: Main server structhandler: MCP request handlingtransport: Transport layer implementationauth: OAuth authentication support
§Handler Design
Single-layer architecture with all handling logic directly in CratesDocsHandler:
CratesDocsHandler: Implements MCP protocol handler interfaceHandlerConfig: Configuration class, supports merge operation
§Example
use crates_docs::{AppConfig, CratesDocsServer};
use crates_docs::server::handler::{CratesDocsHandler, HandlerConfig};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = AppConfig::default();
let server = Arc::new(CratesDocsServer::new(config)?);
// Create handler with merged config
let base_config = HandlerConfig::default();
let override_config = HandlerConfig::new().with_verbose_logging();
let handler = CratesDocsHandler::with_merged_config(
server,
base_config,
Some(override_config)
);
// Run HTTP server
let http_config = crates_docs::server::transport::HyperServerConfig::http();
crates_docs::server::transport::run_hyper_server(&handler.server(), http_config).await?;
Ok(())
}Re-exports§
pub use crate::config::ServerConfig;pub use handler::CratesDocsHandler;pub use transport::HyperServerConfig;
Modules§
- auth
- Authentication module
- auth_
middleware - Authentication middleware for HTTP requests
- handler
- MCP request handler implementation
- transport
- Transport module
Structs§
- Crates
Docs Server - Crates Docs MCP Server