Omit the raw plan byte array from every MCP plan result
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -219,6 +219,13 @@ fn tools() -> Vec<Tool> {
|
||||
),
|
||||
]
|
||||
}
|
||||
/// The WebUI compares the raw signed plan bytes; MCP returns plan_payload and plan_hash.
|
||||
fn without_raw_plan_bytes(mut view: Value) -> Value {
|
||||
if let Some(map) = view.as_object_mut() {
|
||||
map.remove("plan_payload_bytes");
|
||||
}
|
||||
view
|
||||
}
|
||||
fn parse<T: serde::de::DeserializeOwned>(v: Value) -> Result<T, crate::jobs::Error> {
|
||||
serde_json::from_value(v).map_err(Into::into)
|
||||
}
|
||||
@@ -326,6 +333,7 @@ impl Adapter {
|
||||
let i: PlanScript = parse(args)?;
|
||||
crate::script_library::plan(&self.state, &p, i.tenant_id, i.revision_id, i.input)
|
||||
.await
|
||||
.map(without_raw_plan_bytes)
|
||||
}
|
||||
"inventory.list_hypervisors" => {
|
||||
let i: Hypervisors = parse(args)?;
|
||||
@@ -399,17 +407,15 @@ impl Adapter {
|
||||
}
|
||||
"operations.get_plan" => {
|
||||
let i: GetPlan = parse(args)?;
|
||||
// The WebUI compares these raw bytes; MCP gets plan_payload and plan_hash.
|
||||
let mut view =
|
||||
crate::jobs::plan_preview(&self.state, &p, i.tenant_id, i.plan_id).await?;
|
||||
if let Some(map) = view.as_object_mut() {
|
||||
map.remove("plan_payload_bytes");
|
||||
}
|
||||
Ok(view)
|
||||
crate::jobs::plan_preview(&self.state, &p, i.tenant_id, i.plan_id)
|
||||
.await
|
||||
.map(without_raw_plan_bytes)
|
||||
}
|
||||
"operations.plan" => {
|
||||
let i: Plan = parse(args)?;
|
||||
crate::jobs::plan_request(&self.state, &p, i.tenant_id, i.input).await
|
||||
crate::jobs::plan_request(&self.state, &p, i.tenant_id, i.input)
|
||||
.await
|
||||
.map(without_raw_plan_bytes)
|
||||
}
|
||||
"updates.list_releases" => {
|
||||
let i: Devices = parse(args)?;
|
||||
@@ -606,6 +612,12 @@ mod tests {
|
||||
assert!(tools.iter().all(|tool| tool.name != "sessions.request"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plan_results_drop_only_the_raw_byte_array() {
|
||||
let view = without_raw_plan_bytes(json!({"plan_id":"x","plan_hash":"h","plan_payload":{},"plan_payload_bytes":[1,2]}));
|
||||
assert_eq!(view, json!({"plan_id":"x","plan_hash":"h","plan_payload":{}}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unauthenticated_requests_get_a_json_bearer_challenge() {
|
||||
let response = rejected(StatusCode::UNAUTHORIZED);
|
||||
|
||||
Reference in New Issue
Block a user