1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//! # MCP Server Framework
//!
//! A production-ready Rust framework for building Model Context Protocol (MCP) servers.
//! Provides zero-configuration setup, comprehensive MCP 2025-11-25 specification support,
//! and multiple deployment targets including HTTP, AWS Lambda, and local development.
//!
//! [](https://crates.io/crates/turul-mcp-server)
//! [](https://docs.rs/turul-mcp-server)
//! [](https://github.com/aussierobots/turul-mcp-framework/blob/main/LICENSE)
//!
//! ## Features
//!
//! - **Zero Configuration**: Framework auto-determines method strings from types
//! - **Type-Safe Error Handling**: Clean domain/protocol separation
//! - **4 Tool Creation Levels**: Function macros → derive macros → builders → manual
//! - **Multiple Transports**: HTTP, Server-Sent Events (SSE), AWS Lambda
//! - **Pluggable Storage**: InMemory, SQLite, PostgreSQL, DynamoDB
//! - **Real-time Streaming**: SSE notifications for progress and logging
//! - **Production Ready**: Comprehensive testing, monitoring, and deployment support
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! turul-mcp-server = "0.3"
//! turul-mcp-derive = "0.3" # For macros
//! tokio = { version = "1.0", features = ["full"] }
//! ```
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! # use turul_mcp_server::prelude::*;
//! #
//! # async fn example() -> McpResult<()> {
//! // Create a basic MCP server with detailed configuration
//! let server = McpServer::builder()
//! .name("calculator-server")
//! .version("1.0.0")
//! .title("Advanced Calculator Server")
//! .instructions("A production-grade calculator server supporting basic arithmetic operations including addition, subtraction, multiplication, and division. Use the available tools to perform calculations. The server maintains session state for calculation history, supports real-time notifications for long-running computations, and provides detailed error reporting for invalid operations.")
//! .build()?;
//!
//! server.run().await
//! # }
//! ```
//!
//! ## Architecture
//!
//! The framework uses **clean domain/protocol separation**:
//!
//! - **Domain Layer**: Tools return `McpResult<T>` with domain errors
//! - **Protocol Layer**: Framework converts to JSON-RPC 2.0 automatically
//! - **Transport Layer**: HTTP/SSE with session-aware error handling
//! - **Storage Layer**: Pluggable backends (InMemory, SQLite, PostgreSQL, DynamoDB)
//!
//! ## Examples
//!
//! **Complete working examples available at:**
//! [github.com/aussierobots/turul-mcp-framework/tree/main/examples](https://github.com/aussierobots/turul-mcp-framework/tree/main/examples)
//!
//! - **Minimal Server** - Basic tool setup
//! - **Calculator** - Math operations with error handling
//! - **HTTP Server** - Production HTTP deployment
//! - **AWS Lambda** - Serverless deployment
//! - **Real-time Streaming** - SSE notifications
//! - **Database Integration** - SQLite/PostgreSQL/DynamoDB
//!
//! ## Deployment Options
//!
//! ### Local Development
//! ```bash
//! cargo run --example minimal-server
//! # Server runs on http://localhost:8080/mcp
//! ```
//!
//! ### AWS Lambda
//! ```bash
//! cargo lambda build --release
//! cargo lambda deploy --iam-role arn:aws:iam::...
//! ```
//!
//! ### Docker
//! ```dockerfile
//! FROM rust:1.70 as builder
//! COPY . .
//! RUN cargo build --release
//!
//! FROM debian:bookworm-slim
//! COPY --from=builder /target/release/my-mcp-server /usr/local/bin/
//! EXPOSE 8080
//! CMD ["my-mcp-server"]
//! ```
//!
//! ## Configuration
//!
//! The framework supports extensive configuration through the builder pattern:
//!
//! ```rust,no_run
//! # use turul_mcp_server::prelude::*;
//! # use turul_mcp_session_storage::SqliteSessionStorage;
//! # use std::time::Duration;
//! #
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let server = McpServer::builder()
//! .name("production-server")
//! .version("1.0.0")
//! .title("Production MCP Server")
//! .instructions("This production server provides tools for database operations, file management, and API integrations. Use the 'database/query' tool for SQL operations, 'files/read' for file access, and 'api/call' for external service integration. Session management is enabled with SQLite persistence for reliability.")
//! .with_session_storage(std::sync::Arc::new(SqliteSessionStorage::new().await?))
//! .build()?;
//! # Ok(())
//! # }
//! ```
// Re-export session storage from separate crate (breaks circular dependency)
pub use turul_mcp_session_storage as session_storage;
// Re-export task storage from separate crate
pub use turul_mcp_task_storage as task_storage;
// Re-export main types
/// Builder for creating MCP servers with fluent API
pub use McpServerBuilder;
/// Cancellation handle for cooperative task cancellation
pub use CancellationHandle;
/// Completion provider for text generation requests
pub use McpCompletion;
/// Request dispatching and middleware support for MCP operations
pub use ;
/// Elicitation handler for interactive form-based data collection
pub use McpElicitation;
/// Collection of built-in MCP request handlers
pub use *;
/// Logging provider for structured application logs
pub use McpLogger;
/// Notification system for real-time client updates via SSE
pub use McpNotification;
/// Prompt provider for generating conversation templates
pub use McpPrompt;
/// Resource provider for serving file-like content with URI templates
pub use McpResource;
/// Root provider for workspace and project context
pub use McpRoot;
/// Sampling configuration for LLM inference parameters
pub use McpSampling;
/// Security middleware and access control components
pub use ;
/// Core MCP server and session-aware handlers
pub use ;
/// Session management and context for stateful operations
pub use ;
/// Task executor abstraction for pluggable execution backends
pub use ;
/// Task handlers for tasks/get, tasks/list, tasks/cancel, tasks/result
pub use ;
/// Task runtime for managing long-running operations
pub use TaskRuntime;
/// Default Tokio-based task executor
pub use TokioTaskExecutor;
/// Tool trait for executable MCP functions
pub use McpTool;
/// SessionView trait for middleware - re-exported from turul-mcp-session-storage
pub use SessionView;
// Re-export foundational types
/// JSON-RPC 2.0 request dispatcher and handler trait for protocol operations
pub use ;
/// Core MCP protocol types, errors, and specification compliance
pub use *;
// Re-export builder pattern for Level 3 tool creation
/// Dynamic tool creation with runtime configuration and type-safe builders
pub use ;
// Explicitly re-export error types for convenience
/// Domain error type for MCP operations with protocol conversion support
pub use ;
/// HTTP transport layer with SSE streaming and session management
pub use turul_http_mcp_server;
/// Result type for MCP server operations with domain-specific error handling
///
/// This alias provides structured error types that automatically convert to JSON-RPC 2.0
/// error responses when crossing the protocol boundary. Use this for all tool and handler
/// implementations to ensure consistent error reporting to MCP clients.
pub type McpResult<T> = McpResult;
/// Convenience alias for McpResult
pub type Result<T> = ;
/// Implements McpTool for DynamicTool to enable Level 3 builder pattern tool creation
///
/// This implementation bridges DynamicTool's builder pattern with the framework's
/// session-aware execution model, enabling runtime tool construction with type safety.