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( &self, client_details: InitializeRequestParams, ) -> SdkResult<()>

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<'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

Source§

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,

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

fn get_client_info(&self) -> Option<InitializeRequestParams>

👎Deprecated since 0.2.0: Use client_info() instead.
Source§

fn get_server_info(&self) -> &InitializeResult

👎Deprecated since 0.2.0: Use server_info() instead.
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 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,

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,

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,

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,

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,

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,

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,

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,

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>

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 assert_client_capabilities( &self, request_method: &String, ) -> Result<(), RpcError>

Asserts that client capabilities are available for a given server request. Read more
Source§

fn assert_server_notification_capabilities( &self, notification_method: &String, ) -> Result<(), RpcError>

Source§

fn assert_server_request_capabilities( &self, request_method: &String, ) -> Result<(), RpcError>

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,