pmcp/shared/
mod.rs

1//! Shared components used by both client and server.
2
3pub mod batch;
4pub mod context;
5pub mod event_store;
6pub mod logging;
7pub mod middleware;
8pub mod protocol;
9pub mod protocol_helpers;
10#[cfg(not(target_arch = "wasm32"))]
11pub mod reconnect;
12pub mod session;
13pub mod sse_parser;
14#[cfg(not(target_arch = "wasm32"))]
15pub mod stdio;
16pub mod transport;
17pub mod uri_template;
18
19// Cross-platform runtime abstraction
20pub mod runtime;
21
22// Platform-specific WebSocket modules
23#[cfg(all(feature = "websocket", not(target_arch = "wasm32")))]
24pub mod websocket;
25
26#[cfg(all(feature = "websocket-wasm", target_arch = "wasm32"))]
27pub mod wasm_websocket;
28
29#[cfg(target_arch = "wasm32")]
30pub mod wasm_http;
31
32#[cfg(all(feature = "http", not(target_arch = "wasm32")))]
33pub mod http;
34pub mod http_constants;
35
36#[cfg(all(feature = "streamable-http", not(target_arch = "wasm32")))]
37/// Streamable HTTP transport implementation for MCP.
38pub mod streamable_http;
39
40// Re-export commonly used types
41pub use batch::{BatchRequest, BatchResponse};
42pub use context::{ClientInfo, ContextPropagator, RequestContext};
43pub use event_store::{
44    EventStore, EventStoreConfig, InMemoryEventStore, MessageDirection, ResumptionManager,
45    ResumptionState, ResumptionToken, StoredEvent,
46};
47#[cfg(not(target_arch = "wasm32"))]
48pub use logging::init_logging;
49pub use logging::{CorrelatedLogger, LogConfig, LogEntry, LogFormat, LogLevel};
50pub use middleware::{
51    AuthMiddleware, LoggingMiddleware, Middleware, MiddlewareChain, RetryMiddleware,
52};
53pub use protocol::{ProgressCallback, Protocol, ProtocolOptions, RequestOptions};
54pub use protocol_helpers::{
55    create_notification, create_request, parse_notification, parse_request,
56};
57#[cfg(not(target_arch = "wasm32"))]
58pub use reconnect::{ReconnectConfig, ReconnectGuard, ReconnectManager};
59pub use session::{Session, SessionConfig, SessionManager};
60#[cfg(not(target_arch = "wasm32"))]
61pub use stdio::StdioTransport;
62pub use transport::{Transport, TransportMessage};
63pub use uri_template::UriTemplate;
64
65#[cfg(all(feature = "websocket", not(target_arch = "wasm32")))]
66pub use websocket::{WebSocketConfig, WebSocketTransport};
67
68#[cfg(all(feature = "websocket-wasm", target_arch = "wasm32"))]
69pub use wasm_websocket::{WasmWebSocketConfig, WasmWebSocketTransport};
70
71#[cfg(target_arch = "wasm32")]
72pub use wasm_http::{WasmHttpClient, WasmHttpConfig, WasmHttpTransport};
73
74#[cfg(all(feature = "http", not(target_arch = "wasm32")))]
75pub use http::{HttpConfig, HttpTransport};
76
77#[cfg(all(feature = "streamable-http", not(target_arch = "wasm32")))]
78pub use streamable_http::{StreamableHttpTransport, StreamableHttpTransportConfig};