Skip to main content

Server

Struct Server 

Source
pub struct Server<T, P, R, C, L, I> { /* private fields */ }
Expand description

A composable MCP server that routes requests to individual capability providers.

Use ServerBuilder to construct a server.

§Type Parameters

  • T: Tools provider (or Unset)
  • P: Prompts provider (or Unset)
  • R: Resources provider (or Unset)
  • C: Completion provider (or Unset)
  • L: Logging provider (or Unset)
  • I: Server info provider (required)

Implementations§

Source§

impl<T, P, R, C, L, I> Server<T, P, R, C, L, I>

Source

pub fn builder() -> ServerBuilder<Unset, Unset, Unset, Unset, Unset, Unset>

Create a new server builder.

Trait Implementations§

Source§

impl<T: Clone, P: Clone, R: Clone, C: Clone, L: Clone, I: Clone> Clone for Server<T, P, R, C, L, I>

Source§

fn clone(&self) -> Server<T, P, R, C, L, I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, P, R, C, L, I> ServerHandler for Server<T, P, R, C, L, I>

Source§

fn get_info(&self) -> ServerInfo

Source§

async fn initialize( &self, _request: InitializeRequestParams, _context: RequestContext<RoleServer>, ) -> Result<InitializeResult, ErrorData>

Source§

async fn ping( &self, _context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Source§

async fn list_tools( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>

Source§

async fn call_tool( &self, request: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResult, ErrorData>

Source§

async fn list_prompts( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListPromptsResult, ErrorData>

Source§

async fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> Result<GetPromptResult, ErrorData>

Source§

async fn list_resources( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourcesResult, ErrorData>

Source§

async fn list_resource_templates( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourceTemplatesResult, ErrorData>

Source§

async fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> Result<ReadResourceResult, ErrorData>

Source§

async fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Source§

async fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Source§

async fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> Result<CompleteResult, ErrorData>

Source§

async fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Source§

async fn on_cancelled( &self, _notification: CancelledNotificationParam, _context: NotificationContext<RoleServer>, )

Source§

async fn on_progress( &self, _notification: ProgressNotificationParam, _context: NotificationContext<RoleServer>, )

Source§

async fn on_initialized(&self, _context: NotificationContext<RoleServer>)

Source§

async fn on_roots_list_changed(&self, _context: NotificationContext<RoleServer>)

Source§

fn enqueue_task( &self, _request: CallToolRequestParams, _context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CreateTaskResult, ErrorData>> + MaybeSendFuture

Source§

fn get_tool(&self, _name: &str) -> Option<Tool>

Get a tool definition by name. Read more
Source§

fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CustomResult, ErrorData>> + MaybeSendFuture

Source§

fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn list_tasks( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListTasksResult, ErrorData>> + MaybeSendFuture

Source§

fn get_task_info( &self, request: GetTaskInfoParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture

Source§

fn get_task_result( &self, request: GetTaskResultParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskPayloadResult, ErrorData>> + MaybeSendFuture

Source§

fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CancelTaskResult, ErrorData>> + MaybeSendFuture

Auto Trait Implementations§

§

impl<T, P, R, C, L, I> Freeze for Server<T, P, R, C, L, I>
where I: Freeze, T: Freeze, P: Freeze, R: Freeze, C: Freeze, L: Freeze,

§

impl<T, P, R, C, L, I> RefUnwindSafe for Server<T, P, R, C, L, I>

§

impl<T, P, R, C, L, I> Send for Server<T, P, R, C, L, I>
where I: Send, T: Send, P: Send, R: Send, C: Send, L: Send,

§

impl<T, P, R, C, L, I> Sync for Server<T, P, R, C, L, I>
where I: Sync, T: Sync, P: Sync, R: Sync, C: Sync, L: Sync,

§

impl<T, P, R, C, L, I> Unpin for Server<T, P, R, C, L, I>
where I: Unpin, T: Unpin, P: Unpin, R: Unpin, C: Unpin, L: Unpin,

§

impl<T, P, R, C, L, I> UnsafeUnpin for Server<T, P, R, C, L, I>

§

impl<T, P, R, C, L, I> UnwindSafe for Server<T, P, R, C, L, I>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CompletionProvider for T
where T: ServerHandler,

Source§

async fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> Result<CompleteResult, ErrorData>

Provide completion suggestions.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<R, S> DynService<R> for S
where R: ServiceRole, S: Service<R>,

Source§

fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>

Source§

fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>

Source§

fn get_info(&self) -> <R as ServiceRole>::Info

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> LoggingProvider for T
where T: ServerHandler,

Source§

async fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Set the logging level.
Source§

impl<T> PromptsProvider for T
where T: ServerHandler,

Source§

async fn list_prompts( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListPromptsResult, ErrorData>

List available prompts.
Source§

async fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> Result<GetPromptResult, ErrorData>

Get a specific prompt.
Source§

impl<T> ResourcesProvider for T
where T: ServerHandler,

Source§

async fn list_resources( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourcesResult, ErrorData>

List available resources.
Source§

async fn list_resource_templates( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListResourceTemplatesResult, ErrorData>

List resource templates.
Source§

async fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> Result<ReadResourceResult, ErrorData>

Read a resource.
Source§

async fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Subscribe to resource updates.
Source§

async fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Unsubscribe from resource updates.
Source§

impl<H> Service<RoleServer> for H
where H: ServerHandler,

Source§

impl<S> ServiceExt<RoleServer> for S
where S: Service<RoleServer>,

Source§

fn serve_with_ct<T, E, A>( self, transport: T, ct: CancellationToken, ) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + MaybeSendFuture
where T: IntoTransport<RoleServer, E, A>, E: Error + Send + Sync + 'static,

Source§

fn into_dyn(self) -> Box<dyn DynService<R>>

Convert this service to a dynamic boxed service Read more
Source§

fn serve<T, E, A>( self, transport: T, ) -> impl Future<Output = Result<RunningService<R, Self>, <R as ServiceRole>::InitializeError>> + MaybeSendFuture
where T: IntoTransport<R, E, A>, E: Error + Send + Sync + 'static, Self: Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToolsProvider for T
where T: ServerHandler,

Source§

async fn list_tools( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>

List available tools.
Source§

async fn call_tool( &self, request: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResult, ErrorData>

Execute a tool.
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