pub struct HttpTransport { /* private fields */ }Expand description
HTTP transport for MCP protocol
Implements the MCP HTTP transport specification:
- HTTP POST for client-to-server messages
- Server-Sent Events (SSE) for server-to-client streaming
- Session management with Mcp-Session-Id header
- Origin validation and CORS support
- Authentication support
Implementations§
Source§impl HttpTransport
impl HttpTransport
Sourcepub fn config(&self) -> &HttpConfig
pub fn config(&self) -> &HttpConfig
Get the configuration
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the transport is initialized
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the server is running
Sourcepub async fn broadcast_message(
&self,
message: &str,
) -> Result<(), TransportError>
pub async fn broadcast_message( &self, message: &str, ) -> Result<(), TransportError>
Send a message to all connected SSE clients
Sourcepub fn with_config(config: HttpConfig) -> Self
pub fn with_config(config: HttpConfig) -> Self
Create a new HTTP transport with custom configuration
Sourcepub fn validate_origin(
config: &HttpConfig,
headers: &HeaderMap,
) -> Result<(), TransportError>
pub fn validate_origin( config: &HttpConfig, headers: &HeaderMap, ) -> Result<(), TransportError>
Validate origin header
Sourcepub fn validate_auth(
config: &HttpConfig,
headers: &HeaderMap,
) -> Result<(), TransportError>
pub fn validate_auth( config: &HttpConfig, headers: &HeaderMap, ) -> Result<(), TransportError>
Validate authentication
Trait Implementations§
Source§impl Transport for HttpTransport
impl Transport for HttpTransport
fn start<'life0, 'async_trait>(
&'life0 mut self,
handler: RequestHandler,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for HttpTransport
impl !RefUnwindSafe for HttpTransport
impl Send for HttpTransport
impl Sync for HttpTransport
impl Unpin for HttpTransport
impl !UnwindSafe for HttpTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more