Skip to main content

McpClient

Struct McpClient 

Source
pub struct McpClient { /* private fields */ }

Implementations§

Source§

impl McpClient

Source

pub fn new(config: McpClientConfig) -> Self

Create a new MCP client from the configuration.

Source

pub fn with_sandbox_context( config: McpClientConfig, sandbox_context: Option<McpSandboxContext>, ) -> Self

Create an MCP client with an optional inherited stdio sandbox context.

Source

pub fn set_elicitation_handler( &mut self, handler: Arc<dyn McpElicitationHandler>, )

Register a handler used to satisfy elicitation requests from providers.

Source

pub async fn initialize(&mut self) -> Result<()>

Establish connections to all configured providers and complete the MCP handshake.

Source

pub fn update_allowlist(&self, allowlist: McpAllowListConfig)

Refresh the internal allow list at runtime.

Source

pub fn current_allowlist(&self) -> McpAllowListConfig

Current allow list snapshot.

Source

pub fn provider_for_tool(&self, tool_name: &str) -> Option<String>

Return the provider name serving the given tool if previously cached.

Source

pub fn provider_for_resource(&self, uri: &str) -> Option<String>

Return the provider responsible for the given resource URI if known.

Source

pub fn provider_for_prompt(&self, prompt_name: &str) -> Option<String>

Return the provider that exposes the given prompt if known.

Source

pub async fn execute_tool(&self, tool_name: &str, args: Value) -> Result<Value>

Execute a tool call on the appropriate provider.

Source

pub async fn list_tools(&self) -> Result<Vec<McpToolInfo>>

List all tools from all active providers.

Source

pub async fn list_resources(&self) -> Result<Vec<McpResourceInfo>>

List all resources exposed by connected MCP providers.

Source

pub async fn refresh_resources(&self) -> Result<Vec<McpResourceInfo>>

Force refresh and list resources from providers.

Source

pub async fn list_prompts(&self) -> Result<Vec<McpPromptInfo>>

List all prompts advertised by connected MCP providers.

Source

pub async fn refresh_prompts(&self) -> Result<Vec<McpPromptInfo>>

Force refresh and list prompts from providers.

Source

pub async fn read_resource(&self, uri: &str) -> Result<McpResourceData>

Read a single resource from its originating provider.

Source

pub async fn get_prompt( &self, prompt_name: &str, arguments: Option<HashMap<String, String>>, ) -> Result<McpPromptDetail>

Retrieve a rendered prompt from its originating provider.

Source

pub async fn shutdown(&self) -> Result<()>

Shutdown all active provider connections.

Source

pub fn get_status(&self) -> McpClientStatus

Current status snapshot for UI/debugging purposes.

Source

pub async fn list_servers(&self) -> Vec<Value>

Return configured MCP servers and their current connection state.

Connected servers additionally report the protocol version settled during the handshake (negotiated_protocol_version), which may differ from the configured version when the server negotiates down.

Source

pub fn allow_model_lifecycle_control(&self) -> bool

Return whether model-callable lifecycle tools are enabled by config.

Source

pub async fn connect_server(&self, server_name: &str) -> Result<()>

Connect one configured MCP server by name.

Source

pub async fn disconnect_server(&self, server_name: &str) -> Result<()>

Disconnect one active MCP server by name.

Source

pub async fn sync_tools_to_files( &self, workspace_root: &Path, ) -> Result<(PathBuf, usize)>

Sync MCP tool descriptions to files for dynamic context discovery

This implements Cursor-style dynamic context discovery:

  • Tool descriptions are written to .vtcode/mcp/tools/{provider}/{tool}.md
  • Status is written to .vtcode/mcp/status.json
  • Agents can discover tools via grep/read_file without loading all schemas

Returns the paths to written files (index path, tool count)

Trait Implementations§

Source§

impl McpToolExecutor for McpClient

Source§

fn execute_mcp_tool<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tool_name: &'life1 str, args: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn list_mcp_tools<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<McpToolInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn has_mcp_tool<'life0, 'life1, 'async_trait>( &'life0 self, tool_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn get_status(&self) -> McpClientStatus

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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
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