feat!: add SEP-2243 HTTP standard headers (#907)
* feat: add SEP-2243 HTTP standard headers * feat!: validate Mcp-Param-* headers on server * fix: emit Mcp-Method on reinit initialized POST * fix: align header mismatch error code with draft spec * chore: remove redundant streamable HTTP client comments
This commit is contained in:
parent
60d3e77f52
commit
11f525c503
1 changed files with 1183 additions and 40 deletions
|
|
@ -168,6 +168,9 @@ impl ProtocolVersion {
|
|||
pub const V_2024_11_05: Self = Self(Cow::Borrowed("2024-11-05"));
|
||||
pub const LATEST: Self = Self::V_2025_11_25;
|
||||
|
||||
/// First protocol version that requires SEP-2243 standard HTTP headers.
|
||||
pub const STANDARD_HEADERS: Self = Self::V_2026_07_28;
|
||||
|
||||
/// All protocol versions known to this SDK.
|
||||
pub const KNOWN_VERSIONS: &[Self] = &[
|
||||
Self::V_2024_11_05,
|
||||
|
|
@ -512,6 +515,7 @@ pub struct JsonRpcNotification<N = Notification> {
|
|||
pub struct ErrorCode(pub i32);
|
||||
|
||||
impl ErrorCode {
|
||||
pub const HEADER_MISMATCH: Self = Self(-32020);
|
||||
pub const RESOURCE_NOT_FOUND: Self = Self(-32002);
|
||||
pub const INVALID_REQUEST: Self = Self(-32600);
|
||||
pub const METHOD_NOT_FOUND: Self = Self(-32601);
|
||||
|
|
@ -557,7 +561,9 @@ impl ErrorData {
|
|||
pub fn resource_not_found(message: impl Into<Cow<'static, str>>, data: Option<Value>) -> Self {
|
||||
Self::new(ErrorCode::RESOURCE_NOT_FOUND, message, data)
|
||||
}
|
||||
|
||||
pub fn header_mismatch(message: impl Into<Cow<'static, str>>, data: Option<Value>) -> Self {
|
||||
Self::new(ErrorCode::HEADER_MISMATCH, message, data)
|
||||
}
|
||||
pub fn parse_error(message: impl Into<Cow<'static, str>>, data: Option<Value>) -> Self {
|
||||
Self::new(ErrorCode::PARSE_ERROR, message, data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue