pub mod json_rpc;
pub mod messages;
pub mod resources;
pub mod prompts;
pub mod tools;
pub mod sampling;
pub mod annotations;
pub mod logging;
pub mod completion;
pub mod roots;
use serde::{Deserialize, Serialize};
pub const LATEST_PROTOCOL_VERSION: &str = "2025-03-26";
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Implementation {
pub name: String,
pub version: String,
}
impl Implementation {
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self {
Self {
name: name.into(),
version: version.into(),
}
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "lowercase")]
pub enum Role {
User,
Assistant,
}
pub type Cursor = String;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum ProgressToken {
String(String),
Integer(i64),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(untagged)]
pub enum RequestId {
String(String),
Integer(i64),
}
impl From<String> for RequestId {
fn from(s: String) -> Self {
Self::String(s)
}
}
impl From<&str> for RequestId {
fn from(s: &str) -> Self {
Self::String(s.to_owned())
}
}
impl From<i64> for RequestId {
fn from(i: i64) -> Self {
Self::Integer(i)
}
}
impl From<i32> for RequestId {
fn from(i: i32) -> Self {
Self::Integer(i as i64)
}
}
impl From<u32> for RequestId {
fn from(i: u32) -> Self {
Self::Integer(i as i64)
}
}
pub use self::annotations::Annotations;
pub use self::json_rpc::{JSONRPCMessage, JSONRPCRequest, JSONRPCResponse, JSONRPCError, JSONRPCNotification};
pub use self::messages::{Request, Notification, Result as MessageResult};
pub use self::resources::{Resource, ResourceTemplate, ResourceContents, TextResourceContents, BlobResourceContents};
pub use self::prompts::{Prompt, PromptArgument, PromptMessage};
pub use self::tools::{Tool, ToolAnnotations};
pub use self::sampling::{SamplingMessage, TextContent, ImageContent, AudioContent};