pub struct McpProtocol { /* private fields */ }
Expand description
MCP Protocol handler
Implementations§
Source§impl McpProtocol
impl McpProtocol
Sourcepub fn generate_message_id(&self) -> String
pub fn generate_message_id(&self) -> String
Generate unique message ID
Sourcepub fn create_initialize_request(
&self,
client_info: ClientInfo,
capabilities: ClientCapabilities,
) -> McpMessage
pub fn create_initialize_request( &self, client_info: ClientInfo, capabilities: ClientCapabilities, ) -> McpMessage
Create initialize request message
Sourcepub fn create_initialize_response(
&self,
request_id: &str,
server_info: ServerInfo,
capabilities: ServerCapabilities,
) -> McpMessage
pub fn create_initialize_response( &self, request_id: &str, server_info: ServerInfo, capabilities: ServerCapabilities, ) -> McpMessage
Create initialize response message
Sourcepub fn create_tool_call_request(
&self,
tool_name: &str,
arguments: Value,
session_id: &str,
) -> McpMessage
pub fn create_tool_call_request( &self, tool_name: &str, arguments: Value, session_id: &str, ) -> McpMessage
Create tool call request message
Sourcepub fn create_tool_result_response(
&self,
request_id: &str,
content: Vec<McpContent>,
is_error: bool,
error: Option<String>,
) -> McpMessage
pub fn create_tool_result_response( &self, request_id: &str, content: Vec<McpContent>, is_error: bool, error: Option<String>, ) -> McpMessage
Create tool result response message
Sourcepub fn create_error_response(
&self,
request_id: Option<&str>,
code: i32,
message: &str,
data: Option<Value>,
) -> McpMessage
pub fn create_error_response( &self, request_id: Option<&str>, code: i32, message: &str, data: Option<Value>, ) -> McpMessage
Create error response message
Sourcepub fn parse_message(&self, json: &str) -> Result<McpMessage>
pub fn parse_message(&self, json: &str) -> Result<McpMessage>
Parse MCP message from JSON
Sourcepub fn serialize_message(&self, message: &McpMessage) -> Result<String>
pub fn serialize_message(&self, message: &McpMessage) -> Result<String>
Serialize MCP message to JSON
Sourcepub fn validate_version(&self, message: &McpMessage) -> Result<()>
pub fn validate_version(&self, message: &McpMessage) -> Result<()>
Validate message protocol version
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for McpProtocol
impl RefUnwindSafe for McpProtocol
impl Send for McpProtocol
impl Sync for McpProtocol
impl Unpin for McpProtocol
impl UnwindSafe for McpProtocol
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more