pub struct ServerState {
pub tools: RwLock<ToolSet>,
pub resources: RwLock<ResourceSet>,
pub slot: Arc<RwLock<Option<Arc<Session>>>>,
pub session_root: PathBuf,
pub session_start: Mutex<()>,
pub backend: Backend,
pub peer: Mutex<Option<Peer<RoleServer>>>,
pub listeners: Mutex<Vec<Listener>>,
pub cad: Arc<CadService>,
pub extra_tools: Mutex<Vec<ToolSpec>>,
/* private fields */
}Expand description
Everything the handler shares across requests: the tool and resource sets (rebuilt from the registries whenever a session starts or stops), the session slot, and who to tell when the tool list changes.
Fields§
§tools: RwLock<ToolSet>§resources: RwLock<ResourceSet>§slot: Arc<RwLock<Option<Arc<Session>>>>§session_root: PathBuf§session_start: Mutex<()>§backend: BackendWhere sessions run: spawned per session, or the app this server is in.
peer: Mutex<Option<Peer<RoleServer>>>The last client to initialise: where a legacy client (protocol before
2026-07-28) receives a bare tools/list_changed.
listeners: Mutex<Vec<Listener>>The open subscriptions/listen streams: where a modern client receives
tools/list_changed, tagged with its subscription. One per connection
that asked — the HTTP host serves several at once.
cad: Arc<CadService>The operation service: process-scoped, so an accepted operation outlives the connection and the request that submitted it.
extra_tools: Mutex<Vec<ToolSpec>>Tools a HOST adds to every tool set this server composes, whatever the
session does: the test-mcp runner’s own runner group (its PLM
fixture, step records, session_restart), which a script reaches as
sdk.runner.<tool> and which must survive the rebuild a session
restart makes. Empty unless a host sets it.
Implementations§
Source§impl ServerState
impl ServerState
Auto Trait Implementations§
impl !Freeze for ServerState
impl !RefUnwindSafe for ServerState
impl !UnwindSafe for ServerState
impl Forget for ServerState
impl Move for ServerState
impl Send for ServerStatewhere
RwLock<ToolSet>: Send,
RwLock<ResourceSet>: Send,
Arc<RwLock<Option<Arc<Session>>>>: Send,
RawVecInner: Send,
Mutex<()>: Send,
&'static str: Send,
Arc<dyn Fn(HostConfig) -> Result<HostHandle, String> + Sync + Send>: Send,
Arc<Chan<HostRequest, Semaphore>>: Send,
Arc<dyn Platform>: Send,
Mutex<Option<Peer<RoleServer>>>: Send,
Mutex<Vec<Listener>>: Send,
Atomic<u64>: Send,
Arc<CadService>: Send,
Mutex<Vec<ToolSpec>>: Send,
OnceLock<Arc<Catalogue>>: Send,
impl Sync for ServerStatewhere
RwLock<ToolSet>: Sync,
RwLock<ResourceSet>: Sync,
Arc<RwLock<Option<Arc<Session>>>>: Sync,
RawVecInner: Sync,
Mutex<()>: Sync,
Arc<dyn Fn(HostConfig) -> Result<HostHandle, String> + Sync + Send>: Sync,
Arc<Chan<HostRequest, Semaphore>>: Sync,
Arc<dyn Platform>: Sync,
Mutex<Option<Peer<RoleServer>>>: Sync,
Mutex<Vec<Listener>>: Sync,
Atomic<u64>: Sync,
Arc<CadService>: Sync,
Mutex<Vec<ToolSpec>>: Sync,
OnceLock<Arc<Catalogue>>: Sync,
impl Unpin for ServerStatewhere
Align4<u32>: Unpin,
Align1<u8>: Unpin,
*const Waiter is !null: Unpin,
Align8<usize>: Unpin,
*const u8 is !null: Unpin,
&'static str: Unpin,
Arc<dyn Fn(Value) -> Pin<Box<dyn Future<Output = Result<ToolOutput, String>> + Send>> + Sync + Send>: Unpin,
Arc<dyn Fn() -> Result<String, String> + Sync + Send>: Unpin,
Arc<RwLock<Option<Arc<Session>>>>: Unpin,
Arc<dyn Fn(HostConfig) -> Result<HostHandle, String> + Sync + Send>: Unpin,
Arc<Chan<HostRequest, Semaphore>>: Unpin,
Arc<dyn Platform>: Unpin,
Arc<Chan<PeerSinkMessage<RoleServer>, Semaphore>>: Unpin,
Arc<dyn RequestIdProvider>: Unpin,
Arc<dyn ProgressTokenProvider>: Unpin,
Arc<RwLock<HashMap<ProgressToken, Sender<()>>>>: Unpin,
Arc<RwLock<Option<Arc<InitializeRequestParams>>>>: Unpin,
Arc<OnceLock<ClientRequestMetadata>>: Unpin,
Arc<OnceLock<ProtocolVersion>>: Unpin,
Arc<RwLock<HashMap<NumberOrString, (Sender<ClientNotification>, usize)>>>: Unpin,
Arc<str>: Unpin,
Arc<SubscriptionFilter>: Unpin,
Arc<TreeNode>: Unpin,
Align8<u64>: Unpin,
Arc<CadService>: Unpin,
Arc<Catalogue>: Unpin,
impl UnsafeUnpin for ServerStatewhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const Waiter is !null: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<ToolSpec>: UnsafeUnpin,
PhantomData<ResourceSpec>: UnsafeUnpin,
*const ArcInner<RwLock<Option<Arc<Session>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<Option<Arc<Session>>>>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<dyn Fn(HostConfig) -> Result<HostHandle, String> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(HostConfig) -> Result<HostHandle, String> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<Chan<HostRequest, Semaphore>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Chan<HostRequest, Semaphore>>>: UnsafeUnpin,
*const ArcInner<dyn Platform> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Platform>>: UnsafeUnpin,
*const ArcInner<Chan<PeerSinkMessage<RoleServer>, Semaphore>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Chan<PeerSinkMessage<RoleServer>, Semaphore>>>: UnsafeUnpin,
*const ArcInner<dyn RequestIdProvider> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn RequestIdProvider>>: UnsafeUnpin,
*const ArcInner<dyn ProgressTokenProvider> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ProgressTokenProvider>>: UnsafeUnpin,
*const ArcInner<RwLock<HashMap<ProgressToken, Sender<()>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<HashMap<ProgressToken, Sender<()>>>>>: UnsafeUnpin,
*const ArcInner<RwLock<Option<Arc<InitializeRequestParams>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<Option<Arc<InitializeRequestParams>>>>>: UnsafeUnpin,
*const ArcInner<OnceLock<ClientRequestMetadata>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<ClientRequestMetadata>>>: UnsafeUnpin,
*const ArcInner<OnceLock<ProtocolVersion>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<ProtocolVersion>>>: UnsafeUnpin,
*const ArcInner<RwLock<HashMap<NumberOrString, (Sender<ClientNotification>, usize)>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<HashMap<NumberOrString, (Sender<ClientNotification>, usize)>>>>: UnsafeUnpin,
PhantomData<Listener>: UnsafeUnpin,
Align8<u64>: UnsafeUnpin,
*const ArcInner<CadService> is !null: UnsafeUnpin,
PhantomData<ArcInner<CadService>>: UnsafeUnpin,
*const ArcInner<Catalogue> is !null: UnsafeUnpin,
PhantomData<ArcInner<Catalogue>>: UnsafeUnpin,
PhantomData<Arc<Catalogue>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> DowncastSync for T
impl<T> DowncastSync 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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.