turbomcp_protocol/types/content.rs
1//! Message content types.
2//!
3//! The `ContentBlock` union + leaf content structs are canonically defined in
4//! [`turbomcp_types`] as of v3.2. `ContentBlock` is a type alias over
5//! [`turbomcp_types::Content`] so the two names refer to the same Rust type.
6//!
7//! # Content types
8//!
9//! - [`TextContent`], [`ImageContent`], [`AudioContent`] — inline content
10//! - [`ResourceLink`] — reference to an external resource
11//! - [`EmbeddedResource`] + [`ResourceContents`] (plural, `Text | Blob` union)
12//! - `ResourceContent` — backward-compatibility alias for [`ResourceContents`]
13//! - [`ContentType`] — `Json | Binary | Text` (turbomcp-internal; not MCP spec)
14
15use serde::{Deserialize, Serialize};
16
17pub use turbomcp_types::{
18 AudioContent, BlobResourceContents, Content, EmbeddedResource, ImageContent, ResourceContents,
19 ResourceLink, TextContent, TextResourceContents,
20};
21
22/// Backward-compatibility alias — canonical name is [`ResourceContents`].
23pub type ResourceContent = ResourceContents;
24
25/// Spec-aligned alias for the `ContentBlock` union per MCP 2025-11-25.
26///
27/// Canonical Rust name in [`turbomcp_types`] is `Content`; this alias
28/// surfaces the spec name. Both refer to the same type.
29pub type ContentBlock = Content;
30
31/// Content type enumeration (turbomcp-internal transport discriminator; not part of the MCP spec).
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
33#[serde(rename_all = "lowercase")]
34pub enum ContentType {
35 /// JSON content
36 Json,
37 /// Binary content
38 Binary,
39 /// Plain text content
40 Text,
41}