pub struct McpServer {
session: Session,
heard: Option<(Arc<Mutex<HashSet<String>>>, Out)>,
came: Instant,
}Expand description
One editor, driven by tools.
Fields§
§session: Session§heard: Option<(Arc<Mutex<HashSet<String>>>, Out)>What is cancelled, and where to say how far a call is, as serve
has them.
came: InstantWhen the message being answered came: how long it waited.
Implementations§
Source§impl McpServer
impl McpServer
pub fn new() -> Self
Sourcepub fn handle(&mut self, line: &str) -> Option<Value>
pub fn handle(&mut self, line: &str) -> Option<Value>
Answers one JSON-RPC message, or nothing for a notification.
Sourcefn call(
&mut self,
name: &str,
arguments: &Value,
id: &Value,
token: Option<Value>,
) -> Value
fn call( &mut self, name: &str, arguments: &Value, id: &Value, token: Option<Value>, ) -> Value
Calls the tool name with arguments, as tools/call answers: its
result as text, or why it failed as an error result. A kernel that
panics leaves the editor in an unknown state: a fresh one takes
over, with the program as it was before the call.
Sourcefn watcher(
&self,
id: &Value,
token: Option<Value>,
deadline: Option<Instant>,
) -> impl FnMut(&Progress<'_>) -> bool + 'static
fn watcher( &self, id: &Value, token: Option<Value>, deadline: Option<Instant>, ) -> impl FnMut(&Progress<'_>) -> bool + 'static
What watches the call id: it tells the client how far it is, if
the client gave a token to say it by, no more than once a second,
and stops it once it is cancelled, or at deadline.
Sourcefn guarded<T>(
&mut self,
what: &str,
f: impl FnOnce(&mut Session) -> GeopResult<T>,
) -> Result<T, String>
fn guarded<T>( &mut self, what: &str, f: impl FnOnce(&mut Session) -> GeopResult<T>, ) -> Result<T, String>
f on the session, or why it failed. A kernel that panics leaves
the editor in an unknown state: a fresh one takes over, with the
program as it was before, and the panic is told as what what did.