mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-10-21 06:51:24 +02:00
feat: faster MCP browsing
This commit is contained in:
1 parent
1e75f179e1
commit
aec4870588
6 files changed
+975
-54
No files matched your search
@@ -1045,6 +1045,8 @@ impl ApiServer {
|
||||
.port();
|
||||
|
||||
let v1_routes = build_v1_router();
|
||||
#[cfg(feature = "e2e")]
|
||||
let v1_routes = v1_routes.route("/v1/e2e/mcp", axum::routing::post(e2e_mcp_message));
|
||||
|
||||
let api = ApiDoc::openapi();
|
||||
|
||||
@@ -1101,6 +1103,29 @@ impl ApiServer {
|
||||
}
|
||||
}
|
||||
|
||||
/// The suites' way into the MCP tool engine, which the app otherwise serves
|
||||
/// only over the remote bridge. Built into E2E builds only, never published.
|
||||
#[cfg(feature = "e2e")]
|
||||
async fn e2e_mcp_message(headers: HeaderMap, body: axum::body::Bytes) -> Response {
|
||||
use crate::mcp_server::{McpOutcome, McpServer};
|
||||
let session = headers
|
||||
.get("mcp-session-id")
|
||||
.and_then(|value| value.to_str().ok());
|
||||
match McpServer::instance()
|
||||
.handle_message_with(session, &body, None)
|
||||
.await
|
||||
{
|
||||
McpOutcome::Body {
|
||||
body,
|
||||
new_session_id,
|
||||
} => Json(serde_json::json!({ "session_id": new_session_id, "body": body })).into_response(),
|
||||
McpOutcome::Accepted => StatusCode::ACCEPTED.into_response(),
|
||||
McpOutcome::UnknownSession => StatusCode::NOT_FOUND.into_response(),
|
||||
McpOutcome::BadRequest => StatusCode::BAD_REQUEST.into_response(),
|
||||
McpOutcome::RateLimited { .. } => StatusCode::TOO_MANY_REQUESTS.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Register every `/v1` handler.
|
||||
///
|
||||
/// Pulled out of `start` so a test can build it. Axum panics when two handlers
|
||||
|
||||
Reference in new issue
Block a user