G: F5 document the MCP stream and session delete
This commit is contained in:
1 parent
abd5b12cd0
commit
a1117da01d
4 files changed
+183
-8
No files matched your search
+65
-1
@@ -62,6 +62,8 @@ pub const BEARER_SCHEME: &str = "bearer_auth";
|
||||
crate::api::peers::pass,
|
||||
crate::api::openapi_json,
|
||||
mcp_endpoint,
|
||||
mcp_stream,
|
||||
mcp_delete_session,
|
||||
),
|
||||
components(schemas(
|
||||
crate::api::peers::PeerList,
|
||||
@@ -178,6 +180,61 @@ fn build(peers: bool) -> OpenApi {
|
||||
)]
|
||||
pub fn mcp_endpoint() {}
|
||||
|
||||
/// `GET /mcp` in the default session mode: the standalone SSE stream for
|
||||
/// server-to-client messages. rmcp serves it, so there is no axum handler to
|
||||
/// annotate.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/mcp",
|
||||
operation_id = "mcp_stream",
|
||||
tag = "mcp",
|
||||
summary = "MCP server-to-client stream",
|
||||
description = "Standalone `text/event-stream` for messages the server sends outside a request. \
|
||||
The default session mode requires the `Mcp-Session-Id` returned by `initialize`; \
|
||||
an unknown or terminated session is 404. Send `Accept: text/event-stream`.",
|
||||
params((
|
||||
"Mcp-Session-Id" = Option<String>,
|
||||
Header,
|
||||
description = "Session id returned by the `initialize` response"
|
||||
)),
|
||||
responses(
|
||||
(status = 200,
|
||||
description = "SSE stream of server-to-client messages",
|
||||
content_type = "text/event-stream"),
|
||||
(status = 400, description = "`Mcp-Session-Id` is missing or `Mcp-Protocol-Version` is invalid"),
|
||||
(status = 401, body = ErrorBody, description = "Missing or unknown bearer token"),
|
||||
(status = 403, description = "`Host` or `Origin` not allowed (DNS-rebinding guard)"),
|
||||
(status = 404, description = "Unknown or terminated session"),
|
||||
(status = 406, description = "`Accept` does not include `text/event-stream`"),
|
||||
(status = 503, body = ErrorBody, description = "The token database is unavailable"),
|
||||
)
|
||||
)]
|
||||
pub fn mcp_stream() {}
|
||||
|
||||
/// `DELETE /mcp`: ends a session in the default session mode.
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/mcp",
|
||||
operation_id = "mcp_delete_session",
|
||||
tag = "mcp",
|
||||
summary = "End an MCP session",
|
||||
description = "Closes the session named by `Mcp-Session-Id` and frees its in-memory state. \
|
||||
This ends an MCP session only; it never changes systemd, Docker or a peer.",
|
||||
params((
|
||||
"Mcp-Session-Id" = String,
|
||||
Header,
|
||||
description = "Session id returned by the `initialize` response"
|
||||
)),
|
||||
responses(
|
||||
(status = 202, description = "Session closed"),
|
||||
(status = 400, description = "`Mcp-Session-Id` is missing or `Mcp-Protocol-Version` is invalid"),
|
||||
(status = 401, body = ErrorBody, description = "Missing or unknown bearer token"),
|
||||
(status = 403, description = "`Host` or `Origin` not allowed (DNS-rebinding guard)"),
|
||||
(status = 503, body = ErrorBody, description = "The token database is unavailable"),
|
||||
)
|
||||
)]
|
||||
pub fn mcp_delete_session() {}
|
||||
|
||||
fn info() -> Info {
|
||||
InfoBuilder::new()
|
||||
.title("skyg-linux-tracker")
|
||||
@@ -793,12 +850,19 @@ mod tests {
|
||||
fn mcp_endpoint_is_documented_in_both_modes() {
|
||||
for peers in [false, true] {
|
||||
let doc = document(peers);
|
||||
let operation = &doc.paths.paths["/mcp"].post.as_ref().expect("POST /mcp");
|
||||
let item = &doc.paths.paths["/mcp"];
|
||||
let operation = item.post.as_ref().expect("POST /mcp");
|
||||
assert_eq!(operation.operation_id.as_deref(), Some("mcp"));
|
||||
let responses = serde_json::to_value(&operation.responses).unwrap();
|
||||
let content = responses["200"]["content"].as_object().unwrap();
|
||||
assert!(content.contains_key("application/json"));
|
||||
assert!(content.contains_key("text/event-stream"));
|
||||
// The default session mode also serves the standalone stream and
|
||||
// the session DELETE.
|
||||
let stream = item.get.as_ref().expect("GET /mcp");
|
||||
assert_eq!(stream.operation_id.as_deref(), Some("mcp_stream"));
|
||||
let delete = item.delete.as_ref().expect("DELETE /mcp");
|
||||
assert_eq!(delete.operation_id.as_deref(), Some("mcp_delete_session"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user