fix(epic3): принимать поток progress при JSON-first Accept официального SDK (Story 3.4, FR-14)
CI / UI Checks (pull_request) Successful in 10s
CI / Rust Checks (pull_request) Successful in 9m12s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Community Release / release (push) Successful in 24m39s
CI / UI Checks (pull_request) Successful in 10s
CI / Rust Checks (pull_request) Successful in 9m12s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Community Release / release (push) Successful in 24m39s
Официальный MCP SDK перечисляет медиатипы в `Accept` JSON-first (`application/json, text/event-stream`). Прежняя реализация выбирала negotiated JSON-тело, и клиент, которому нужен progress, не получал ни одного кадра. Коррекция переиспользует уже провалидированные шаги: для `tools/call` с допустимым progress token и предложенным event-stream режим ответа переключается на SSE. Admission/авторизация не двигались; другой метод, отсутствующий или непригодный token и JSON-only `Accept` сохраняют negotiated режим. ATDD: тот же JSON-first `Accept` даёт строго монотонные progress 1/2/3 и прежний result в обеих supported revisions, а негативные контроли (без token и с непригодным token) остаются на JSON-теле.
This commit is contained in:
1 parent
f613250fd3
commit
2499016dc7
2 files changed
+107
-3
No files matched your search
@@ -17,8 +17,8 @@ use crate::{
|
||||
rate_limit::{rate_limited_jsonrpc_response, rate_limited_status_response},
|
||||
request_context::RequestContext,
|
||||
transport::{
|
||||
accepts_event_stream, negotiate_post_response_mode, session_id_from_headers, sse_response,
|
||||
transport_response, validate_get_accept_header, validate_origin,
|
||||
ResponseMode, accepts_event_stream, negotiate_post_response_mode, session_id_from_headers,
|
||||
sse_response, transport_response, validate_get_accept_header, validate_origin,
|
||||
validate_session_protocol_version, with_request_id_header,
|
||||
},
|
||||
};
|
||||
@@ -256,7 +256,7 @@ async fn mcp_post_response(
|
||||
return status.into_response();
|
||||
}
|
||||
|
||||
let response_mode = match negotiate_post_response_mode(headers) {
|
||||
let mut response_mode = match negotiate_post_response_mode(headers) {
|
||||
Ok(mode) => mode,
|
||||
Err(status) => return status.into_response(),
|
||||
};
|
||||
@@ -365,6 +365,19 @@ async fn mcp_post_response(
|
||||
Err(error) => return error.into_response(),
|
||||
};
|
||||
|
||||
// Story 3.4 correction: the official SDK lists the media types JSON-first. For a `tools/call`
|
||||
// that carries a validated progress token and offered `text/event-stream`, the stream is the only
|
||||
// carrier that can deliver the progress the client asked for, so the media-type order is not a
|
||||
// preference for the JSON body here. Every other request — another method, no token, an unusable
|
||||
// token, a JSON-only `Accept` — keeps the negotiated mode, and no admission check moved.
|
||||
if matches!(response_mode, ResponseMode::Json)
|
||||
&& method_name(message) == Some("tools/call")
|
||||
&& accepts_event_stream(headers)
|
||||
&& crate::app::lifecycle::token_from_meta(message.pointer("/params/_meta")).is_some()
|
||||
{
|
||||
response_mode = ResponseMode::Sse;
|
||||
}
|
||||
|
||||
if matches!(identity.era, RequestEra::Modern) {
|
||||
// ERA_MODERN_ENTER (spec section 7.2): this request entered the modern era-adapter.
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user