pub struct McpServer { /* private fields */ }Expand description
The MCP server wrapping the Engine.
Implementations§
Source§impl McpServer
impl McpServer
pub fn new(engine: Engine, token_budget: usize) -> Self
Sourcepub fn new_with_filter(
engine: Engine,
token_budget: usize,
disabled_tools: HashSet<String>,
config_source: Option<PathBuf>,
) -> Self
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.
Sourcepub fn new_with_config(
engine: Engine,
token_budget: usize,
disabled_tools: HashSet<String>,
config_source: Option<PathBuf>,
mutations: MutationsSection,
plugin: HashMap<String, Table>,
) -> Self
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.
Sourcepub fn with_default_role(self, role: Role) -> Self
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.
pub fn with_operator_mode(self, operator_mode: bool) -> Self
Sourcepub fn is_operator_mode(&self) -> bool
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.
Sourcepub fn filtered_tool_list(&self) -> Vec<Tool>
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).
Sourcepub fn is_tool_disabled(&self, name: &str) -> bool
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
impl McpServer
Sourcepub fn memstead_entity_tool_attr() -> Tool
pub fn memstead_entity_tool_attr() -> Tool
Generated tool metadata function for memstead_entity
Sourcepub fn memstead_search_tool_attr() -> Tool
pub fn memstead_search_tool_attr() -> Tool
Generated tool metadata function for memstead_search
Sourcepub fn memstead_overview_tool_attr() -> Tool
pub fn memstead_overview_tool_attr() -> Tool
Generated tool metadata function for memstead_overview
Sourcepub fn memstead_schema_tool_attr() -> Tool
pub fn memstead_schema_tool_attr() -> Tool
Generated tool metadata function for memstead_schema
Sourcepub fn memstead_create_tool_attr() -> Tool
pub fn memstead_create_tool_attr() -> Tool
Generated tool metadata function for memstead_create
Sourcepub fn memstead_update_tool_attr() -> Tool
pub fn memstead_update_tool_attr() -> Tool
Generated tool metadata function for memstead_update
Sourcepub fn memstead_relate_tool_attr() -> Tool
pub fn memstead_relate_tool_attr() -> Tool
Generated tool metadata function for memstead_relate
Sourcepub fn memstead_delete_tool_attr() -> Tool
pub fn memstead_delete_tool_attr() -> Tool
Generated tool metadata function for memstead_delete
Sourcepub fn memstead_check_tool_attr() -> Tool
pub fn memstead_check_tool_attr() -> Tool
Generated tool metadata function for memstead_check
Sourcepub fn memstead_rename_tool_attr() -> Tool
pub fn memstead_rename_tool_attr() -> Tool
Generated tool metadata function for memstead_rename
Sourcepub fn memstead_health_tool_attr() -> Tool
pub fn memstead_health_tool_attr() -> Tool
Generated tool metadata function for memstead_health
Sourcepub fn memstead_changes_since_tool_attr() -> Tool
pub fn memstead_changes_since_tool_attr() -> Tool
Generated tool metadata function for memstead_changes_since
Sourcepub fn memstead_diff_tool_attr() -> Tool
pub fn memstead_diff_tool_attr() -> Tool
Generated tool metadata function for memstead_diff
Sourcepub fn memstead_reload_tool_attr() -> Tool
pub fn memstead_reload_tool_attr() -> Tool
Generated tool metadata function for memstead_reload
Sourcepub fn memstead_mem_create_tool_attr() -> Tool
pub fn memstead_mem_create_tool_attr() -> Tool
Generated tool metadata function for memstead_mem_create
Sourcepub fn memstead_mem_delete_tool_attr() -> Tool
pub fn memstead_mem_delete_tool_attr() -> Tool
Generated tool metadata function for memstead_mem_delete
Sourcepub fn memstead_mem_set_version_tool_attr() -> Tool
pub fn memstead_mem_set_version_tool_attr() -> Tool
Generated tool metadata function for memstead_mem_set_version
Sourcepub fn memstead_mem_configure_tool_attr() -> Tool
pub fn memstead_mem_configure_tool_attr() -> Tool
Generated tool metadata function for memstead_mem_configure
Sourcepub fn memstead_mem_set_schema_tool_attr() -> Tool
pub fn memstead_mem_set_schema_tool_attr() -> Tool
Generated tool metadata function for memstead_mem_set_schema
Sourcepub fn memstead_workspace_grant_cross_link_tool_attr() -> Tool
pub fn memstead_workspace_grant_cross_link_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_grant_cross_link
Sourcepub fn memstead_workspace_revoke_cross_link_tool_attr() -> Tool
pub fn memstead_workspace_revoke_cross_link_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_revoke_cross_link
Sourcepub fn memstead_workspace_allow_create_tool_attr() -> Tool
pub fn memstead_workspace_allow_create_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_allow_create
Sourcepub fn memstead_workspace_revoke_create_tool_attr() -> Tool
pub fn memstead_workspace_revoke_create_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_revoke_create
Sourcepub fn memstead_workspace_allow_delete_tool_attr() -> Tool
pub fn memstead_workspace_allow_delete_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_allow_delete
Sourcepub fn memstead_workspace_revoke_delete_tool_attr() -> Tool
pub fn memstead_workspace_revoke_delete_tool_attr() -> Tool
Generated tool metadata function for memstead_workspace_revoke_delete
pub fn tool_router() -> ToolRouter<Self>
Trait Implementations§
Source§impl ServerHandler for McpServer
impl ServerHandler for McpServer
Source§fn get_info(&self) -> ServerInfo
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>
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>
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>
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>
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.
fn enqueue_task( &self, _request: CallToolRequestParams, _context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CreateTaskResult, ErrorData>> + MaybeSendFuture
fn ping( &self, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture
fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CompleteResult, ErrorData>> + MaybeSendFuture
fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture
fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetPromptResult, ErrorData>> + MaybeSendFuture
fn list_prompts( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListPromptsResult, ErrorData>> + MaybeSendFuture
fn list_resources( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourcesResult, ErrorData>> + MaybeSendFuture
fn list_resource_templates( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourceTemplatesResult, ErrorData>> + MaybeSendFuture
fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ReadResourceResult, ErrorData>> + MaybeSendFuture
fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture
fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture
fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CustomResult, ErrorData>> + MaybeSendFuture
fn on_cancelled( &self, notification: CancelledNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn on_progress( &self, notification: ProgressNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn on_initialized( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn on_roots_list_changed( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn on_task_status( &self, params: TaskStatusNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture
fn list_tasks( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListTasksResult, ErrorData>> + MaybeSendFuture
fn get_task_info( &self, request: GetTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture
fn get_task_result( &self, request: GetTaskPayloadParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskPayloadResult, ErrorData>> + MaybeSendFuture
fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CancelTaskResult, ErrorData>> + MaybeSendFuture
Auto Trait Implementations§
impl Freeze for McpServer
impl RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
impl UnwindSafe for McpServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<R, S> DynService<R> for Swhere
R: ServiceRole,
S: Service<R>,
impl<R, S> DynService<R> for Swhere
R: ServiceRole,
S: Service<R>,
fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>
fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>
fn get_info(&self) -> <R as ServiceRole>::Info
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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