pub struct McpCapabilityProvider { /* private fields */ }Expand description
A CapabilityProvider that surfaces MCP tools, resources, and prompts into the
agentkit capabilities system.
Built from a discovery snapshot, this provider wraps each MCP tool as an
McpInvocable, each resource as an McpResourceHandle, and each prompt as
an McpPromptHandle.
§Example
use std::sync::Arc;
use agentkit_mcp::{McpCapabilityProvider, McpServerConfig, McpTransportBinding, StdioTransportConfig};
let config = McpServerConfig::new(
"filesystem",
McpTransportBinding::Stdio(StdioTransportConfig::new("npx")
.with_arg("-y")
.with_arg("@modelcontextprotocol/server-filesystem")),
);
let (connection, provider, snapshot) = McpCapabilityProvider::connect(&config).await?;
// `provider` implements CapabilityProvider and can be registered with an agent.Implementations§
Source§impl McpCapabilityProvider
impl McpCapabilityProvider
Sourcepub fn from_snapshot(
connection: Arc<McpConnection>,
snapshot: &McpDiscoverySnapshot,
) -> Self
pub fn from_snapshot( connection: Arc<McpConnection>, snapshot: &McpDiscoverySnapshot, ) -> Self
Creates a capability provider from an existing connection and its discovery snapshot.
Each tool, resource, and prompt in the snapshot is wrapped in the appropriate adapter type.
Sourcepub fn merge<I>(providers: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn merge<I>(providers: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Merges multiple capability providers into a single provider.
This is useful when managing several MCP servers through a
McpServerManager and you want one combined provider for the agent.
Sourcepub async fn connect(
config: &McpServerConfig,
) -> Result<(Arc<McpConnection>, Self, McpDiscoverySnapshot), McpError>
pub async fn connect( config: &McpServerConfig, ) -> Result<(Arc<McpConnection>, Self, McpDiscoverySnapshot), McpError>
Trait Implementations§
Source§impl CapabilityProvider for McpCapabilityProvider
impl CapabilityProvider for McpCapabilityProvider
Auto Trait Implementations§
impl Freeze for McpCapabilityProvider
impl !RefUnwindSafe for McpCapabilityProvider
impl Send for McpCapabilityProvider
impl Sync for McpCapabilityProvider
impl Unpin for McpCapabilityProvider
impl UnsafeUnpin for McpCapabilityProvider
impl !UnwindSafe for McpCapabilityProvider
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
Mutably borrows from an owned value. Read more