mcp_probe_core/
lib.rs

1//! # MCP Core Library
2//!
3//! `mcp-core` provides the foundational types, traits, and implementations for the
4//! Model Context Protocol (MCP). This crate is the core building block for MCP
5//! clients and debugging tools.
6//!
7//! ## Features
8//!
9//! - **Complete MCP Message Types**: All JSON-RPC message structures defined by the MCP specification
10//! - **Transport Abstraction**: Unified interface for stdio, HTTP+SSE, and HTTP streaming transports  
11//! - **Type-Safe Configuration**: Compile-time validated configuration for all transport types
12//! - **Comprehensive Error Handling**: Structured error types for all failure modes
13//! - **Async-First Design**: Built on tokio for high-performance async I/O
14//! - **High-Level Client**: Ready-to-use MCP client with protocol handling
15//!
16//! ## Quick Start
17//!
18//! ```rust,no_run
19//! use mcp_probe_core::{
20//!     client::{McpClient, ClientConfig},
21//!     transport::TransportConfig,
22//!     messages::Implementation,
23//! };
24//!
25//! #[tokio::main]
26//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
27//!     // Configure a stdio transport
28//!     let config = TransportConfig::stdio("python", &["server.py"]);
29//!     
30//!     // Create and connect client
31//!     let mut client = McpClient::with_defaults(config).await?;
32//!     
33//!     let client_info = Implementation {
34//!         name: "mcp-probe".to_string(),
35//!         version: "0.1.0".to_string(),
36//!         metadata: std::collections::HashMap::new(),
37//!     };
38//!     
39//!     let server_info = client.connect(client_info).await?;
40//!     println!("Connected to: {}", server_info.implementation.name);
41//!     
42//!     Ok(())
43//! }
44//! ```
45//!
46//! ## Architecture
47//!
48//! The library is organized into several key modules:
49//!
50//! - [`error`]: Comprehensive error types for all MCP operations
51//! - [`messages`]: Complete MCP message type definitions  
52//! - [`transport`]: Transport abstraction and implementations
53//! - [`client`]: High-level MCP client interface
54//!
55//! ## Transport Support
56//!
57//! This crate supports all three MCP transport mechanisms:
58//!
59//! - **stdio**: Local process communication (enabled by default)
60//! - **http-sse**: HTTP + Server-Sent Events (enabled by default)  
61//! - **http-stream**: Full-duplex HTTP streaming (enabled by default)
62//!
63//! Transport support can be controlled via feature flags.
64
65#![warn(missing_docs)]
66#![warn(clippy::all)]
67#![allow(clippy::module_name_repetitions)]
68
69pub mod client;
70pub mod error;
71pub mod messages;
72pub mod transport;
73pub mod validation;
74
75// Re-export commonly used types for convenience
76pub use client::{ClientConfig, ClientState, ClientStats, McpClient, ServerInfo};
77pub use error::{McpError, McpResult};
78pub use messages::{
79    Capabilities, Implementation, InitializeRequest, InitializeResponse, InitializedNotification,
80    JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, ProtocolVersion,
81};
82pub use transport::{Transport, TransportConfig, TransportFactory, TransportInfo};
83
84/// Current version of the mcp-core library
85pub const VERSION: &str = env!("CARGO_PKG_VERSION");
86
87/// Current MCP protocol version supported by this library
88pub const PROTOCOL_VERSION: &str = "2024-11-05";