Skip to main content

McpServer

Struct McpServer 

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

The MCP server wrapping the Engine.

Implementations§

Source§

impl McpServer

Source

pub fn new(engine: Engine, token_budget: usize) -> Self

Source

pub fn new_with_filter( engine: Engine, token_budget: usize, disabled_tools: HashSet<String>, config_source: Option<PathBuf>, ) -> Self

Construct with an explicit disabled-tool filter. disabled_tools must already be validated against the compile-time tool-name registry (see config::validate_disabled_tools). config_source is the .memstead/workspace.toml path attributed in the TOOL_DISABLED envelope; pass None when there is no file-backed config.

Source

pub fn new_with_config( engine: Engine, token_budget: usize, disabled_tools: HashSet<String>, config_source: Option<PathBuf>, mutations: MutationsSection, plugin: HashMap<String, Table>, ) -> Self

Full-surface constructor. mutations and plugin come from EffectiveSettings and are surfaced verbatim under memstead_health { include_config: true }. The operator-mode posture defaults to false (agent-mode); flip it via Self::with_operator_mode before serving when boot established operator intent.

Source

pub fn with_default_role(self, role: Role) -> Self

Builder-style setter for the operator-mode posture. Returns self for fluent chaining at the boot site. Only the memstead-mcp --operator-mode boot path is authorised to call this with true; agent-spawned servers leave it on the default false. Set the session-level default role (the binary’s --role flag). Per-call role parameters win over this default.

Source

pub fn with_operator_mode(self, operator_mode: bool) -> Self

Source

pub fn is_operator_mode(&self) -> bool

true when this server was booted with operator-mode bypass. Exposed so callers (tests, the overview surface) can observe the posture without reaching into private state.

Source

pub fn unified_engine(&self) -> &Arc<Mutex<Engine>>

Borrow of the unified engine handle.

Source

pub fn filtered_tool_list(&self) -> Vec<Tool>

Tool list filtered by the workspace’s disabled_tools set. Used by the list_tools handler and directly by tests (which cannot easily synthesize a RequestContext).

Source

pub fn is_tool_disabled(&self, name: &str) -> bool

true if the given tool name is disabled in this server’s workspace. Public so tests can reason about the filter without reaching into private state.

Source§

impl McpServer

Source

pub fn memstead_entity_tool_attr() -> Tool

Generated tool metadata function for memstead_entity

Source

pub fn memstead_search_tool_attr() -> Tool

Generated tool metadata function for memstead_search

Source

pub fn memstead_overview_tool_attr() -> Tool

Generated tool metadata function for memstead_overview

Source

pub fn memstead_schema_tool_attr() -> Tool

Generated tool metadata function for memstead_schema

Source

pub fn memstead_create_tool_attr() -> Tool

Generated tool metadata function for memstead_create

Source

pub fn memstead_update_tool_attr() -> Tool

Generated tool metadata function for memstead_update

Source

pub fn memstead_relate_tool_attr() -> Tool

Generated tool metadata function for memstead_relate

Source

pub fn memstead_delete_tool_attr() -> Tool

Generated tool metadata function for memstead_delete

Source

pub fn memstead_check_tool_attr() -> Tool

Generated tool metadata function for memstead_check

Source

pub fn memstead_rename_tool_attr() -> Tool

Generated tool metadata function for memstead_rename

Source

pub fn memstead_health_tool_attr() -> Tool

Generated tool metadata function for memstead_health

Source

pub fn memstead_changes_since_tool_attr() -> Tool

Generated tool metadata function for memstead_changes_since

Source

pub fn memstead_diff_tool_attr() -> Tool

Generated tool metadata function for memstead_diff

Source

pub fn memstead_reload_tool_attr() -> Tool

Generated tool metadata function for memstead_reload

Source

pub fn memstead_mem_create_tool_attr() -> Tool

Generated tool metadata function for memstead_mem_create

Source

pub fn memstead_mem_delete_tool_attr() -> Tool

