Skip to main content

vtcode_mcp/
types.rs

1//! Core MCP data types for tool, resource, and prompt information.
2
3use rmcp::model::{ElicitationAction, PromptArgument, PromptMessage, ResourceContents};
4use serde::{Deserialize, Serialize};
5use serde_json::{Map, Value};
6
7/// Information about an MCP tool exposed by a provider.
8#[derive(Debug, Clone)]
9pub struct McpToolInfo {
10    pub name: String,
11    pub description: String,
12    pub provider: String,
13    pub input_schema: Value,
14    /// Optional output schema (`outputSchema`), when the server advertises
15    /// the structure of the tool's result. Carried for discovery fidelity so
16    /// the Full detail level returns the complete definition; execution paths
17    /// treat it as advisory metadata.
18    pub output_schema: Option<Value>,
19}
20
21/// Summary of an MCP resource exposed by a provider.
22#[derive(Debug, Clone)]
23pub struct McpResourceInfo {
24    pub(crate) provider: String,
25    pub(crate) uri: String,
26    pub(crate) name: String,
27    pub(crate) description: Option<String>,
28    pub(crate) mime_type: Option<String>,
29    pub(crate) size: Option<i64>,
30}
31
32/// Resource contents fetched from an MCP provider.
33#[derive(Debug, Clone)]
34pub struct McpResourceData {
35    pub(crate) provider: String,
36    pub(crate) uri: String,
37    pub(crate) contents: Vec<ResourceContents>,
38    pub(crate) meta: Map<String, Value>,
39}
40
41/// Summary of an MCP prompt exposed by a provider.
42#[derive(Debug, Clone)]
43pub struct McpPromptInfo {
44    pub(crate) provider: String,
45    pub(crate) name: String,
46    pub(crate) description: Option<String>,
47    pub(crate) arguments: Vec<PromptArgument>,
48}
49
50/// Fully rendered MCP prompt ready for use.
51#[derive(Debug, Clone)]
52pub struct McpPromptDetail {
53    pub(crate) provider: String,
54    pub(crate) name: String,
55    pub(crate) description: Option<String>,
56    pub(crate) messages: Vec<PromptMessage>,
57    pub(crate) meta: Map<String, Value>,
58}
59
60/// Snapshot describing the MCP client at runtime.
61#[derive(Debug, Clone)]
62pub struct McpClientStatus {
63    pub enabled: bool,
64    pub provider_count: usize,
65    pub active_connections: usize,
66    pub configured_providers: Vec<String>,
67}
68
69/// Request payload for handling elicitation prompts from MCP providers.
70#[derive(Debug, Clone)]
71pub struct McpElicitationRequest {
72    pub message: String,
73    pub requested_schema: Value,
74    pub(crate) meta: Option<Value>,
75}
76
77/// Result returned by an elicitation handler after interacting with the user.
78#[derive(Debug, Clone)]
79pub struct McpElicitationResponse {
80    pub action: ElicitationAction,
81    pub content: Option<Value>,
82    pub meta: Option<Value>,
83}
84
85// === File Upload Types (PR #15197) ===
86
87/// Metadata key used in tool input schemas to indicate file upload parameters.
88pub const OPENAI_FILE_PARAMS_META_KEY: &str = "_meta";
89pub const OPENAI_FILE_PARAMS_VALUE: &str = "openai/fileParams";
90
91/// Shape of a file payload provided by the client after upload.
92///
93/// This is the object shape that MCP tools expecting file uploads expect to receive.
94/// The client uploads local files to the backend and replaces the local file path
95/// with this structure.
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct ProvidedFilePayload {
98    /// The file ID returned from the upload (maps to backend file reference)
99    #[serde(rename = "fileId")]
100    file_id: String,
101    /// The original file name
102    #[serde(rename = "fileName")]
103    file_name: String,
104    /// MIME type of the uploaded file
105    #[serde(rename = "mimeType")]
106    mime_type: String,
107    /// File size in bytes
108    #[serde(rename = "fileSize")]
109    file_size: i64,
110}
111
112/// Result of uploading a local file to the backend.
113#[derive(Debug, Clone)]
114pub struct FileUploadResult {
115    /// The file ID from the backend upload
116    file_id: String,
117    /// The payload to substitute in the tool call arguments
118    payload: ProvidedFilePayload,
119}
120
121/// Masked schema entry for a file parameter in a tool's input schema.
122///
123/// When a tool declares `_meta["openai/fileParams"]` in its input schema,
124/// we mask the raw file payload object and instead instruct the model to
125/// provide an absolute local file path. The client then handles the upload
126/// and argument rewriting transparently.
127#[derive(Debug, Clone, Serialize, Deserialize)]
128pub struct FileParamSchemaEntry {
129    /// The original property name in the tool's input schema
130    property_name: String,
131    /// Description shown to the model for this file parameter
132    description: String,
133    /// Whether this file parameter is required
134    required: bool,
135}