pub struct ServerRuntime { /* private fields */ }
Expand description
Struct representing the runtime core of the MCP server, handling transport and client details
Trait Implementations§
Source§impl McpServer for ServerRuntime
impl McpServer for ServerRuntime
Source§fn set_client_details(
&self,
client_details: InitializeRequestParams,
) -> SdkResult<()>
fn set_client_details( &self, client_details: InitializeRequestParams, ) -> SdkResult<()>
Set the client details, storing them in client_details
Source§fn server_info(&self) -> &InitializeResult
fn server_info(&self) -> &InitializeResult
Returns the server’s details, including server capability, instructions, protocol_version , server_info and optional meta data
Source§fn client_info(&self) -> Option<InitializeRequestParams>
fn client_info(&self) -> Option<InitializeRequestParams>
Returns the client information if available, after successful initialization , otherwise returns None
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Main runtime loop, processes incoming messages and handles requests
fn sender<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = &RwLock<Option<MessageDispatcher<ClientMessage>>>> + Send + 'async_trait>>where
MessageDispatcher<ClientMessage>: McpDispatch<ClientMessage, MessageFromServer>,
Self: 'async_trait,
'life0: 'async_trait,
Source§fn stderr_message<'life0, 'async_trait>(
&'life0 self,
message: String,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stderr_message<'life0, 'async_trait>(
&'life0 self,
message: String,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a message to the standard error output (stderr) asynchronously.
Source§fn get_client_info(&self) -> Option<InitializeRequestParams>
fn get_client_info(&self) -> Option<InitializeRequestParams>
👎Deprecated since 0.2.0: Use
client_info()
instead.Source§fn get_server_info(&self) -> &InitializeResult
fn get_server_info(&self) -> &InitializeResult
👎Deprecated since 0.2.0: Use
server_info()
instead.Source§fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
Checks whether the server has been initialized with client
Source§fn client_version(&self) -> Option<Implementation>
fn client_version(&self) -> Option<Implementation>
Returns the client’s name and version information once initialization is complete.
This method retrieves the client details, if available, after successful initialization.
Source§fn capabilities(&self) -> &ServerCapabilities
fn capabilities(&self) -> &ServerCapabilities
Returns the server’s capabilities.
Source§fn request<'life0, 'async_trait>(
&'life0 self,
request: RequestFromServer,
timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = SdkResult<ResultFromClient>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request<'life0, 'async_trait>(
&'life0 self,
request: RequestFromServer,
timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = SdkResult<ResultFromClient>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a request to the client and processes the response. Read more
Source§fn send_notification<'life0, 'async_trait>(
&'life0 self,
notification: NotificationFromServer,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_notification<'life0, 'async_trait>(
&'life0 self,
notification: NotificationFromServer,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a notification. This is a one-way message that is not expected
to return any response. The method asynchronously sends the notification using
the transport layer and does not wait for any acknowledgement or result.
Source§fn list_roots<'life0, 'async_trait>(
&'life0 self,
params: Option<ListRootsRequestParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<ListRootsResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_roots<'life0, 'async_trait>(
&'life0 self,
params: Option<ListRootsRequestParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<ListRootsResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Request a list of root URIs from the client. Roots allow
servers to ask for specific directories or files to operate on. A common example
for roots is providing a set of repositories or directories a server should operate on.
This request is typically used when the server needs to understand the file system
structure or access specific locations that the client has permission to read from
Source§fn send_logging_message<'life0, 'async_trait>(
&'life0 self,
params: LoggingMessageNotificationParams,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_logging_message<'life0, 'async_trait>(
&'life0 self,
params: LoggingMessageNotificationParams,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send log message notification from server to client.
If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
Source§fn send_prompt_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<PromptListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_prompt_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<PromptListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
An optional notification from the server to the client, informing it that
the list of prompts it offers has changed.
This may be issued by servers without any previous subscription from the client.
Source§fn send_resource_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<ResourceListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_resource_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<ResourceListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
An optional notification from the server to the client,
informing it that the list of resources it can read from has changed.
This may be issued by servers without any previous subscription from the client.
Source§fn send_resource_updated<'life0, 'async_trait>(
&'life0 self,
params: ResourceUpdatedNotificationParams,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_resource_updated<'life0, 'async_trait>(
&'life0 self,
params: ResourceUpdatedNotificationParams,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A notification from the server to the client, informing it that
a resource has changed and may need to be read again.
This should only be sent if the client previously sent a resources/subscribe request.
Source§fn send_tool_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<ToolListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_tool_list_changed<'life0, 'async_trait>(
&'life0 self,
params: Option<ToolListChangedNotificationParams>,
) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
An optional notification from the server to the client, informing it that
the list of tools it offers has changed.
This may be issued by servers without any previous subscription from the client.
Source§fn ping<'life0, 'async_trait>(
&'life0 self,
timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = SdkResult<Result>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ping<'life0, 'async_trait>(
&'life0 self,
timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = SdkResult<Result>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A ping request to check that the other party is still alive.
The receiver must promptly respond, or else may be disconnected. Read more
Source§fn create_message<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
) -> Pin<Box<dyn Future<Output = SdkResult<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_message<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
) -> Pin<Box<dyn Future<Output = SdkResult<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A request from the server to sample an LLM via the client.
The client has full discretion over which model to select.
The client should also inform the user before beginning sampling,
to allow them to inspect the request (human in the loop)
and decide whether to approve it.
Source§fn client_supports_sampling(&self) -> Option<bool>
fn client_supports_sampling(&self) -> Option<bool>
Checks if the client supports sampling. Read more
Source§fn client_supports_root_list(&self) -> Option<bool>
fn client_supports_root_list(&self) -> Option<bool>
Checks if the client supports listing roots. Read more
Source§fn client_supports_experimental(&self) -> Option<bool>
fn client_supports_experimental(&self) -> Option<bool>
Checks if the client has experimental capabilities available. Read more
Source§fn assert_client_capabilities(
&self,
request_method: &String,
) -> Result<(), RpcError>
fn assert_client_capabilities( &self, request_method: &String, ) -> Result<(), RpcError>
Asserts that client capabilities are available for a given server request. Read more
fn assert_server_notification_capabilities( &self, notification_method: &String, ) -> Result<(), RpcError>
fn assert_server_request_capabilities( &self, request_method: &String, ) -> Result<(), RpcError>
Auto Trait Implementations§
impl !Freeze for ServerRuntime
impl !RefUnwindSafe for ServerRuntime
impl Send for ServerRuntime
impl Sync for ServerRuntime
impl Unpin for ServerRuntime
impl !UnwindSafe for ServerRuntime
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