pub struct UltraFastServer { /* private fields */ }Expand description
MCP Server implementation
Implementations§
Source§impl UltraFastServer
impl UltraFastServer
Sourcepub fn new(info: ServerInfo, capabilities: ServerCapabilities) -> Self
pub fn new(info: ServerInfo, capabilities: ServerCapabilities) -> Self
Create a new UltraFastServer with the given info and capabilities
Sourcepub async fn set_logging_config(&self, config: ServerLoggingConfig)
pub async fn set_logging_config(&self, config: ServerLoggingConfig)
Configure server logging
Sourcepub async fn get_logging_config(&self) -> ServerLoggingConfig
pub async fn get_logging_config(&self) -> ServerLoggingConfig
Get current server logging configuration
Sourcepub fn with_timeout_config(self, config: TimeoutConfig) -> Self
pub fn with_timeout_config(self, config: TimeoutConfig) -> Self
Set timeout configuration
Sourcepub fn get_timeout_config(&self) -> TimeoutConfig
pub fn get_timeout_config(&self) -> TimeoutConfig
Get current timeout configuration
Sourcepub fn with_high_performance_timeouts(self) -> Self
pub fn with_high_performance_timeouts(self) -> Self
Set timeout configuration for high-performance scenarios
Sourcepub fn with_long_running_timeouts(self) -> Self
pub fn with_long_running_timeouts(self) -> Self
Set timeout configuration for long-running operations
Sourcepub fn get_operation_timeout(&self, operation: &str) -> Duration
pub fn get_operation_timeout(&self, operation: &str) -> Duration
Get timeout for a specific operation
Sourcepub fn validate_timeout_config(&self) -> Result<(), String>
pub fn validate_timeout_config(&self) -> Result<(), String>
Validate timeout configuration
Sourcepub async fn set_log_level(&self, level: LogLevel) -> MCPResult<()>
pub async fn set_log_level(&self, level: LogLevel) -> MCPResult<()>
Set the current log level
Sourcepub async fn get_log_level(&self) -> LogLevel
pub async fn get_log_level(&self) -> LogLevel
Get the current log level
Sourcepub fn with_monitoring_config(self, config: MonitoringConfig) -> Self
pub fn with_monitoring_config(self, config: MonitoringConfig) -> Self
Enable monitoring with custom configuration
Sourcepub fn with_monitoring(self) -> Self
pub fn with_monitoring(self) -> Self
Enable monitoring with default configuration
Sourcepub fn with_health_checks(self) -> Self
pub fn with_health_checks(self) -> Self
Enable health checks with default configuration
Sourcepub fn with_metrics(self) -> Self
pub fn with_metrics(self) -> Self
Enable metrics collection with default configuration
Sourcepub fn with_tracing(self) -> Self
pub fn with_tracing(self) -> Self
Enable tracing with default configuration
Sourcepub fn with_full_monitoring(self) -> Self
pub fn with_full_monitoring(self) -> Self
Enable all monitoring features (health checks, metrics, tracing)
Sourcepub fn with_middleware(self) -> Self
pub fn with_middleware(self) -> Self
Enable middleware support
Sourcepub fn with_recovery(self) -> Self
pub fn with_recovery(self) -> Self
Enable recovery mechanisms
Sourcepub fn with_oauth(self) -> Self
pub fn with_oauth(self) -> Self
Enable OAuth authentication
Sourcepub fn with_authentication(
self,
_token_validator: (),
_required_scopes: Vec<String>,
) -> Self
pub fn with_authentication( self, _token_validator: (), _required_scopes: Vec<String>, ) -> Self
Enable authentication with custom configuration (feature removed)
Sourcepub fn with_bearer_auth(
self,
_secret: String,
_required_scopes: Vec<String>,
) -> Self
pub fn with_bearer_auth( self, _secret: String, _required_scopes: Vec<String>, ) -> Self
Enable Bearer token authentication (feature removed)
Sourcepub fn with_api_key_auth(self) -> Self
pub fn with_api_key_auth(self) -> Self
Enable API key authentication
Sourcepub fn with_basic_auth(self) -> Self
pub fn with_basic_auth(self) -> Self
Enable Basic authentication
Sourcepub fn with_rate_limiting(self, requests_per_minute: u32) -> Self
pub fn with_rate_limiting(self, requests_per_minute: u32) -> Self
Enable rate limiting
Sourcepub fn with_request_validation(self) -> Self
pub fn with_request_validation(self) -> Self
Enable request validation
Sourcepub fn with_response_caching(self) -> Self
pub fn with_response_caching(self) -> Self
Enable response caching
Sourcepub fn monitoring(&self) -> Option<Arc<MonitoringSystem>>
pub fn monitoring(&self) -> Option<Arc<MonitoringSystem>>
Get the monitoring system if available
Sourcepub async fn create_context(&self) -> Context
pub async fn create_context(&self) -> Context
Create a context with the current server logging configuration
Sourcepub async fn create_context_with_ids(
&self,
request_id: String,
session_id: Option<String>,
) -> Context
pub async fn create_context_with_ids( &self, request_id: String, session_id: Option<String>, ) -> Context
Create a context with custom request and session IDs
Sourcepub async fn register_tool(
&self,
tool: Tool,
) -> Result<(), ToolRegistrationError>
pub async fn register_tool( &self, tool: Tool, ) -> Result<(), ToolRegistrationError>
Register a tool with validation
Sourcepub async fn register_tools(
&self,
tools: Vec<Tool>,
) -> Result<(), ToolRegistrationError>
pub async fn register_tools( &self, tools: Vec<Tool>, ) -> Result<(), ToolRegistrationError>
Register multiple tools
Sourcepub async fn unregister_tool(&self, name: &str) -> bool
pub async fn unregister_tool(&self, name: &str) -> bool
Unregister a tool by name
Sourcepub async fn list_tools(&self) -> Vec<Tool>
pub async fn list_tools(&self) -> Vec<Tool>
List all registered tools
Sourcepub async fn tool_count(&self) -> usize
pub async fn tool_count(&self) -> usize
Get tool count
Sourcepub async fn clear_tools(&self)
pub async fn clear_tools(&self)
Clear all tools
Sourcepub async fn validate_tool_call(
&self,
tool_name: &str,
arguments: &Value,
) -> Result<(), MCPError>
pub async fn validate_tool_call( &self, tool_name: &str, arguments: &Value, ) -> Result<(), MCPError>
Validate tool call arguments against tool schema
Sourcepub async fn execute_tool_call(
&self,
tool_name: &str,
arguments: Value,
) -> Result<ToolResult, MCPError>
pub async fn execute_tool_call( &self, tool_name: &str, arguments: Value, ) -> Result<ToolResult, MCPError>
Execute a tool call with validation
Sourcepub fn with_tool_handler(self, handler: Arc<dyn ToolHandler>) -> Self
pub fn with_tool_handler(self, handler: Arc<dyn ToolHandler>) -> Self
Add a tool handler to the server
Sourcepub fn with_resource_handler(self, handler: Arc<dyn ResourceHandler>) -> Self
pub fn with_resource_handler(self, handler: Arc<dyn ResourceHandler>) -> Self
Add a resource handler to the server
Sourcepub fn with_prompt_handler(self, handler: Arc<dyn PromptHandler>) -> Self
pub fn with_prompt_handler(self, handler: Arc<dyn PromptHandler>) -> Self
Add a prompt handler to the server
Sourcepub fn with_sampling_handler(self, handler: Arc<dyn SamplingHandler>) -> Self
pub fn with_sampling_handler(self, handler: Arc<dyn SamplingHandler>) -> Self
Add a sampling handler to the server
Sourcepub fn with_completion_handler(
self,
handler: Arc<dyn CompletionHandler>,
) -> Self
pub fn with_completion_handler( self, handler: Arc<dyn CompletionHandler>, ) -> Self
Add a completion handler to the server
Sourcepub fn with_roots_handler(self, handler: Arc<dyn RootsHandler>) -> Self
pub fn with_roots_handler(self, handler: Arc<dyn RootsHandler>) -> Self
Add a roots handler to the server
Sourcepub fn with_elicitation_handler(
self,
handler: Arc<dyn ElicitationHandler>,
) -> Self
pub fn with_elicitation_handler( self, handler: Arc<dyn ElicitationHandler>, ) -> Self
Add an elicitation handler to the server
Sourcepub fn with_subscription_handler(
self,
handler: Arc<dyn ResourceSubscriptionHandler>,
) -> Self
pub fn with_subscription_handler( self, handler: Arc<dyn ResourceSubscriptionHandler>, ) -> Self
Add a subscription handler to the server
Sourcepub fn with_logging_config(self, config: ServerLoggingConfig) -> Self
pub fn with_logging_config(self, config: ServerLoggingConfig) -> Self
Configure logging with a custom configuration
Sourcepub async fn run_with_transport(
&self,
transport: Box<dyn Transport>,
) -> MCPResult<()>
pub async fn run_with_transport( &self, transport: Box<dyn Transport>, ) -> MCPResult<()>
Run the server with a custom transport
Sourcepub async fn run_streamable_http(&self, host: &str, port: u16) -> MCPResult<()>
pub async fn run_streamable_http(&self, host: &str, port: u16) -> MCPResult<()>
Run the server with Streamable HTTP transport
Sourcepub async fn run_http(&self, config: HttpTransportConfig) -> MCPResult<()>
pub async fn run_http(&self, config: HttpTransportConfig) -> MCPResult<()>
Run the server with HTTP transport
Sourcepub async fn run_streamable_http_with_config(
&self,
config: HttpTransportConfig,
) -> MCPResult<()>
pub async fn run_streamable_http_with_config( &self, config: HttpTransportConfig, ) -> MCPResult<()>
Run the server with custom Streamable HTTP transport configuration This provides clearer naming for advanced Streamable HTTP configuration
Sourcepub fn info(&self) -> &ServerInfo
pub fn info(&self) -> &ServerInfo
Get server info
Sourcepub fn cancellation_manager(&self) -> Arc<CancellationManager>
pub fn cancellation_manager(&self) -> Arc<CancellationManager>
Get cancellation manager
Sourcepub fn ping_manager(&self) -> Arc<PingManager>
pub fn ping_manager(&self) -> Arc<PingManager>
Get ping manager
Sourcepub async fn start_ping_monitoring(
&self,
ping_interval: Duration,
) -> MCPResult<()>
pub async fn start_ping_monitoring( &self, ping_interval: Duration, ) -> MCPResult<()>
Start periodic ping monitoring (optional, for connection health) This method should be called after the server is running with a transport
Sourcepub async fn stop_ping_monitoring(&self) -> MCPResult<()>
pub async fn stop_ping_monitoring(&self) -> MCPResult<()>
Stop ping monitoring
Sourcepub async fn get_state(&self) -> ServerState
pub async fn get_state(&self) -> ServerState
Get current server state
Sourcepub async fn can_operate(&self) -> bool
pub async fn can_operate(&self) -> bool
Check if server can accept operations
Sourcepub async fn notify_tools_changed(
&self,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_tools_changed( &self, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send tools list changed notification
Sourcepub async fn notify_resources_changed(
&self,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_resources_changed( &self, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send resources list changed notification
Sourcepub async fn notify_prompts_changed(
&self,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_prompts_changed( &self, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send prompts list changed notification
Sourcepub async fn notify_resource_updated(
&self,
uri: String,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_resource_updated( &self, uri: String, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send resource updated notification
Sourcepub async fn notify_progress(
&self,
progress_token: Value,
progress: f64,
total: Option<f64>,
message: Option<String>,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_progress( &self, progress_token: Value, progress: f64, total: Option<f64>, message: Option<String>, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send progress notification
Sourcepub async fn notify_logging_message(
&self,
level: LogLevel,
data: Value,
logger: Option<String>,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_logging_message( &self, level: LogLevel, data: Value, logger: Option<String>, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send logging message notification
Sourcepub async fn notify_cancelled(
&self,
request_id: Value,
reason: Option<String>,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_cancelled( &self, request_id: Value, reason: Option<String>, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send cancellation notification
Sourcepub async fn notify_roots_changed(
&self,
transport: &mut Box<dyn Transport>,
) -> MCPResult<()>
pub async fn notify_roots_changed( &self, transport: &mut Box<dyn Transport>, ) -> MCPResult<()>
Send roots list changed notification
Sourcepub fn with_advanced_sampling_handler(
self,
handler: Arc<dyn AdvancedSamplingHandler>,
) -> Self
pub fn with_advanced_sampling_handler( self, handler: Arc<dyn AdvancedSamplingHandler>, ) -> Self
Set the advanced sampling handler for context collection and human-in-the-loop features
Sourcepub fn with_default_advanced_sampling(self) -> Self
pub fn with_default_advanced_sampling(self) -> Self
Set the advanced sampling handler with default implementation
Sourcepub async fn handle_set_roots(
&self,
roots: Vec<Root>,
transport: &mut Box<dyn Transport>,
) -> SetRootsResponse
pub async fn handle_set_roots( &self, roots: Vec<Root>, transport: &mut Box<dyn Transport>, ) -> SetRootsResponse
Handle a roots/set request
Trait Implementations§
Source§impl Clone for UltraFastServer
impl Clone for UltraFastServer
Source§fn clone(&self) -> UltraFastServer
fn clone(&self) -> UltraFastServer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more