turul_mcp_json_rpc_server/
lib.rs

1//! # JSON-RPC 2.0 Server Implementation
2//! 
3//! A pure, transport-agnostic JSON-RPC 2.0 server implementation that follows the specification.
4//! This crate provides the core types and dispatch logic for JSON-RPC without any transport-specific code.
5//!
6//! ## Features
7//! - Full JSON-RPC 2.0 specification compliance
8//! - Transport agnostic (works with HTTP, WebSocket, TCP, etc.)
9//! - Async/await support with `async` feature
10//! - Comprehensive error handling
11//! - Support for notifications and requests
12
13pub mod error;
14pub mod request;
15pub mod response; 
16pub mod notification;
17pub mod dispatch;
18pub mod types;
19
20#[cfg(feature = "async")]
21pub mod r#async;
22
23// Re-export main types
24pub use error::{JsonRpcError, JsonRpcErrorCode};
25pub use request::{JsonRpcRequest, RequestParams};
26pub use response::{JsonRpcResponse, ResponseResult};
27pub use notification::JsonRpcNotification;
28pub use types::{RequestId, JsonRpcVersion};
29
30#[cfg(feature = "async")]
31pub use r#async::{JsonRpcHandler, JsonRpcDispatcher, SessionContext};
32
33/// JSON-RPC 2.0 version constant
34pub const JSONRPC_VERSION: &str = "2.0";
35
36/// Standard JSON-RPC 2.0 error codes
37pub mod error_codes {
38    pub const PARSE_ERROR: i64 = -32700;
39    pub const INVALID_REQUEST: i64 = -32600;
40    pub const METHOD_NOT_FOUND: i64 = -32601;
41    pub const INVALID_PARAMS: i64 = -32602;
42    pub const INTERNAL_ERROR: i64 = -32603;
43    
44    // Server error range: -32099 to -32000
45    pub const SERVER_ERROR_START: i64 = -32099;
46    pub const SERVER_ERROR_END: i64 = -32000;
47}