pub struct ThingsMcpServer {
pub db: Arc<ThingsDatabase>,
/* private fields */
}Expand description
MCP server for Things 3 integration
Fields§
§db: Arc<ThingsDatabase>Implementations§
Source§impl ThingsMcpServer
impl ThingsMcpServer
pub fn new(db: Arc<ThingsDatabase>, config: ThingsConfig) -> Self
Sourcepub fn with_middleware_config(
db: ThingsDatabase,
config: ThingsConfig,
middleware_config: MiddlewareConfig,
) -> Self
pub fn with_middleware_config( db: ThingsDatabase, config: ThingsConfig, middleware_config: MiddlewareConfig, ) -> Self
Create a new MCP server with custom middleware configuration
Sourcepub fn new_with_mcp_config(
db: Arc<ThingsDatabase>,
config: ThingsConfig,
mcp_config: McpServerConfig,
) -> Self
pub fn new_with_mcp_config( db: Arc<ThingsDatabase>, config: ThingsConfig, mcp_config: McpServerConfig, ) -> Self
Create a new MCP server with comprehensive configuration
Sourcepub fn middleware_chain(&self) -> &MiddlewareChain
pub fn middleware_chain(&self) -> &MiddlewareChain
Get the middleware chain for inspection or modification
Sourcepub fn list_tools(&self) -> McpResult<ListToolsResult>
pub fn list_tools(&self) -> McpResult<ListToolsResult>
Sourcepub async fn call_tool(
&self,
request: CallToolRequest,
) -> McpResult<CallToolResult>
pub async fn call_tool( &self, request: CallToolRequest, ) -> McpResult<CallToolResult>
Sourcepub async fn call_tool_with_fallback(
&self,
request: CallToolRequest,
) -> CallToolResult
pub async fn call_tool_with_fallback( &self, request: CallToolRequest, ) -> CallToolResult
Call a specific MCP tool with fallback error handling
This method provides backward compatibility by converting McpError to CallToolResult
for cases where the caller expects a CallToolResult even on error
Sourcepub fn list_resources(&self) -> McpResult<ListResourcesResult>
pub fn list_resources(&self) -> McpResult<ListResourcesResult>
Sourcepub async fn read_resource(
&self,
request: ReadResourceRequest,
) -> McpResult<ReadResourceResult>
pub async fn read_resource( &self, request: ReadResourceRequest, ) -> McpResult<ReadResourceResult>
Read a specific MCP resource
§Errors
Returns an error if resource reading fails or resource is not found
Sourcepub async fn read_resource_with_fallback(
&self,
request: ReadResourceRequest,
) -> ReadResourceResult
pub async fn read_resource_with_fallback( &self, request: ReadResourceRequest, ) -> ReadResourceResult
Read a specific MCP resource with fallback error handling
This method provides backward compatibility by converting McpError to ReadResourceResult
for cases where the caller expects a ReadResourceResult even on error
Sourcepub fn list_prompts(&self) -> McpResult<ListPromptsResult>
pub fn list_prompts(&self) -> McpResult<ListPromptsResult>
Sourcepub async fn get_prompt(
&self,
request: GetPromptRequest,
) -> McpResult<GetPromptResult>
pub async fn get_prompt( &self, request: GetPromptRequest, ) -> McpResult<GetPromptResult>
Get a specific MCP prompt with arguments
§Errors
Returns an error if prompt retrieval fails or prompt is not found
Sourcepub async fn get_prompt_with_fallback(
&self,
request: GetPromptRequest,
) -> GetPromptResult
pub async fn get_prompt_with_fallback( &self, request: GetPromptRequest, ) -> GetPromptResult
Get a specific MCP prompt with fallback error handling
This method provides backward compatibility by converting McpError to GetPromptResult
for cases where the caller expects a GetPromptResult even on error
Sourcepub async fn handle_jsonrpc_request(
&self,
request: Value,
) -> Result<Option<Value>>
pub async fn handle_jsonrpc_request( &self, request: Value, ) -> Result<Option<Value>>
Handle a JSON-RPC request and return a JSON-RPC response
Returns None for notifications (messages without id field) - these don’t require a response
§Errors
Returns an error if request parsing or handling fails
Auto Trait Implementations§
impl Freeze for ThingsMcpServer
impl !RefUnwindSafe for ThingsMcpServer
impl Send for ThingsMcpServer
impl Sync for ThingsMcpServer
impl Unpin for ThingsMcpServer
impl !UnwindSafe for ThingsMcpServer
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