Skip to main content

Kit

Struct Kit 

Source
pub struct Kit<M, I = Local, E = Open, T = Unmetered, S = InProcessTasks> { /* private fields */ }
Expand description

A module ready to serve, with the seams its calls go through.

Implementations§

Source§

impl<M: Module, I: Identity> Kit<M, I>

Source

pub fn new(module: M, identity: I) -> Self

The module with the open-source entitlements, metering and task store.

Source§

impl<M: Module, I: Identity, E: Entitlements, T: Metering, S: TaskStore> Kit<M, I, E, T, S>

Source

pub fn with_entitlements<E2: Entitlements>( self, entitlements: E2, ) -> Kit<M, I, E2, T, S>

Source

pub fn with_metering<T2: Metering>(self, metering: T2) -> Kit<M, I, E, T2, S>

Source

pub fn with_changes(self, changes: impl ChangeFeed) -> Self

Carries resource changes through changes instead of within this process, for listeners on other instances.

Source

pub fn with_tasks<S2: TaskStore>(self, tasks: S2) -> Kit<M, I, E, T, S2>

Source

pub fn manifest(&self) -> &Manifest

Source

pub fn tools(&self) -> impl Iterator<Item = &Tool>

Every registered operation, in registration order.

Source

pub fn instructions(&self) -> Option<&'static str>

The module’s guidance for a model, if it gave any.

Source

pub fn looks(&self) -> &Looks

How the server shows to people.

Source

pub fn apps(&self) -> &[App]

Every registered MCP App page.

Source

pub fn resources(&self) -> impl Iterator<Item = &Resource>

Every registered resource and resource template.

Source

pub async fn read( &self, uri: &str, bearer: Option<&str>, ) -> Result<Body, CallError>

Reads the resource at uri for the caller holding bearer.

Source

pub fn prompts(&self) -> impl Iterator<Item = &Prompt>

Every registered prompt.

Source

pub async fn prompt( &self, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<Vec<Message>, CallError>

Fills prompt name from arguments for the caller holding bearer.

Source

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

The registered operation name.

Source

pub async fn call( &self, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<Reply, CallError>

Calls operation name for the caller holding bearer, and waits for its result.

Source

pub async fn start( self: &Arc<Self>, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<StoredTask, CallError>

Starts operation name as a task for the caller holding bearer, and returns it while the operation runs.

Source

pub async fn update( self: &Arc<Self>, bearer: Option<&str>, id: &str, answers: BTreeMap<String, Value>, ) -> Result<StoredTask, CallError>

Gives a task that asked for input the user’s answers and runs its operation again with them. A task not waiting for input is left as it is, as are answers to questions it did not ask.

Source

pub async fn task( &self, bearer: Option<&str>, id: &str, ) -> Result<StoredTask, CallError>

The caller’s task id.

Source

pub async fn cancel( &self, bearer: Option<&str>, id: &str, ) -> Result<StoredTask, CallError>

Marks the caller’s task id cancelled. Cooperative: the operation sees Ctx::is_cancelled when it runs in this process, stops where its state is whole, and its result is discarded; the kit never stops it between two awaits.

Source§

impl<M: Module, I: Identity, E: Entitlements, T: Metering, S: TaskStore> Kit<M, I, E, T, S>

Source

pub async fn serve_stdio(self) -> Result<()>

Serves this kit over stdin and stdout until the client disconnects.

Auto Trait Implementations§

§

impl<M, I = Local, E = Open, T = Unmetered, S = InProcessTasks> !Freeze for Kit<M, I, E, T, S>

§

impl<M, I = Local, E = Open, T = Unmetered, S = InProcessTasks> !RefUnwindSafe for Kit<M, I, E, T, S>

§

impl<M, I = Local, E = Open, T = Unmetered, S = InProcessTasks> !UnwindSafe for Kit<M, I, E, T, S>

§

impl<M, I, E, T, S> Forget for Kit<M, I, E, T, S>

§

impl<M, I, E, T, S> Send for Kit<M, I, E, T, S>
where Core<M>: Send, I: Send, E: Send, T: Send, S: Send,

§

impl<M, I, E, T, S> Sync for Kit<M, I, E, T, S>
where Core<M>: Sync, I: Sync, E: Sync, T: Sync, S: Sync,

§

impl<M, I, E, T, S> Unpin for Kit<M, I, E, T, S>
where Core<M>: Unpin, I: Unpin, E: Unpin, T: Unpin, S: Unpin,

§

impl<M, I, E, T, S> UnsafeUnpin for Kit<M, I, E, T, S>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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