Generated tool metadata function for memstead_mem_delete

Source

pub fn memstead_mem_set_version_tool_attr() -> Tool

Generated tool metadata function for memstead_mem_set_version

Source

pub fn memstead_mem_configure_tool_attr() -> Tool

Generated tool metadata function for memstead_mem_configure

Source

pub fn memstead_mem_set_schema_tool_attr() -> Tool

Generated tool metadata function for memstead_mem_set_schema

Generated tool metadata function for memstead_workspace_grant_cross_link

Generated tool metadata function for memstead_workspace_revoke_cross_link

Source

pub fn memstead_workspace_allow_create_tool_attr() -> Tool

Generated tool metadata function for memstead_workspace_allow_create

Source

pub fn memstead_workspace_revoke_create_tool_attr() -> Tool

Generated tool metadata function for memstead_workspace_revoke_create

Source

pub fn memstead_workspace_allow_delete_tool_attr() -> Tool

Generated tool metadata function for memstead_workspace_allow_delete

Source

pub fn memstead_workspace_revoke_delete_tool_attr() -> Tool

Generated tool metadata function for memstead_workspace_revoke_delete

Source

pub fn tool_router() -> ToolRouter<Self>

Trait Implementations§

Source§

impl Clone for McpServer

Source§

fn clone(&self) -> McpServer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ServerHandler for McpServer

Source§

fn get_info(&self) -> ServerInfo

Hand-written so instructions can be the named SERVER_INSTRUCTIONS const (the macro only accepts string literals) and the serverInfo version is the engine’s full build version (semver + git build sha for dev builds) by construction — the historical hardcoded "0.1.0" cannot recur, and two dev builds between releases stay distinguishable. The const keeps its compile-time semver line; a short runtime “Build:” sentence is appended only when a sha exists. Mirrors the shape #[tool_handler] would generate.

Source§

async fn initialize( &self, request: InitializeRequestParams, context: RequestContext<RoleServer>, ) -> Result<InitializeResult, McpError>

Capture the client’s clientInfo from the initialize handshake so every agent-initiated mutation can tag its commit with a Client: <name>@<version> trailer.

Mirrors the default ServerHandler::initialize body (set peer info + return get_info()) and additionally stashes the client identity into McpServer::client. OnceLock::set returning Err would mean a second initialize arrived on the same server instance — impossible under the stdio transport (one process per client) but worth logging if the transport ever changes.

Source§

async fn list_tools( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, McpError>

list_tools with the workspace’s disabled_tools filter applied. Defining this method stops #[tool_handler] from generating the default body (see has_method gate in rmcp-macros::tool_handler). Behavior is byte-identical to the default when the filter is empty; otherwise matching tool records are omitted from the response.

Source§

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

get_tool short-circuits on disabled names to None so rmcp’s validation path treats a disabled tool as non-existent. Matches list_tools — a disabled tool is neither listed nor discoverable by name.

Source§

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

call_tool rejects disabled names with a TOOL_DISABLED envelope before dispatch. A client that kept a stale tool list or deliberately probes the bypass gets the same contract as the list_tools omission: this tool is not available here.

This is also the friction ledger’s one recording seam for the whole tool surface (agent-trust plan 08): every dispatched result that is a typed refusal appends one ledger entry whose values all come from closed engine-defined vocabularies (the module’s privacy hard line — never parameters or payload text) — best-effort, after the response is already built, so recording can never perturb the refusal it measures.

Source§

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

Source§

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

Source§

fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CompleteResult, ErrorData>> + MaybeSendFuture

Source§

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

Source§

fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetPromptResult, ErrorData>> + MaybeSendFuture

Source§

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

Source§

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

Source§

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

Source§

fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ReadResourceResult, ErrorData>> + MaybeSendFuture

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn on_task_status( &self, params: TaskStatusNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + 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: GetTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture

Source§

fn get_task_result( &self, request: GetTaskPayloadParams, 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§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Fruit for T
where T: Send + Downcast,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, S: Sized,

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