feat(mcp): cap MCP batch tool at MAX_BATCH_OPERATIONS (PRJ-22)

- enforce the same 100-operation cap the HTTP /batch endpoint enforces;
  over-cap \x60calls\x60 reject with a structured INVALID_INPUT (retryable:
  false, matching CallError::invalid_input) before any dispatch
- hoist MAX_BATCH_OPERATIONS to gateway/mod.rs and reuse it in routes,
  to_openapi (removing a pre-existing duplicate literal), and to_mcp
- state the limit in the batch tool description and add maxItems to the
  input schema (doc previously advertised no limit)
- GatewayDispatch gains a per-instance invoke_count spy accessor so the
  over-cap test proves zero dispatches (process-global counters raced
  under the parallel test runner)
- tests: over-cap -> INVALID_INPUT + invoke_count()==0; at-cap -> 100
  results + invoke_count()==100

verification: scripts/verify.sh (352 passed) and scripts/verify.sh
--all-features (468 passed); cargo clippy --all-targets -D warnings and
cargo fmt --check clean
This commit is contained in:
2026-08-30 22:51:06 +00:00
parent 8261fefd8f
commit 4f644a4c2c
5 changed files with 101 additions and 6 deletions
+1 -1
View File
@@ -45,12 +45,12 @@ use serde_json::{json, Value};
use super::dispatch::GatewayDispatch;
use super::error::call_error_to_http_response_with_identity;
use super::schema_cache::{CompileFailed, PublishSchemaCache};
use super::MAX_BATCH_OPERATIONS;
use crate::server::auth::ResolvedIdentity;
use crate::server::state::RouterState;
const SERVICES_LIST: &str = "services/list";
const SERVICES_SCHEMA: &str = "services/schema";
const MAX_BATCH_OPERATIONS: usize = 100;
const MAX_PUBLISH_LINE_BYTES: usize = 2 * 1024 * 1024;
/// The explicit request-body limit for the whole gateway router