pub struct McpTestHarness { /* private fields */ }Expand description
Test harness for MCP server operations
Implementations§
Source§impl McpTestHarness
impl McpTestHarness
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new test harness with a fresh database
§Panics
Panics if the database cannot be creationDate or the server cannot be initialized
Sourcepub fn new_with_config(middleware_config: MiddlewareConfig) -> Self
pub fn new_with_config(middleware_config: MiddlewareConfig) -> Self
Create a new test harness with a fresh database and custom middleware config
§Panics
Panics if the database cannot be creationDate or the server cannot be initialized
Sourcepub fn with_middleware_config(middleware_config: MiddlewareConfig) -> Self
pub fn with_middleware_config(middleware_config: MiddlewareConfig) -> Self
Create a test harness with custom middleware configuration
§Panics
Panics if the database cannot be creationDate or the server cannot be initialized
Sourcepub fn server(&self) -> &ThingsMcpServer
pub fn server(&self) -> &ThingsMcpServer
Get a reference to the MCP server
Sourcepub async fn call_tool_with_fallback(
&self,
name: &str,
arguments: Option<Value>,
) -> CallToolResult
pub async fn call_tool_with_fallback( &self, name: &str, arguments: Option<Value>, ) -> CallToolResult
Call a tool with fallback error handling
Sourcepub async fn read_resource(&self, uri: &str) -> ReadResourceResult
pub async fn read_resource(&self, uri: &str) -> ReadResourceResult
Sourcepub async fn read_resource_result(
&self,
uri: &str,
) -> Result<ReadResourceResult, McpError>
pub async fn read_resource_result( &self, uri: &str, ) -> Result<ReadResourceResult, McpError>
Read a resource and return the result or error
§Errors
Returns an error if the resource cannot be read or if the MCP server is not available.
Sourcepub async fn read_resource_with_fallback(&self, uri: &str) -> ReadResourceResult
pub async fn read_resource_with_fallback(&self, uri: &str) -> ReadResourceResult
Read a resource with fallback error handling
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: Option<Value>,
) -> GetPromptResult
pub async fn get_prompt( &self, name: &str, arguments: Option<Value>, ) -> GetPromptResult
Sourcepub async fn get_prompt_result(
&self,
name: &str,
arguments: Option<Value>,
) -> Result<GetPromptResult, McpError>
pub async fn get_prompt_result( &self, name: &str, arguments: Option<Value>, ) -> Result<GetPromptResult, McpError>
Get a prompt and return the result or error
§Errors
Returns an error if the prompt cannot be retrieved or if the MCP server is not available.
Sourcepub async fn get_prompt_with_fallback(
&self,
name: &str,
arguments: Option<Value>,
) -> GetPromptResult
pub async fn get_prompt_with_fallback( &self, name: &str, arguments: Option<Value>, ) -> GetPromptResult
Get a prompt with fallback error handling
Sourcepub async fn assert_tool_succeeds(
&self,
name: &str,
arguments: Option<Value>,
) -> CallToolResult
pub async fn assert_tool_succeeds( &self, name: &str, arguments: Option<Value>, ) -> CallToolResult
Sourcepub async fn assert_tool_fails_with<F>(
&self,
name: &str,
arguments: Option<Value>,
_expected_error: F,
)
pub async fn assert_tool_fails_with<F>( &self, name: &str, arguments: Option<Value>, _expected_error: F, )
Assert that a tool call fails with expected error
§Panics
Panics if the tool call succeeds when it should fail
Sourcepub async fn assert_resource_succeeds(&self, uri: &str) -> ReadResourceResult
pub async fn assert_resource_succeeds(&self, uri: &str) -> ReadResourceResult
Sourcepub async fn assert_resource_fails_with<F>(&self, uri: &str, expected_error: F)
pub async fn assert_resource_fails_with<F>(&self, uri: &str, expected_error: F)
Assert that a resource read fails with expected error
§Panics
Panics if the resource read succeeds when it should fail
Sourcepub async fn assert_prompt_succeeds(
&self,
name: &str,
arguments: Option<Value>,
) -> GetPromptResult
pub async fn assert_prompt_succeeds( &self, name: &str, arguments: Option<Value>, ) -> GetPromptResult
Sourcepub async fn assert_prompt_fails_with<F>(
&self,
name: &str,
arguments: Option<Value>,
expected_error: F,
)
pub async fn assert_prompt_fails_with<F>( &self, name: &str, arguments: Option<Value>, expected_error: F, )
Assert that a prompt fails with expected error
§Panics
Panics if the prompt request succeeds when it should fail
Sourcepub async fn assert_tool_returns_json(
&self,
name: &str,
arguments: Option<Value>,
) -> Value
pub async fn assert_tool_returns_json( &self, name: &str, arguments: Option<Value>, ) -> Value
Assert that a tool call returns valid JSON
§Panics
Panics if the tool call fails or returns invalid JSON
Sourcepub async fn assert_resource_returns_json(&self, uri: &str) -> Value
pub async fn assert_resource_returns_json(&self, uri: &str) -> Value
Assert that a resource read returns valid JSON
§Panics
Panics if the resource read fails or returns invalid JSON
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpTestHarness
impl !RefUnwindSafe for McpTestHarness
impl Send for McpTestHarness
impl Sync for McpTestHarness
impl Unpin for McpTestHarness
impl !UnwindSafe for McpTestHarness
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> 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>
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>
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