Skip to main content

McpServer

Struct McpServer 

Source
pub struct McpServer { /* private fields */ }

Implementations§

Source§

impl McpServer

Source

pub fn new() -> Self

Create a new MCP server.

Source

pub fn enable_layered_pipeline(&mut self, pipeline: SessionPipeline)

Enable the Paper 2 layered pipeline (L0 cross-turn dedup) for the lifetime of this server. Once set, every tools/call response is passed through SessionPipeline::process before being returned.

Source

pub fn on_compaction_boundary(&self)

Drop the layered-pipeline cache partition on host compaction.

Source

pub fn set_routing_engine(&mut self, engine: Arc<RoutingEngine>)

Install a transparent-routing engine. Must be built by the caller after upstream tools have been fetched and the local tool catalogue has been enumerated.

Source

pub fn set_telemetry(&mut self, buffer: TelemetryBuffer)

Install a telemetry buffer. Every tool invocation emits one event into it.

Source

pub fn set_builtin_tools_config( &mut self, config: BuiltinToolsConfig, ) -> Result<()>

Set the built-in tools filtering configuration.

Returns an error if both disabled and enabled are set (mutually exclusive).

Source

pub fn set_proxy_manager(&mut self, proxy_manager: ProxyManager)

Set the proxy manager for upstream MCP server connections.

Source

pub fn set_deferred_init(&mut self, receiver: Receiver<DeferredInit>)

Set deferred initialization that will be resolved on first tools/list or tools/call.

This allows the MCP server to start reading stdin immediately while remote config fetch, proxy connections, and tool loading run in the background.

Source

pub fn add_meeting_provider(&mut self, provider: Arc<dyn MeetingNotesProvider>)

Source

pub fn add_knowledge_base_provider( &mut self, provider: Arc<dyn KnowledgeBaseProvider>, )

Source

pub fn add_knowledge_base_provider_to_context( &mut self, context: &str, provider: Arc<dyn KnowledgeBaseProvider>, )

Source

pub fn add_messenger_provider(&mut self, provider: Arc<dyn MessengerProvider>)

Source

pub fn add_messenger_provider_to_context( &mut self, context: &str, provider: Arc<dyn MessengerProvider>, )

Source

pub fn add_provider(&mut self, provider: Arc<dyn Provider>)

Source

pub fn add_provider_to_context( &mut self, context: &str, provider: Arc<dyn Provider>, )

Add a provider under a named context.

Source

pub fn ensure_context(&mut self, context: &str)

Ensure a named context exists, even if it has no providers.

Source

pub fn set_active_context(&self, context: &str) -> Result<()>

Source

pub fn active_context_name(&self) -> String

Get active context name.

Source

pub fn context_names(&self) -> Vec<String>

List all context names.

Source

pub fn active_providers(&self) -> Vec<Arc<dyn Provider>>

Get providers in active context.

Source

pub fn active_knowledge_base_providers( &self, ) -> Vec<Arc<dyn KnowledgeBaseProvider>>

Get knowledge base providers in active context.

Source

pub fn active_messenger_providers(&self) -> Vec<Arc<dyn MessengerProvider>>

Get messenger providers in active context.

Source

pub fn providers(&self) -> &[Arc<dyn Provider>]

Get providers in the default context.

Source

pub async fn run(&mut self) -> Result<()>

Run the MCP server main loop.

Source

pub async fn handle_request(&mut self, req: JsonRpcRequest) -> JsonRpcResponse

Handle a JSON-RPC request.

Source

pub fn handle_tools_list(&self, id: RequestId) -> JsonRpcResponse

Handle tools/list request.

Returns the list of available tools filtered by configured providers. This method is public to allow integration testing.

Source

pub async fn execute_for_prefetch( &self, name: &str, arguments: Option<Value>, ) -> ToolCallResult

Paper 3 — execute a tool out-of-band for the speculative pre-fetch dispatcher.

Goes through the same routing engine as the main flow so that transparent-proxy prefixes / fallbacks / mock providers all work identically. Differences from handle_tools_call:

  • No JsonRpcResponse wrapping — returns the raw ToolCallResult.
  • No telemetry write here — the synthetic PipelineEvent is emitted later by SessionPipeline::write_prefetch_to_cache with enricher_prefetched = true.
  • No mutation invalidation — the planner’s is_speculatable() filter blocks MutatesLocal / MutatesExternal upstream, so we never reach this method for a write.
  • No dedup post-pass — the prefetched body is written into the dedup cache afterward by SessionPipeline, not here.

Internal-context tools (use_context, list_contexts, …) are not eligible for speculation by design, so they short-circuit to an error result rather than mutating server state.

Trait Implementations§

Source§

impl Default for McpServer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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