[mcp] Support MCP Apps part 1. (#16082)

- [x] Add `mcpResource/read` method to read mcp resource.
This commit is contained in:
Matthew Zeng
2026-04-06 19:17:14 -07:00
committed by GitHub
parent ee12772e80
commit 5fe9ef06ce
20 changed files with 754 additions and 2 deletions

View File

@@ -82,6 +82,38 @@ pub struct Resource {
pub meta: Option<serde_json::Value>,
}
/// Contents returned when reading a resource from an MCP server.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, TS)]
#[serde(untagged)]
pub enum ResourceContent {
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Text {
/// The URI of this resource.
uri: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
mime_type: Option<String>,
text: String,
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
meta: Option<serde_json::Value>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Blob {
/// The URI of this resource.
uri: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
mime_type: Option<String>,
blob: String,
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
meta: Option<serde_json::Value>,
},
}
/// A template description for resources available on the server.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]