Skip to main content

ServerRuntime

Struct ServerRuntime 

Source
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

Source§

fn set_client_details<'life0, 'async_trait>( &'life0 self, client_details: InitializeRequestParams, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the client details, storing them in client_details

Source§

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>

Returns the client information if available, after successful initialization , otherwise returns None

Source§

fn start<'async_trait>( self: Arc<Self>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Main runtime loop, processes incoming messages and handles requests

Source§

fn task_store(&self) -> Option<Arc<ServerTaskStore>>

Returns the server-side task store, if available. Read more
Source§

fn client_task_store(&self) -> Option<Arc<ClientTaskStore>>

Returns the client-side task store, if available. Read more
Source§

fn update_auth_info<'life0, 'async_trait>( &'life0 self, new_auth_info: Option<AuthInfo>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn auth_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RwLockReadGuard<'_, Option<AuthInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn auth_info_cloned<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<AuthInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn wait_for_initialization<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn send<'life0, 'async_trait>( &'life0 self, message: MessageFromServer, request_id: Option<RequestId>, request_timeout: Option<Duration>, ) -> Pin<Box<dyn Future<Output = SdkResult<Option<ClientMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn send_batch<'life0, 'async_trait>( &'life0 self, messages: Vec<ServerMessage>, request_timeout: Option<Duration>, ) -> Pin<Box<dyn Future<Output = SdkResult<Option<Vec<ClientMessage>>>> + Send + 'async_trait>>
where 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,

Sends a message to the standard error output (stderr) asynchronously.
Source§

fn session_id(&self) -> Option<SessionId>

Source§

fn client_supports_sampling(&self) -> Option<bool>

Checks if the client supports sampling. Read more
Source§

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>

Checks if the client has experimental capabilities available. Read more
Source§

fn is_initialized(&self) -> bool

Checks whether the server has been initialized with client
Source§

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

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,

Sends a request to the client and processes the response. Read more
Source§

fn request_elicitation<'life0, 'async_trait>( &'life0 self, params: ElicitRequestParams, ) -> Pin<Box<dyn Future<Output = SdkResult<ElicitResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends an elicitation request to the client to prompt user input and returns the received response. Read more
Source§

fn request_elicitation_task<'life0, 'async_trait>( &'life0 self, params: ElicitRequestParams, ) -> Pin<Box<dyn Future<Output = SdkResult<CreateTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn request_root_list<'life0, 'async_trait>( &'life0 self, params: Option<RequestParams>, ) -> 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 ping<'life0, 'async_trait>( &'life0 self, params: Option<RequestParams>, 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 request_message_creation<'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 request_get_task<'life0, 'async_trait>( &'life0 self, params: GetTaskParams, ) -> Pin<Box<dyn Future<Output = SdkResult<GetTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a request to retrieve the state of a task.
Source§

fn request_get_task_payload<'life0, 'async_trait>( &'life0 self, params: GetTaskPayloadParams, ) -> Pin<Box<dyn Future<Output = SdkResult<ClientTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a request to retrieve the result of a completed task.
Source§

fn request_task_cancellation<'life0, 'async_trait>( &'life0 self, params: CancelTaskParams, ) -> Pin<Box<dyn Future<Output = SdkResult<CancelTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a request to cancel a task.
Source§

fn request_task_list<'life0, 'async_trait>( &'life0 self, params: Option<PaginatedRequestParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<ListTasksResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

A request to retrieve a list of tasks.
Source§

fn request_custom<'life0, 'async_trait>( &'life0 self, params: CustomRequest, ) -> Pin<Box<dyn Future<Output = SdkResult<GenericResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a custom request with a custom method name and params
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,

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 notify_log_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 notify_prompt_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send 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 notify_resource_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send 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 notify_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,

Send 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 notify_tool_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send 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 notify_cancellation<'life0, 'async_trait>( &'life0 self, params: CancelledNotificationParams, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

This notification can be sent to indicate that it is cancelling a previously-issued request. The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. This notification indicates that the result will be unused, so any associated processing SHOULD cease. A client MUST NOT attempt to cancel its initialize request. For task cancellation, use the tasks/cancel request instead of this notification.
Source§

fn notify_progress<'life0, 'async_trait>( &'life0 self, params: ProgressNotificationParams, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send an out-of-band notification used to inform the receiver of a progress update for a long-running request.
Source§

fn notify_task_status<'life0, 'async_trait>( &'life0 self, params: TaskStatusNotificationParams, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send an optional notification from the receiver to the requestor, informing them that a task’s status has changed. Receivers are not required to send these notifications.
Source§

fn notify_elicitation_completed<'life0, 'async_trait>( &'life0 self, params: ElicitCompleteParams, ) -> 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 of a completion of a out-of-band elicitation request.
Source§

fn notify_custom<'life0, 'async_trait>( &'life0 self, params: CustomNotification, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a custom notification
Source§

fn list_roots<'life0, 'async_trait>( &'life0 self, params: Option<RequestParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<ListRootsResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

👎Deprecated since 0.8.0:

Use request_root_list() instead.

Source§

fn elicit_input<'life0, 'async_trait>( &'life0 self, params: ElicitRequestParams, ) -> Pin<Box<dyn Future<Output = SdkResult<ElicitResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

👎Deprecated since 0.8.0:

Use request_elicitation() instead.

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,

👎Deprecated since 0.8.0:

Use request_message_creation() instead.

Source§

fn send_tool_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

👎Deprecated since 0.8.0:

Use notify_tool_list_changed() instead.

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,

👎Deprecated since 0.8.0:

Use notify_resource_updated() instead.

Source§

fn send_resource_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

👎Deprecated since 0.8.0:

Use notify_resource_list_changed() instead.

Source§

fn send_prompt_list_changed<'life0, 'async_trait>( &'life0 self, params: Option<NotificationParams>, ) -> Pin<Box<dyn Future<Output = SdkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

👎Deprecated since 0.8.0:

Use notify_prompt_list_changed() instead.

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,

👎Deprecated since 0.8.0:

Use notify_log_message() instead.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more