turul_mcp_protocol/
lib.rs

1//! # Model Context Protocol (MCP) - Current Version
2//!
3//! **The official Rust implementation of the Model Context Protocol specification.**
4//!
5//! This crate provides a stable API that aliases the current version of the MCP specification,
6//! ensuring your code stays up-to-date with the latest protocol version while maintaining
7//! compatibility. Currently implements **MCP 2025-06-18** specification.
8//!
9//! [![Crates.io](https://img.shields.io/crates/v/turul-mcp-protocol.svg)](https://crates.io/crates/turul-mcp-protocol)
10//! [![Documentation](https://docs.rs/turul-mcp-protocol/badge.svg)](https://docs.rs/turul-mcp-protocol)
11//! [![License](https://img.shields.io/crates/l/turul-mcp-protocol.svg)](https://github.com/aussierobots/turul-mcp-framework/blob/main/LICENSE)
12//!
13//! ## Installation
14//!
15//! ```toml
16//! [dependencies]
17//! turul-mcp-protocol = "0.2"
18//! ```
19//!
20//! ## Quick Start
21//!
22//! ```rust
23//! use turul_mcp_protocol::prelude::*;
24//!
25//! // Create tools, resources, prompts
26//! let tool = Tool::new("calculator", ToolSchema::object());
27//! let resource = Resource::new("file://data.json", "data");
28//! let prompt = Prompt::new("code_review");
29//!
30//! // Handle requests and responses
31//! let request = InitializeRequest::new(
32//!     McpVersion::CURRENT,
33//!     ClientCapabilities::default(),
34//!     Implementation::new("my-client", "1.0.0")
35//! );
36//! ```
37//!
38//! ## Protocol Types
39//!
40//! This crate provides all core MCP types:
41//!
42//! - **Tools**: `Tool`, `CallToolRequest`, `CallToolResult`
43//! - **Resources**: `Resource`, `ReadResourceRequest`, `ResourceContent`
44//! - **Prompts**: `Prompt`, `GetPromptRequest`, `PromptMessage`
45//! - **Notifications**: `ProgressNotification`, `LoggingMessage`
46//! - **Protocol**: `InitializeRequest`, `McpVersion`, `ServerCapabilities`
47//! - **Errors**: `McpError`, `JsonRpcError`, error codes
48//!
49//! ## Use Cases
50//!
51//! - **MCP Server Development**: Use with [`turul-mcp-server`](https://crates.io/crates/turul-mcp-server)
52//! - **MCP Client Development**: Use with [`turul-mcp-client`](https://crates.io/crates/turul-mcp-client)
53//! - **Protocol Parsing**: Direct protocol message handling
54//! - **Type Definitions**: Reference implementation for MCP types
55//!
56//! ## Related Crates
57//!
58//! - [`turul-mcp-server`](https://crates.io/crates/turul-mcp-server) - High-level server framework
59//! - [`turul-mcp-client`](https://crates.io/crates/turul-mcp-client) - Client library
60//! - [`turul-mcp-derive`](https://crates.io/crates/turul-mcp-derive) - Procedural macros
61//!
62//! ## Version Mapping
63//!
64//! | This Crate | MCP Spec | Implementation Crate |
65//! |------------|----------|---------------------|
66//! | `0.2.x` | `2025-06-18` | `turul-mcp-protocol-2025-06-18` |
67//!
68//! Currently aliases: `turul-mcp-protocol-2025-06-18`
69
70// Re-export the current MCP protocol version
71pub use turul_mcp_protocol_2025_06_18::*;
72
73// Explicitly re-export the prelude module for convenient imports
74pub mod prelude {
75    pub use turul_mcp_protocol_2025_06_18::prelude::*;
76}
77
78/// The current MCP protocol version implemented by this crate
79pub const CURRENT_VERSION: &str = MCP_VERSION;
80
81#[cfg(test)]
82mod tests {
83    use super::*;
84
85    #[test]
86    fn test_current_version() {
87        assert_eq!(CURRENT_VERSION, "2025-06-18");
88        assert_eq!(MCP_VERSION, "2025-06-18");
89    }
90
91    #[test]
92    fn test_version_parsing() {
93        let version = "2025-06-18".parse::<McpVersion>().unwrap();
94        assert_eq!(version, McpVersion::V2025_06_18);
95    }
96
97    #[test]
98    fn test_re_exports_work() {
99        // Test that we can create basic types
100        let _impl = Implementation::new("test", "1.0.0");
101        let _capabilities = ClientCapabilities::default();
102        let _tool = Tool::new("test", ToolSchema::object());
103
104        // If this compiles, the re-exports are working
105    }
106
107    #[test]
108    fn test_prelude_works() {
109        use crate::prelude::*;
110
111        // Test that prelude types are available
112        let _tool = Tool::new("test", ToolSchema::object());
113        let _resource = Resource::new("test://resource", "test_resource");
114        let _prompt = Prompt::new("test_prompt");
115        let _error = McpError::tool_execution("test error");
116
117        // If this compiles, the prelude is working
118    }
119}