Expose the WebUI's read views through MCP: order list, plan preview, hypervisors and catalog
New tools operations.list, operations.get_plan, inventory.list_hypervisors, catalog.list_package_recipes, catalog.list_windows_msi_recipes and catalog.get_artifact reuse the WebUI handlers and their tenant and scope checks. Interactive-only actions (approvals, device management, customer transfer, enrollment, emergency stop, imports, tokens) stay out of MCP and are listed as such in the access guide and product contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+21
-16
@@ -1079,11 +1079,15 @@ async fn plan_get_http(
|
||||
Path((t, id)): Path<(Uuid, Uuid)>,
|
||||
) -> Result<Json<Value>> {
|
||||
let p = principal(&s, &h, false).await?;
|
||||
scope(&p, t, false)?;
|
||||
Ok(Json(plan_preview(&s, &p, t, id).await?))
|
||||
}
|
||||
/// Fixed plan preview shared by the WebUI and MCP. Reading never approves.
|
||||
pub async fn plan_preview(s: &crate::State, p: &Principal, t: Uuid, id: Uuid) -> Result<Value> {
|
||||
scope(p, t, false)?;
|
||||
let mut tx = rmm_persistence::tenant_tx(&s.pool, t).await?;
|
||||
let (plan, hash, bytes) = load_plan(&mut tx, id).await?;
|
||||
crate::permissions::require_principal(&mut tx, &p, "operations:read").await?;
|
||||
let metadata = crate::approvals::summary(&mut tx, &p, id).await?;
|
||||
crate::permissions::require_principal(&mut tx, p, "operations:read").await?;
|
||||
let metadata = crate::approvals::summary(&mut tx, p, id).await?;
|
||||
let approval = metadata["approval_state"].as_str().map(str::to_owned);
|
||||
let mut view = plan_view(&plan, &hash, approval, &bytes)?;
|
||||
for (key, value) in metadata.as_object().into_iter().flatten() {
|
||||
@@ -1093,7 +1097,7 @@ async fn plan_get_http(
|
||||
}
|
||||
}
|
||||
tx.commit().await?;
|
||||
Ok(Json(view))
|
||||
Ok(view)
|
||||
}
|
||||
async fn operation_http(
|
||||
State(s): State<crate::State>,
|
||||
@@ -1209,23 +1213,24 @@ async fn cancel_http(
|
||||
let p = principal(&s, &h, true).await?;
|
||||
Ok(Json(cancel(&s, &p, t, id, i).await?))
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, schemars::JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum OrderSort {
|
||||
pub(crate) enum OrderSort {
|
||||
Recent,
|
||||
}
|
||||
|
||||
/// Order list filters of the WebUI order view, also used by `operations.list`.
|
||||
#[derive(Default, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct OrderListQuery {
|
||||
sort: Option<OrderSort>,
|
||||
cursor: Option<String>,
|
||||
limit: Option<u16>,
|
||||
q: Option<String>,
|
||||
device: Option<String>,
|
||||
status: Option<String>,
|
||||
from: Option<DateTime<Utc>>,
|
||||
until: Option<DateTime<Utc>>,
|
||||
pub(crate) struct OrderListQuery {
|
||||
pub(crate) sort: Option<OrderSort>,
|
||||
pub(crate) cursor: Option<String>,
|
||||
pub(crate) limit: Option<u16>,
|
||||
pub(crate) q: Option<String>,
|
||||
pub(crate) device: Option<String>,
|
||||
pub(crate) status: Option<String>,
|
||||
pub(crate) from: Option<DateTime<Utc>>,
|
||||
pub(crate) until: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
async fn operations_http(
|
||||
@@ -1238,7 +1243,7 @@ async fn operations_http(
|
||||
order_list(&s, &p, t, query).await.map(Json)
|
||||
}
|
||||
|
||||
async fn order_list(
|
||||
pub(crate) async fn order_list(
|
||||
s: &crate::State,
|
||||
p: &Principal,
|
||||
t: Uuid,
|
||||
|
||||
Reference in New Issue
Block a user