pub struct MockClient { /* private fields */ }Expand description
A mock MCP client for testing servers.
The mock client tracks all interactions and provides utilities for verifying server behavior.
Implementations§
Source§impl MockClient
impl MockClient
Sourcepub fn with_info(
self,
name: impl Into<String>,
version: impl Into<String>,
) -> Self
pub fn with_info( self, name: impl Into<String>, version: impl Into<String>, ) -> Self
Create a mock client with custom info.
Sourcepub fn with_capabilities(self, capabilities: ClientCapabilities) -> Self
pub fn with_capabilities(self, capabilities: ClientCapabilities) -> Self
Create a mock client with custom capabilities.
Sourcepub fn info(&self) -> &ClientInfo
pub fn info(&self) -> &ClientInfo
Get the client info.
Sourcepub fn capabilities(&self) -> &ClientCapabilities
pub fn capabilities(&self) -> &ClientCapabilities
Get the client capabilities.
Sourcepub fn server_info(&self) -> Option<ServerInfo>
pub fn server_info(&self) -> Option<ServerInfo>
Get the server info (after initialization).
Sourcepub fn server_capabilities(&self) -> Option<ServerCapabilities>
pub fn server_capabilities(&self) -> Option<ServerCapabilities>
Get the server capabilities (after initialization).
Sourcepub fn create_initialize_request(&self) -> Request
pub fn create_initialize_request(&self) -> Request
Create an initialize request.
Sourcepub fn process_initialize_response(
&self,
response: &Response,
) -> Result<(), McpError>
pub fn process_initialize_response( &self, response: &Response, ) -> Result<(), McpError>
Process an initialize response.
Sourcepub fn create_initialized_notification(&self) -> Notification
pub fn create_initialized_notification(&self) -> Notification
Create an initialized notification.
Sourcepub fn create_list_tools_request(&self) -> Request
pub fn create_list_tools_request(&self) -> Request
Create a tools/list request.
Sourcepub fn create_call_tool_request(&self, name: &str, arguments: Value) -> Request
pub fn create_call_tool_request(&self, name: &str, arguments: Value) -> Request
Create a tools/call request.
Sourcepub fn create_list_resources_request(&self) -> Request
pub fn create_list_resources_request(&self) -> Request
Create a resources/list request.
Sourcepub fn create_read_resource_request(&self, uri: &str) -> Request
pub fn create_read_resource_request(&self, uri: &str) -> Request
Create a resources/read request.
Sourcepub fn create_list_prompts_request(&self) -> Request
pub fn create_list_prompts_request(&self) -> Request
Create a prompts/list request.
Sourcepub fn create_get_prompt_request(
&self,
name: &str,
arguments: Option<Map<String, Value>>,
) -> Request
pub fn create_get_prompt_request( &self, name: &str, arguments: Option<Map<String, Value>>, ) -> Request
Create a prompts/get request.
Sourcepub fn create_ping_request(&self) -> Request
pub fn create_ping_request(&self) -> Request
Create a ping request.
Sourcepub fn record_request(&self, request: Request)
pub fn record_request(&self, request: Request)
Record a request.
Sourcepub fn record_response(&self, response: Response)
pub fn record_response(&self, response: Response)
Record a response.
Sourcepub fn record_notification_sent(&self, notification: Notification)
pub fn record_notification_sent(&self, notification: Notification)
Record a sent notification.
Sourcepub fn record_notification_received(&self, notification: Notification)
pub fn record_notification_received(&self, notification: Notification)
Record a received notification.
Sourcepub fn notifications_sent(&self) -> Vec<Notification>
pub fn notifications_sent(&self) -> Vec<Notification>
Get all sent notifications.
Sourcepub fn notifications_received(&self) -> Vec<Notification>
pub fn notifications_received(&self) -> Vec<Notification>
Get all received notifications.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get pending request count.
Sourcepub fn request_count(&self) -> usize
pub fn request_count(&self) -> usize
Get the total request count.
Sourcepub fn response_count(&self) -> usize
pub fn response_count(&self) -> usize
Get the total response count.
Sourcepub fn parse_tool_list(
&self,
response: &Response,
) -> Result<Vec<Tool>, McpError>
pub fn parse_tool_list( &self, response: &Response, ) -> Result<Vec<Tool>, McpError>
Parse a tool list response.
Sourcepub fn parse_tool_call(
&self,
response: &Response,
) -> Result<CallToolResult, McpError>
pub fn parse_tool_call( &self, response: &Response, ) -> Result<CallToolResult, McpError>
Parse a tool call response.
Sourcepub fn parse_resource_list(
&self,
response: &Response,
) -> Result<Vec<Resource>, McpError>
pub fn parse_resource_list( &self, response: &Response, ) -> Result<Vec<Resource>, McpError>
Parse a resource list response.
Sourcepub fn parse_resource_read(
&self,
response: &Response,
) -> Result<Vec<ResourceContents>, McpError>
pub fn parse_resource_read( &self, response: &Response, ) -> Result<Vec<ResourceContents>, McpError>
Parse a resource read response.
Sourcepub fn parse_prompt_list(
&self,
response: &Response,
) -> Result<Vec<Prompt>, McpError>
pub fn parse_prompt_list( &self, response: &Response, ) -> Result<Vec<Prompt>, McpError>
Parse a prompt list response.
Sourcepub fn parse_prompt_get(
&self,
response: &Response,
) -> Result<GetPromptResult, McpError>
pub fn parse_prompt_get( &self, response: &Response, ) -> Result<GetPromptResult, McpError>
Parse a prompt get response.
Trait Implementations§
Source§impl Clone for MockClient
impl Clone for MockClient
Source§impl Debug for MockClient
impl Debug for MockClient
Auto Trait Implementations§
impl !Freeze for MockClient
impl RefUnwindSafe for MockClient
impl Send for MockClient
impl Sync for MockClient
impl Unpin for MockClient
impl UnwindSafe for MockClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more