### Start Client Runtime Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search= Initiates the client runtime, potentially performing setup or connection establishment. This method consumes the client instance. ```rust fn start<'async_trait>(self: Arc) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, ``` -------------------------------- ### Get Instructions Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html Retrieves any specific instructions or configuration strings provided by the server. This can be used for custom client behavior or setup. ```rust pub fn instructions(&self) -> Option ``` -------------------------------- ### Print Example Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpClient.html A simple example demonstrating the use of the println! macro. ```rust println!("{}",1); ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search=u32+-%3E+bool Starts the client runtime. ```APIDOC ## fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, ### Description Starts the client runtime. This method consumes `Arc`. ### Returns - `Pin> + Send + 'async_trait>>`: A future that resolves to a `SdkResult` indicating success or failure. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the McpServer asynchronously. This is a required method for server initialization. ```APIDOC ## start ### Description Starts the McpServer asynchronously. This is a required method for server initialization. ### Method `async fn start` ### Parameters None ### Returns `Pin> + Send + 'async_trait>>` - A future that resolves when the server has started. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.ClientSseTransport.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the transport, initializing SSE and POST tasks, and setting up communication streams. ```APIDOC ## fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> where 'life0: 'async_trait, MessageDispatcher: McpDispatch, ClientSseTransport: 'async_trait, Starts the transport, initializing SSE and POST tasks Sets up the SSE stream, POST request handler, and message streams for communication. ##### §Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` * The message stream, dispatcher, and error stream ``` -------------------------------- ### Example Search Queries for Rust MCP SDK Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/enum.ContentBlock.html?search= Demonstrates example search queries that can be used within the context of the Rust MCP SDK. These examples illustrate common search patterns. ```rust * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.ClientSseTransport.html?search= Starts the transport, initializing SSE and POST tasks, and setting up message streams. ```APIDOC ## fn start ### Description Starts the transport, initializing SSE and POST tasks. Sets up the SSE stream, POST request handler, and message streams for communication. ### Signature ```rust fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> where 'life0: 'async_trait, MessageDispatcher: McpDispatch, ClientSseTransport: 'async_trait, ``` ### Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` * The message stream, dispatcher, and error stream ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpServer.html Starts the server. This is an asynchronous operation that returns a future. ```APIDOC ## start ### Description Starts the server. This is an asynchronous operation that returns a future. ### Method `start` ### Parameters - `self`: An `Arc` representing the server instance. ### Returns A `Pin> + Send + 'async_trait>>>` which resolves when the server has started. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search=std%3A%3Avec Starts the client runtime. This method consumes the client runtime. ```APIDOC ## fn start ### Description Starts the client runtime. This method consumes the client runtime. ### Signature `fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>>` ``` -------------------------------- ### Example Searches Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/auth/fn.create_protected_resource_metadata_url.html?search= These are example search queries that can be used with the documentation or related tools. They demonstrate various search patterns. ```text std::vec ``` ```text u32 -> bool ``` ```text Option, (T -> U) -> Option ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.SseTransport.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the transport, initializing streams and the message dispatcher. ```APIDOC ## fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> ### Description Starts the transport, initializing streams and message dispatcher. Sets up the MCP stream and dispatcher using the provided duplex streams. ### Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` - The message stream, dispatcher, and error stream. ### Errors * Returns `TransportError` if streams are already taken or not initialized. ``` -------------------------------- ### Example Searches for u32 -> bool Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.CancelledNotificationParams.html?search= Demonstrates example search queries for type conversions and function signatures. ```rust u32 -> bool ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the client runtime. This is an asynchronous operation that returns an SdkResult. ```APIDOC ## fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, ### Description Starts the client runtime. ### Returns A `Pin>>>` which resolves to an `SdkResult` indicating success or failure. ``` -------------------------------- ### ClientRoots Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/struct.ClientRoots.html?search= Examples of how to perform searches related to ClientRoots. ```APIDOC ## Search Examples ### Example 1: Searching for a specific type ```rust // Example: Search for std::vec let results = client_roots.search("std::vec"); ``` ### Example 2: Searching for type conversions ```rust // Example: Search for u32 to bool conversion let results = client_roots.search("u32 -> bool"); ``` ### Example 3: Searching for generic type conversions ```rust // Example: Search for Option, (T -> U) -> Option let results = client_roots.search("Option, (T -> U) -> Option"); ``` ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.ClientSseTransport.html?search=u32+-%3E+bool Starts the transport, initializing SSE and POST tasks. Sets up the SSE stream, POST request handler, and message streams for communication. ```APIDOC ## fn start ### Description Starts the transport, initializing SSE and POST tasks. Sets up the SSE stream, POST request handler, and message streams for communication. ### Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` - A tuple containing the message stream, dispatcher, and error stream. ``` -------------------------------- ### Build McpAuthConfig with Server URL and Scope Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/client.rs.html Demonstrates how to construct an McpAuthConfig using the builder pattern, specifying the server URL and desired OAuth scopes. This is a common starting point for client authentication setup. ```rust use rust_mcp_sdk::auth::McpAuthConfig; let client = McpAuthConfig::builder() .server_url("https://mcp.example.com/mcp") .scope("mcp tools") .build() .unwrap(); ``` -------------------------------- ### Start Task Polling in Rust MCP SDK Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/task_store/in_memory_task_store.rs.html?search=std%3A%3Avec Demonstrates how to start polling for a task using the in-memory task store. This snippet shows the setup, task creation, and the initiation of polling, followed by a delay and an assertion to verify the task was polled. ```rust .await; store.start_task_polling(callback).unwrap(); tokio::time::sleep(Duration::from_millis(250)).await; assert_eq!(*polled_task_id.lock().await, task.task_id); } } ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpServer.html?search= Starts the MCP server. This is an asynchronous operation that returns a future. ```APIDOC ## fn start ### Description Starts the MCP server asynchronously. ### Method `start` ### Parameters None ### Returns A `Pin> + Send + 'async_trait>>>` representing the asynchronous start operation. ``` -------------------------------- ### Example Search Queries Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.EmptyResult.html?search= Demonstrates common search query patterns. These examples show how to search for specific types, type conversions, and generic type transformations. ```rust * std::vec ``` ```rust * u32 -> bool ``` ```rust * Option, (T -> U) -> Option ``` -------------------------------- ### Example Searches for std::vec Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.CancelledNotificationParams.html?search= Demonstrates example search queries for common Rust types and patterns. ```rust std::vec ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/enum.ClientMessage.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the transport, initializing streams and message dispatcher. Sets up the MCP stream and dispatcher using the provided duplex streams. ```APIDOC ## start ### Description Starts the transport, initializing streams and message dispatcher. Sets up the MCP stream and dispatcher using the provided duplex streams. ### Method `start` ### Parameters None ### Returns - `Result<(Pin + Send>>, MessageDispatcher, IoStream), TransportError>` - The message stream, dispatcher, and error stream. ### Errors - Returns `TransportError` if streams are already taken or not initialized. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpClient.html Starts the MCP client. This is an asynchronous operation that returns a future. ```APIDOC ## start ### Description Starts the MCP client. This is an asynchronous operation that returns a future. ### Method `start` ### Parameters None ### Returns A future that resolves to `SdkResult<()>`. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.StdioTransport.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the transport, initializing streams and the message dispatcher. It can either launch an MCP server if configured with a command, or use the current process's stdio for server-side communication. ```APIDOC ## start ### Description Starts the transport, initializing streams and the message dispatcher. If configured with a command (MCP Client), launches the MCP server and connects its stdio streams. Otherwise, uses the current process’s stdio for server-side communication. ### Method `async fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>>` ### Returns A `TransportResult` containing: * A pinned stream of incoming messages. * A `MessageDispatcher` for sending messages. * An `IoStream` for stderr (readable) or stdout (writable) depending on the mode. ### Errors Returns a `TransportError` if the subprocess fails to spawn or stdio streams cannot be accessed. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html Starts the client runtime. This method is asynchronous and returns a future that resolves to an SdkResult<()>. It takes ownership of the client runtime. ```APIDOC ## fn start ### Description Starts the client runtime. This method is asynchronous and returns a future that resolves to an SdkResult<()>. It takes ownership of the client runtime. ### Signature `fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>>` ### Parameters * `self` (Arc) - An `Arc` reference to the `ClientRuntime` instance. ### Returns A `Pin> + Send + 'async_trait>>` which resolves to an `SdkResult<()>` indicating success or failure. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/server_runtime.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the main runtime loop, processing incoming messages from the client and handling requests. This method should be called to begin the server's operation. ```APIDOC ## start ### Description Main runtime loop, processes incoming messages and handles requests. This function initiates the server's operational cycle. ### Method Signature ```rust async fn start(self: Arc) -> SdkResult<()> ``` ### Returns * `SdkResult<()>`: A result indicating success or failure of the runtime start operation. ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.StdioTransport.html?search= Starts the transport, initializing streams and the message dispatcher. It can launch an MCP server or use the current process's stdio. ```APIDOC ## fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> ### Description Starts the transport, initializing streams and the message dispatcher. If configured with a command (MCP Client), launches the MCP server and connects its stdio streams. Otherwise, uses the current process’s stdio for server-side communication. ### Returns A `TransportResult` containing: * A pinned stream of incoming messages. * A `MessageDispatcher` for sending messages. * An `IoStream` for stderr (readable) or stdout (writable) depending on the mode. ### Errors Returns a `TransportError` if the subprocess fails to spawn or stdio streams cannot be accessed. ``` -------------------------------- ### Example Searches for Option, (T -> U) -> Option Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.CancelledNotificationParams.html?search= Demonstrates example search queries for generic type transformations involving Option. ```rust Option, (T -> U) -> Option ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.ClientSseTransport.html Starts the transport, initializing SSE and POST tasks. This method is part of the Transport trait implementation for ClientSseTransport. ```APIDOC ## fn start ### Description Starts the transport, initializing SSE and POST tasks. Sets up the SSE stream, POST request handler, and message streams for communication. ### Signature ```rust fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> where 'life0: 'async_trait, MessageDispatcher: McpDispatch, ClientSseTransport: 'async_trait, ``` ### Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` * The message stream, dispatcher, and error stream. ``` -------------------------------- ### OauthMetadata Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/auth/struct.OauthMetadata.html?search= Examples demonstrating how to search for OAuth metadata using various patterns. ```APIDOC ## Search Examples ### Example 1: Searching for a specific type ```rust // Example: Search for std::vec let results = oauth_metadata.search("std::vec"); ``` ### Example 2: Searching for type conversions ```rust // Example: Search for u32 -> bool conversion let results = oauth_metadata.search("u32 -> bool"); ``` ### Example 3: Searching for generic type transformations ```rust // Example: Search for Option, (T -> U) -> Option let results = oauth_metadata.search("Option, (T -> U) -> Option"); ``` ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/server_runtime.rs.html?search=u32+-%3E+bool Starts the main runtime loop for the server. This loop continuously processes incoming messages from the client and handles requests by spawning tasks for each message. ```APIDOC ## start ### Description Initiates the primary runtime loop for the server. This asynchronous function is responsible for managing the lifecycle of the server's communication with clients. It sets up a stream for incoming messages and processes them concurrently by spawning new asynchronous tasks for each received message, ensuring efficient handling of multiple client interactions. ### Method `async fn start(self: Arc) -> SdkResult<()>` ### Parameters None ### Request Example ```rust let server_runtime_arc = Arc::new(server_runtime); match server_runtime_arc.start().await { Ok(_) => println!("Server runtime started successfully."), Err(e) => eprintln!("Error starting server runtime: {:?}", e), } ``` ### Response #### Success Response (200) - **()** - Indicates successful execution of the runtime loop. #### Error Response - **SdkResult<()>** - Returns an `SdkResult` which is `Ok(())` on success or an `RpcError` if any issue occurs during the startup or processing of the runtime loop. ``` -------------------------------- ### McpClient start Method Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpClient.html?search= Initiates the MCP client's operation. This method is asynchronous and returns a future that resolves when the client has started. ```rust fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, ``` -------------------------------- ### Get Server Instructions Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_traits/mcp_client.rs.html?search= Retrieves the server's instructions. Returns `None` if server information is not available. ```rust fn instructions(&self) -> Option { self.server_info()?.instructions } ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/enum.ClientMessages.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the SSE transport, initializing the message stream and dispatcher. This method sets up the necessary components for communication. ```APIDOC ## start ### Description Starts the transport, initializing streams and message dispatcher. Sets up the MCP stream and dispatcher using the provided duplex streams. ### Method `start` ### Parameters None ### Returns * `Result, TransportError>` - A `ReceiverStream` for incoming client messages or a `TransportError` if streams are already taken or not initialized. ``` -------------------------------- ### mcp_icon! Macro Syntax and Example Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_macros/mcp_icon.rs.html?search=u32+-%3E+bool Demonstrates the syntax for the mcp_icon macro, including mandatory and optional parameters, and provides a complete usage example. ```rust macro_rules! mcp_icon { ( src = $src:expr $(, mime_type = $mime_type:expr )? $(, sizes = [$($size:expr),* $(,)?] )? $(, theme = $theme:expr )? $(,)? ) => { $crate::schema::Icon { src: $src.into(), mime_type: None $(.or(Some($mime_type.into())))?, sizes: vec![$($($size.into()),*)?], theme: None $(.or(Some($theme.into())))?, } }; } ``` ```rust let my_icon: rust_mcp_sdk::schema::Icon = rust_mcp_sdk::mcp_icon!( src = "/icons/dark.png", mime_type = "image/png", sizes = ["128x128", "256x256"], theme = "dark" ); ``` -------------------------------- ### mcp_icon! Macro Syntax and Example Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_macros/mcp_icon.rs.html Demonstrates the syntax for the mcp_icon macro, including mandatory and optional parameters, and provides a full example of its usage to create an Icon instance. ```text mcp_icon!( src = "path_or_url", mime_type = "optional_mime_type", sizes = ["WxH", "WxH", ...], theme = "dark" | "light", ) ``` ```rust let my_icon: rust_mcp_sdk::schema::Icon = rust_mcp_sdk::mcp_icon!( src = "/icons/dark.png", mime_type = "image/png", sizes = ["128x128", "256x256"], theme = "dark" ); ``` -------------------------------- ### Full Icon Creation Example Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_macros/mcp_icon.rs.html?search=std%3A%3Avec Demonstrates creating an Icon instance with all possible parameters: src, mime_type, sizes, and theme. Verifies that all fields are correctly populated. ```rust 110 #[test] 111 fn test_icon_full() { 112 let icon = mcp_icon!( 113 src = "/icons/full.png", 114 mime_type = "image/png", 115 sizes = ["16x16", "32x32", "64x64"], 116 theme = "dark" 117 ); 118 119 assert_eq!(icon.src, "/icons/full.png"); 120 assert_eq!(icon.mime_type.as_deref(), Some("image/png")); 121 assert_eq!(icon.sizes, vec!["16x16", "32x32", "64x64"]); 122 assert_eq!(theme_str(icon.theme), "dark"); 123 } ``` -------------------------------- ### Get Stream Position Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/task_store/type.TaskStatusPoller.html?search= Returns the current seek position from the start of the stream for a boxed Seek implementation. ```rust fn stream_position(&mut self) -> Result where S: Seek + ?Sized, ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.StdioTransport.html Starts the transport, initializing streams and the message dispatcher. It can launch an MCP server and connect stdio streams if configured as an MCP Client, or use the current process's stdio for server-side communication. ```APIDOC ## start ### Description Starts the transport, initializing streams and the message dispatcher. If configured with a command (MCP Client), launches the MCP server and connects its stdio streams. Otherwise, uses the current process’s stdio for server-side communication. ### Method `async fn start<'life0, 'async_trait>( &'life0 self ) -> Pin, TransportError>> + Send + 'async_trait>>` ### Returns A `TransportResult` containing: * A pinned stream of incoming messages. * A `MessageDispatcher` for sending messages. * An `IoStream` for stderr (readable) or stdout (writable) depending on the mode. ### Errors Returns a `TransportError` if the subprocess fails to spawn or stdio streams cannot be accessed. ``` -------------------------------- ### Get Current Stream Position for Box Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_http/type.RequestHandler.html?search= Retrieves the current position within a boxed seekable stream, measured in bytes from the start. ```rust fn stream_position(&mut self) -> Result ``` -------------------------------- ### Start Transport with ClientSseTransport Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.ClientSseTransport.html?search=std%3A%3Avec Starts the transport, initializing SSE and POST tasks. Sets up the SSE stream, POST request handler, and message streams for communication. Returns the message stream, dispatcher, and error stream. ```rust fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin, TransportError>> + Send + 'async_trait>> where 'life0: 'async_trait, MessageDispatcher: McpDispatch, ClientSseTransport: 'async_trait, ``` -------------------------------- ### Initialize Client Runtime and Start Task Polling Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/client_runtime.rs.html?search=u32+-%3E+bool Starts the client runtime, including subscribing to task status notifications and initiating server task polling if configured. ```rust async fn start(self: Arc) -> SdkResult<()> { let runtime = self.clone(); if let Some(task_store) = runtime.task_store() { // send TaskStatusNotification if task_store is present and supports subscribe() if let Some(mut stream) = task_store.subscribe() { tokio::spawn(async move { while let Some((params, _)) = stream.next().await { let _ = runtime.notify_task_status(params).await; } }); } } let runtime = self.clone(); // Task polling for client initiated tasks if let Some(server_task_store) = runtime.server_task_store.clone() { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime.clone(); let callback: TaskStatusPoller = Box::new(move |task_id, session_id| { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime_clone.clone(); Box::pin(async move { runtime_clone .poll_task_status(task_id, session_id, task_store_clone) .await }) }); if let Err(error) = task_store_clone.start_task_polling(callback) { tracing::error!("Failed to start task polling: {error}"); } } #[cfg(feature = "streamable-http")] { if self.transport_options.is_some() { self.initialize_request().await?; return Ok(()); } } self.start_standalone().await } ``` -------------------------------- ### Panicking `expect_err` Example Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/auth/type.ClientResult.html?search=std%3A%3Avec Use `expect_err()` to get the `Err` value. This method panics if the `Result` is an `Ok`, providing a custom panic message along with the `Ok` value. ```rust let x: Result = Ok(10); x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10` ``` -------------------------------- ### McpAuthClient Example Usage Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/client.rs.html Illustrates a typical workflow for using McpAuthClient. It shows how to initialize the client with configuration, authenticate, and retrieve authorization headers. ```rust use rust_mcp_sdk::auth::McpAuthConfig; # async fn example() -> Result<(), Box> { let client = McpAuthConfig::builder() .server_url("https://mcp.example.com/mcp") .client_id("my-client") .client_secret("my-secret") .scope("mcp") .build()?; client.authenticate().await?; let headers = client.get_auth_headers().await?; // -> {"Authorization": "Bearer "} # Ok(()) # } ``` -------------------------------- ### Get Server Information Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/client_runtime.rs.html?search=u32+-%3E+bool Returns an optional clone of the server's initialization details. ```rust fn server_info(&self) -> Option { self.server_details_rx.borrow().clone() } ``` -------------------------------- ### UrlElicitError Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.UrlElicitError.html?search= Examples of how to search for UrlElicitError. These examples demonstrate different query patterns. ```APIDOC ## UrlElicitError Search ### Description Provides examples of search queries for UrlElicitError. ### Example Searches * `std::vec` * `u32 -> bool` * `Option, (T -> U) -> Option` ``` -------------------------------- ### Get Client Information Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/client_runtime.rs.html?search=u32+-%3E+bool Returns a reference to the client's initialization parameters. ```rust fn client_info(&self) -> &InitializeRequestParams { &self.client_details } ``` -------------------------------- ### Example: Configured fallback scope Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/scope.rs.html?search= Illustrates using the client-configured fallback scope when neither WWW-Authenticate nor PRM scopes_supported are available. ```rust let s = select_scope(None, None, Some("fallback")); assert_eq!(s.as_deref(), Some("fallback")); ``` -------------------------------- ### ListToolsResult Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.ListToolsResult.html?search= Examples of how to perform searches on ListToolsResult. ```APIDOC ## Search Examples Example searches: * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` -------------------------------- ### Building an McpAuthClient with McpAuthConfig Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/auth/struct.McpAuthConfig.html Example of constructing an McpAuthClient using the McpAuthConfig builder pattern. It demonstrates setting the server URL and scope. ```rust use rust_mcp_sdk::auth::McpAuthConfig; let client = McpAuthConfig::builder() .server_url("https://mcp.example.com/mcp") .scope("mcp tools") .build() .unwrap(); ``` -------------------------------- ### ElicitCompleteParams Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.ElicitCompleteParams.html?search= Examples of how to perform searches related to ElicitCompleteParams. ```APIDOC ## Search Examples ### Example 1: Basic Search ``` std::vec ``` ### Example 2: Type Conversion Search ``` u32 -> bool ``` ### Example 3: Generic Type Conversion Search ``` Option, (T -> U) -> Option ``` ``` -------------------------------- ### Get Instructions Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search= Retrieves any specific instructions provided by the server. Returns an Option containing the instructions. ```rust fn instructions(&self) -> Option ``` -------------------------------- ### Start Task Polling and Create Tasks Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/task_store/in_memory_task_store.rs.html?search=std%3A%3Avec Initializes an InMemoryTaskStore, starts a task polling callback, and creates multiple tasks with different poll intervals. It then waits for a duration to observe polling behavior. ```rust let callback: TaskStatusPoller = Box::new(move |task_id, _session_id| { let order = order_clone.clone(); Box::pin(async move { order.lock().await.push(task_id.clone()); Ok((TaskStatus::Working, Some(200))) }) }); let store = InMemoryTaskStore::::new(None); store.start_task_polling(callback); let task_a = store .create_task( CreateTaskOptions { poll_interval: Some(300), ttl: Some(60_000), meta: None, }, 1.into(), dummy_request(), None, ) .await; let task_b = store .create_task( CreateTaskOptions { poll_interval: Some(500), ttl: Some(60_000), meta: None, }, 2.into(), dummy_request(), None, ) .await; let task_c = store .create_task( CreateTaskOptions { poll_interval: Some(800), ttl: Some(60_000), meta: None, }, 3.into(), dummy_request(), None, ) .await; // Let run for ~1.2 seconds tokio::time::sleep(Duration::from_millis(1200)).await; let order = poll_order.lock().await; let polls: std::collections::HashMap<_, usize> = order .iter() .fold(std::collections::HashMap::new(), |mut acc, id| { *acc.entry(id).or_insert(0) += 1; acc }); // task_a (300ms): should be polled ~4 times (300,600,900,1200) assert!(polls[&task_a.task_id] >= 3); // task_b (500ms): ~2-3 times assert!(polls[&task_b.task_id] >= 2); // task_c (800ms): ~1-2 times assert!(polls[&task_c.task_id] >= 1); ``` -------------------------------- ### Test: Builder with full configuration Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/client.rs.html Demonstrates building `McpAuthConfigBuilder` with all available configuration options, including server URL, client ID, client secret, scope, and redirect URI. ```rust #[test] fn builder_full_config() { let client = McpAuthConfigBuilder::default() .server_url("https://example.com/mcp") .client_id("pre-reg-id") .client_secret("pre-reg-secret") .scope("mcp") .redirect_uri("https://client.example.com/callback") .build() .unwrap(); assert_eq!(client.config.server_url, "https://example.com/mcp"); assert_eq!(client.config.client_id.as_deref(), Some("pre-reg-id")); assert_eq!( client.config.client_secret.as_deref(), Some("pre-reg-secret") ); assert_eq!(client.config.scope.as_deref(), Some("mcp")); } ``` -------------------------------- ### McpAuthClient Initialization and Authentication Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/auth/struct.McpAuthClient.html Demonstrates how to build and use McpAuthClient to authenticate and retrieve authorization headers. Requires McpAuthConfig to be configured with server URL, client ID, client secret, and scope. ```rust use rust_mcp_sdk::auth::McpAuthConfig; let client = McpAuthConfig::builder() .server_url("https://mcp.example.com/mcp") .client_id("my-client") .client_secret("my-secret") .scope("mcp") .build()?; client.authenticate().await?; let headers = client.get_auth_headers().await?; // -> {"Authorization": "Bearer "} ``` -------------------------------- ### Start Task Polling and Create Tasks Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/task_store/in_memory_task_store.rs.html Demonstrates starting task polling with a custom callback and creating multiple tasks with different poll intervals. It then waits for a duration and asserts the number of times each task was polled based on its interval. ```rust let poll_order = Arc::new(Mutex::new(Vec::new())); let order_clone = poll_order.clone(); let callback: TaskStatusPoller = Box::new(move |task_id, _session_id| { let order = order_clone.clone(); Box::pin(async move { order.lock().await.push(task_id.clone()); Ok((TaskStatus::Working, Some(200))) }) }); let store = InMemoryTaskStore::::new(None); store.start_task_polling(callback); let task_a = store .create_task( CreateTaskOptions { poll_interval: Some(300), ttl: Some(60_000), meta: None, }, 1.into(), dummy_request(), None, ) .await; let task_b = store .create_task( CreateTaskOptions { poll_interval: Some(500), ttl: Some(60_000), meta: None, }, 2.into(), dummy_request(), None, ) .await; let task_c = store .create_task( CreateTaskOptions { poll_interval: Some(800), ttl: Some(60_000), meta: None, }, 3.into(), dummy_request(), None, ) .await; // Let run for ~1.2 seconds tokio::time::sleep(Duration::from_millis(1200)).await; let order = poll_order.lock().await; let polls: std::collections::HashMap<_, usize> = order .iter() .fold(std::collections::HashMap::new(), |mut acc, id| { *acc.entry(id).or_insert(0) += 1; acc }); // task_a (300ms): should be polled ~4 times (300,600,900,1200) assert!(polls[&task_a.task_id] >= 3); // task_b (500ms): ~2-3 times assert!(polls[&task_b.task_id] >= 2); // task_c (800ms): ~1-2 times assert!(polls[&task_c.task_id] >= 1); } ``` -------------------------------- ### Example Usage with Axum Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_http/mount/struct.McpMountOptions.html?search=u32+-%3E+bool Demonstrates how to instantiate McpMountOptions for use with the Axum web framework. It sets specific endpoint paths and utilizes default values for other fields. ```rust let mount = McpMountOptions { streamable_http_endpoint: "/mcp".into(), sse_endpoint: "/sse".into(), sse_messages_endpoint: "/messages".into(), health_endpoint: Some("/health".into()), ..Default::default() }; ``` -------------------------------- ### Start Client Runtime Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html Initiates the client runtime, taking ownership of the `Arc`. This method is typically called once to start the client's main event loop or connection process. It returns a future that resolves when the startup is complete or an error occurs. ```rust pub async fn start(self: Arc) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, ``` -------------------------------- ### Icon Creation with Sizes Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_macros/mcp_icon.rs.html?search=std%3A%3Avec Illustrates creating an Icon instance with the 'sizes' parameter, providing a list of size strings. Verifies that the sizes are correctly stored and other optional fields are default. ```rust 79 #[test] 80 fn test_icon_with_sizes() { 81 let icon = mcp_icon!(src = "/icons/simple.png", sizes = ["32x32", "64x64"]); 82 assert_eq!(icon.src, "/icons/simple.png"); 83 assert!(icon.mime_type.is_none()); 84 assert_eq!(icon.sizes, vec!["32x32", "64x64"]); 85 assert!(icon.theme.is_none()); 86 } ``` -------------------------------- ### Start Client Runtime and Task Polling Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/client_runtime.rs.html?search=std%3A%3Avec Initializes the client runtime, setting up task status subscriptions and polling for server-initiated tasks. If streamable HTTP is enabled, it initializes the request; otherwise, it starts a standalone client. ```rust async fn start(self: Arc) -> SdkResult<()> { let runtime = self.clone(); if let Some(task_store) = runtime.task_store() { // send TaskStatusNotification if task_store is present and supports subscribe() if let Some(mut stream) = task_store.subscribe() { tokio::spawn(async move { while let Some((params, _)) = stream.next().await { let _ = runtime.notify_task_status(params).await; } }); } } let runtime = self.clone(); // Task polling for client initiated tasks if let Some(server_task_store) = runtime.server_task_store.clone() { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime.clone(); let callback: TaskStatusPoller = Box::new(move |task_id, session_id| { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime_clone.clone(); Box::pin(async move { runtime_clone .poll_task_status(task_id, session_id, task_store_clone) .await }) }); if let Err(error) = task_store_clone.start_task_polling(callback) { tracing::error!("Failed to start task polling: {error}"); } } #[cfg(feature = "streamable-http")] { if self.transport_options.is_some() { self.initialize_request().await?; return Ok(()); } } self.start_standalone().await } ``` -------------------------------- ### start Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpClient.html?search=u32+-%3E+bool Initiates the client's operation. This is an asynchronous method that returns a future. ```APIDOC ## start ### Description Initiates the client's operation. ### Method Signature `fn start<'async_trait>( self: Arc, ) -> Pin> + Send + 'async_trait>>` ### Type Parameters - `'async_trait`: Lifetime parameter for async operations. ``` -------------------------------- ### ModelHint Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/mcp_2025_11_25/struct.ModelHint.html?search= Examples of search queries that can be used with the ModelHint schema. ```APIDOC ## Search Examples This section provides examples of how to search within the ModelHint schema. ### Example Queries - `std::vec` - `u32 -> bool` - `Option, (T -> U) -> Option` ``` -------------------------------- ### Get Prompt Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/trait.McpClient.html Retrieves a prompt. This method is used to get prompt-related information. ```APIDOC ## get_prompt ### Description Retrieves a prompt. ### Method (Not specified, likely a client-side SDK method call) ### Endpoint (Not applicable for SDK methods) ### Parameters (No parameters specified in the source for this method) ### Request Example (Not applicable for SDK methods) ### Response (Response type not specified in the source for this method) ``` -------------------------------- ### Icon Creation with Light Theme Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_macros/mcp_icon.rs.html?search=std%3A%3Avec Demonstrates creating an Icon instance specifying the 'light' theme. Checks that the theme is correctly set and other optional fields are default. ```rust 88 #[test] 89 fn test_icon_with_theme_light() { 90 let icon = mcp_icon!(src = "/icons/simple.png", theme = "light"); 91 assert_eq!(icon.src, "/icons/simple.png"); 92 assert!(icon.mime_type.is_none()); 93 assert!(icon.sizes.is_empty()); 94 assert_eq!(theme_str(icon.theme), "light"); 95 } ``` -------------------------------- ### Search Examples Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/struct.ReadResourceRequest.html?search= Illustrative examples of how to perform searches, demonstrating common patterns and types. ```APIDOC ## Search results Example searches: * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` -------------------------------- ### instructions Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search=std%3A%3Avec Returns any instructions provided by the server. ```APIDOC ## fn instructions ### Description Returns any instructions provided by the server. ### Signature `fn instructions(&self) -> Option` ``` -------------------------------- ### Example: No scope available Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/scope.rs.html?search= Demonstrates the case where no scope information is available from any source, resulting in None. ```rust let s = select_scope(None, None, None); assert!(s.is_none()); ``` -------------------------------- ### Start Task Polling in Rust Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/task_store/in_memory_task_store.rs.html?search= Demonstrates how to start polling for a task using the in-memory task store. This involves creating a task, defining a callback, and initiating the polling process. Ensure the task ID is correctly passed and the callback handles the polled task ID. ```rust store.start_task_polling(callback).unwrap(); tokio::time::sleep(Duration::from_millis(250)).await; assert_eq!(*polled_task_id.lock().await, task.task_id); ``` -------------------------------- ### Example: PRM scopes_supported as fallback Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/scope.rs.html?search= Shows how scopes_supported from PRM are used when WWW-Authenticate scope is not provided. ```rust let s = select_scope(None, Some(&["a".into(), "b".into()]), Some("fallback")); assert_eq!(s.as_deref(), Some("a b")); ``` -------------------------------- ### Initialize Client Runtime and Start Task Polling Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/client_runtime.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes the client runtime, sets up task status subscription, and starts polling for server-initiated tasks if a server task store is available. It also handles streamable HTTP initialization if the feature is enabled. ```rust async fn start(self: Arc) -> SdkResult<()> { let runtime = self.clone(); if let Some(task_store) = runtime.task_store() { // send TaskStatusNotification if task_store is present and supports subscribe() if let Some(mut stream) = task_store.subscribe() { tokio::spawn(async move { while let Some((params, _)) = stream.next().await { let _ = runtime.notify_task_status(params).await; } }); } } let runtime = self.clone(); // Task polling for client initiated tasks if let Some(server_task_store) = runtime.server_task_store.clone() { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime.clone(); let callback: TaskStatusPoller = Box::new(move |task_id, session_id| { let task_store_clone = server_task_store.clone(); let runtime_clone = runtime_clone.clone(); Box::pin(async move { runtime_clone .poll_task_status(task_id, session_id, task_store_clone) .await }) }); if let Err(error) = task_store_clone.start_task_polling(callback) { tracing::error!("Failed to start task polling: {error}"); } } #[cfg(feature = "streamable-http")] { if self.transport_options.is_some() { self.initialize_request().await?; return Ok(()) } } self.start_standalone().await } ``` -------------------------------- ### SseTransport start method Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/schema/enum.ClientMessages.html?search= Starts the SSE transport, initializing streams and the message dispatcher. ```APIDOC ## fn start ### Description Starts the transport, initializing streams and message dispatcher Sets up the MCP stream and dispatcher using the provided duplex streams. ### Method `start` ### Returns * `TransportResult<(Pin + Send>>, MessageDispatcher, IoStream)>` * The message stream, dispatcher, and error stream ### Errors * Returns `TransportError` if streams are already taken or not initialized ``` -------------------------------- ### McpAuthClient Structure and Example Usage Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/auth/client_auth/client.rs.html Defines the McpAuthClient and provides an example of its basic usage for authentication. ```APIDOC ## McpAuthClient ### Description Client-side OAuth orchestrator for MCP. Handles metadata discovery, dynamic client registration, token exchange, and auto-refresh. ### Example ```no_run use rust_mcp_sdk::auth::McpAuthConfig; # async fn example() -> Result<(), Box> { let client = McpAuthConfig::builder() .server_url("https://mcp.example.com/mcp") .client_id("my-client") .client_secret("my-secret") .scope("mcp") .build()?; client.authenticate().await?; let headers = client.get_auth_headers().await?; // -> {"Authorization": "Bearer "} # Ok(()) # } ``` ``` -------------------------------- ### Create MCP Server Instance Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/server_runtime/mcp_server_runtime.rs.html?search=u32+-%3E+bool Creates a new instance of the `ServerRuntime` with detailed initialization parameters. This is a more granular way to set up the server, allowing for specific configurations like session ID, authentication info, and task stores. ```rust pub(crate) fn create_server_instance( server_details: Arc, handler: Arc, session_id: SessionId, auth_info: Option, task_store: Option>, client_task_store: Option>, message_observer: Option>>, ) -> Arc { ServerRuntime::new_instance( server_details, handler, session_id, auth_info, task_store, client_task_store, message_observer, ) } ``` -------------------------------- ### Get Type ID of Self Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/struct.RequestIdGenNumeric.html Gets the `TypeId` of the current instance. This is part of the `Any` trait implementation. ```rust fn type_id(&self) -> TypeId> ``` -------------------------------- ### instructions Source: https://docs.rs/rust-mcp-sdk/latest/rust_mcp_sdk/mcp_client/struct.ClientRuntime.html?search=u32+-%3E+bool Retrieves instructions from the server. ```APIDOC ## fn instructions(&self) -> Option ### Description Returns instructions from the server. ### Returns - `Option`: An optional string containing instructions. ``` -------------------------------- ### Rust: Get Client Information Source: https://docs.rs/rust-mcp-sdk/latest/src/rust_mcp_sdk/mcp_runtimes/server_runtime.rs.html Returns the client's initialization parameters if available after successful initialization, otherwise returns None. ```rust fn client_info(&self) -> Option { self.client_details_rx.borrow().clone() } ```