pub struct McpPlugin { /* private fields */ }Expand description
A plugin backed by an MCP server child process.
The MCP server is spawned during load() and shut down during
unload(). Tool calls are forwarded over the MCP connection via
the stored Peer handle.
§Dependency Injection
McpPlugin::new() receives an McpClient at construction time.
The caller (plugin manager / runtime) decides which Plugin impl to
create based on the manifest’s PluginEntryPoint.
Implementations§
Source§impl McpPlugin
impl McpPlugin
Sourcepub fn new(manifest: PluginManifest, mcp_client: McpClient) -> Self
pub fn new(manifest: PluginManifest, mcp_client: McpClient) -> Self
Create a new MCP plugin.
The plugin starts in Unloaded state. Call Plugin::load() to
spawn the MCP server and discover tools.
Sourcepub fn with_sandbox(self, profile: SandboxProfile) -> Self
pub fn with_sandbox(self, profile: SandboxProfile) -> Self
Set an OS sandbox profile for the child process.
Sourcepub async fn send_hook_event(&self, event: HookEvent, data: Value)
pub async fn send_hook_event(&self, event: HookEvent, data: Value)
Send a hook event notification to the MCP server.
Sends a custom MCP notification with method
notifications/astrid.hookEvent. This is fire-and-forget;
errors are logged but do not propagate.
Sourcepub fn server_name(&self) -> &str
pub fn server_name(&self) -> &str
Get the MCP server name for this plugin.
Sourcepub fn mcp_client(&self) -> &McpClient
pub fn mcp_client(&self) -> &McpClient
Get a reference to the injected McpClient.
Sourcepub fn check_health(&mut self) -> bool
pub fn check_health(&mut self) -> bool
Check if the MCP server child process is still running.
Returns true if the plugin is loaded and the underlying MCP service
reports it is still alive. If the process has crashed, transitions the
plugin state to Failed and returns false.
Trait Implementations§
Source§impl Plugin for McpPlugin
impl Plugin for McpPlugin
Source§fn manifest(&self) -> &PluginManifest
fn manifest(&self) -> &PluginManifest
Source§fn state(&self) -> PluginState
fn state(&self) -> PluginState
Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for McpPlugin
impl !RefUnwindSafe for McpPlugin
impl Send for McpPlugin
impl Sync for McpPlugin
impl Unpin for McpPlugin
impl UnsafeUnpin for McpPlugin
impl !UnwindSafe for McpPlugin
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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