Skip to main content

vtcode_core/mcp/
traits.rs

1//! MCP trait abstractions for tool execution and elicitation handling.
2
3use super::types::{McpClientStatus, McpElicitationRequest, McpElicitationResponse, McpToolInfo};
4use anyhow::Result;
5use async_trait::async_trait;
6use serde_json::Value;
7
8/// Callback interface used to resolve elicitation requests from MCP providers.
9#[async_trait]
10pub trait McpElicitationHandler: Send + Sync {
11    async fn handle_elicitation(
12        &self,
13        provider: &str,
14        request: McpElicitationRequest,
15    ) -> Result<McpElicitationResponse>;
16}
17
18/// Trait abstraction used by the tool registry to talk to the MCP client.
19#[async_trait]
20pub trait McpToolExecutor: Send + Sync {
21    async fn execute_mcp_tool(&self, tool_name: &str, args: &Value) -> Result<Value>;
22    async fn list_mcp_tools(&self) -> Result<Vec<McpToolInfo>>;
23    async fn has_mcp_tool(&self, tool_name: &str) -> Result<bool>;
24    fn get_status(&self) -> McpClientStatus;
25}