ultrafast_mcp_sequential_thinking/
lib.rs

1//! # UltraFast MCP Sequential Thinking
2//!
3//! High-performance, Rust-based Model Context Protocol (MCP) server and client implementation
4//! for sequential thinking, built on the UltraFast MCP framework.
5//!
6//! This library provides a complete implementation of the sequential thinking concept,
7//! offering significant performance advantages over the official TypeScript version
8//! while maintaining full compatibility with the MCP 2025-06-18 specification.
9//!
10//! ## Features
11//!
12//! - **Dynamic Problem Breakdown**: Break complex problems into manageable steps
13//! - **Reflective Thinking**: Revise and refine thoughts as understanding deepens
14//! - **Branching Logic**: Explore alternative paths of reasoning
15//! - **Adaptive Planning**: Adjust the total number of thoughts dynamically
16//! - **Solution Verification**: Generate and verify solution hypotheses
17//! - **Context Preservation**: Maintain thinking context across multiple steps
18//! - **High Performance**: 10-100x faster than TypeScript implementation
19//! - **Type Safety**: Compile-time guarantees for protocol compliance
20//!
21//! ## Quick Start
22//!
23//! This crate provides a high-performance, type-safe Rust implementation of the Model Context Protocol (MCP) for sequential thinking. It enables you to break down complex problems into steps, track progress, and manage sessions programmatically.
24//!
25//! ### Example: Start a Session, Add a Thought, and Complete
26//!
27//! ```rust,no_run
28//! use ultrafast_mcp_sequential_thinking::{SequentialThinkingClient, ThoughtData};
29//!
30//! #[tokio::main]
31//! async fn main() -> anyhow::Result<()> {
32//!     // Create a client connected to the server
33//!     let client = SequentialThinkingClient::new("http://localhost:8080").await?;
34//!
35//!     // Start a new thinking session
36//!     let session = client.start_session("Solve a complex problem".to_string()).await?;
37//!
38//!     // Add a thought to the session
39//!     client.add_thought(&session.session_id, ThoughtData {
40//!         thought: "First, I need to understand the problem scope".to_string(),
41//!         thought_number: 1,
42//!         total_thoughts: 5,
43//!         next_thought_needed: true,
44//!         ..Default::default()
45//!     }).await?;
46//!
47//!     // Mark the session as complete
48//!     client.complete_session(&session.session_id).await?;
49//!
50//!     Ok(())
51//! }
52//! ```
53//!
54//! See the crate documentation and module docs for more details and advanced usage.
55
56pub mod analytics;
57pub mod config;
58pub mod export;
59pub mod session;
60pub mod thinking;
61
62// Re-export main types for convenience
63pub use session::{SessionManager, SessionMetadata, ThinkingSession};
64pub use thinking::{ThinkingEngine, ThoughtData, ThoughtProcessor};
65
66// Re-export client and server types
67pub use crate::thinking::client::SequentialThinkingClient;
68pub use crate::thinking::server::SequentialThinkingServer;
69
70// Re-export error types
71pub use crate::thinking::error::{SequentialThinkingError, SequentialThinkingResult};
72
73// Re-export configuration types
74pub use crate::config::{ClientConfig, ServerConfig, ThinkingConfig};
75
76// Re-export analytics types
77pub use crate::analytics::{AnalyticsEngine, SessionAnalytics};
78pub use crate::thinking::ThinkingStats;
79
80// Re-export export types
81pub use crate::export::{ExportEngine, ExportFormat, ExportOptions};
82
83/// Result type for sequential thinking operations
84pub type Result<T> = std::result::Result<T, SequentialThinkingError>;
85
86/// Default configuration for the sequential thinking server
87pub fn default_server_config() -> ServerConfig {
88    ServerConfig {
89        name: "ultrafast-sequential-thinking".to_string(),
90        version: env!("CARGO_PKG_VERSION").to_string(),
91        transport: "stdio".to_string(),
92        port: 8080,
93        thinking: ThinkingConfig::default(),
94        export: config::ExportConfig::default(),
95        analytics: config::AnalyticsConfig::default(),
96        logging: config::LoggingConfig::default(),
97        security: config::SecurityConfig::default(),
98    }
99}
100
101/// Default configuration for the sequential thinking client
102pub fn default_client_config() -> ClientConfig {
103    ClientConfig {
104        server_url: "stdio://".to_string(),
105        timeout_seconds: 30,
106        retry_attempts: 3,
107        thinking: thinking::client::ClientThinkingConfig::default(),
108        connection: config::ConnectionConfig::default(),
109        ui: config::UIConfig::default(),
110    }
111}
112
113#[cfg(test)]
114mod tests {
115    use super::*;
116
117    #[test]
118    fn test_default_configs() {
119        let server_config = default_server_config();
120        assert_eq!(server_config.name, "ultrafast-sequential-thinking");
121        assert_eq!(server_config.transport, "stdio");
122
123        let client_config = default_client_config();
124        assert_eq!(client_config.server_url, "stdio://");
125        assert_eq!(client_config.timeout_seconds, 30);
126    }
127}