pub struct McpServer { /* private fields */ }Expand description
A server for an AI agent: on the person’s replica, as the AI client, or on the agent’s own replica of a library.
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn open<E: Environment>(
cli: &Cli,
environment: &mut E,
) -> Result<Self, CliError>
pub fn open<E: Environment>( cli: &Cli, environment: &mut E, ) -> Result<Self, CliError>
The server of nib mcp as cli gives it: on the library it names, which must allow
AI agents or be an AI agent’s replica, unlocked without asking on a terminal.
§Errors
Returns CliError::NotAnAiAgent if the library neither allows AI agents nor is an
AI agent’s replica, CliError::NoTerminal if its keys need a passphrase that no
file gives, and the errors of opening the library.
Sourcepub fn set_network(&mut self, options: NetworkOptions)
pub fn set_network(&mut self, options: NetworkOptions)
Starts the network, when the server first syncs, as options say rather than as the
command line did, such as without looking for replicas on the network.
Sourcepub fn remember(
&mut self,
endpoint: [u8; 32],
addresses: &[SocketAddr],
) -> Result<(), CliError>
pub fn remember( &mut self, endpoint: [u8; 32], addresses: &[SocketAddr], ) -> Result<(), CliError>
Tells the server where a replica’s endpoint is, as one that it finds without looking on the network, such as another in the same test.
§Errors
Returns an error if the network cannot start.
Sourcepub fn handle<E: Environment>(
&mut self,
line: &str,
environment: &mut E,
) -> Option<String>
pub fn handle<E: Environment>( &mut self, line: &str, environment: &mut E, ) -> Option<String>
Handles one message from the client, a line of JSON, and returns the line to answer with, if it is a request.
Sourcepub fn idle<E: Environment>(&mut self, environment: &mut E)
pub fn idle<E: Environment>(&mut self, environment: &mut E)
Syncs, if the AI agent changed something a few seconds ago and nothing came since, unless the server tried since the change, and less than a minute ago: a user whose devices are not waiting is not looked for every second. A sync that started at the moment of the change came before it, as the sync before a tool runs does.
Sourcepub fn finish<E: Environment>(self, environment: &mut E)
pub fn finish<E: Environment>(self, environment: &mut E)
Syncs what the AI agent changed since the last sync, as the server ends.
Auto Trait Implementations§
impl !Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl !Sync for McpServer
impl !UnwindSafe for McpServer
impl Forget for McpServer
impl Move for McpServer
impl Send for McpServer
impl Unpin for McpServer
impl UnsafeUnpin 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
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.