修复 AGC MCP 通知请求被拒导致 cc 执行器零工具
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 2m19s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m30s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m30s
Project CI / AI game creator shell Rust crates (push) Successful in 1m40s
Project CI / Backend tests (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled
Project CI / Frontend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled

- direct_tools_mcp:HTTP 入口对没有 id 的 JSON-RPC 通知(notifications/initialized)返回 202 空体,不再按错误回 400
- 之前 Claude Code 的 MCP 握手被 400 打断,把 agc 服务器标记为 failed,模型请求里一个工具都没有(实测 tools=0,修复后 tools=60)
This commit is contained in:
kdletters
2026-10-02 14:55:27 +08:00
parent 41f0c7aac3
commit 13ce49599f
@@ -2,6 +2,7 @@ use super::*;
use axum::extract::DefaultBodyLimit;
use axum::extract::State as AxumState;
use axum::http::{HeaderMap, StatusCode};
use axum::response::IntoResponse;
use axum::routing::post;
use axum::Json;
use axum::Router;
@@ -2090,7 +2091,7 @@ async fn handle_external_mcp_http_request(
AxumState(state): AxumState<ExternalMcpHttpState>,
headers: HeaderMap,
Json(request): Json<Value>,
) -> Result<Json<Value>, StatusCode> {
) -> Result<axum::response::Response, StatusCode> {
if !external_mcp_authorized(&headers, &state.token) {
return Err(StatusCode::UNAUTHORIZED);
}
@@ -2107,6 +2108,13 @@ async fn handle_external_mcp_http_request(
.in_flight
.try_acquire()
.map_err(|_| StatusCode::TOO_MANY_REQUESTS)?;
// JSON-RPC 通知(没有 `id`)没有响应体:MCP 客户端在 `initialize` 之后一定会发
// `notifications/initialized`,按错误回 400 会被判成握手失败,整个服务器就被标记
// 成 `failed`、一个工具都不广告(真实案例:2026-10-02 的 cc DirectProject 因此
// 拿到 0 个工具)。规范要求的应答是 202 Accepted(空体)。
if request.get("id").is_none() {
return Ok(StatusCode::ACCEPTED.into_response());
}
let response = EXTERNAL_MCP_BRIDGE_URL
.scope(
state.bridge_url.clone(),
@@ -2114,7 +2122,7 @@ async fn handle_external_mcp_http_request(
)
.await
.ok_or(StatusCode::BAD_REQUEST)?;
Ok(Json(response))
Ok(Json(response).into_response())
}
pub(crate) async fn start_external_mcp_loopback(