Tighten OpenRPC schemas for admin mcp.* / metrics.* — typed accessors #134

Open
opened 2026-05-14 07:56:01 +00:00 by zaelgohary · 0 comments
Member

Several admin-domain OpenRPC methods declare bare {type: object} result schemas, so openrpc_client! generates #[serde(transparent)] { value: serde_json::Value } outputs. Every consumer (CLI, admin UI, integration tests) has to walk raw JSON via result.value.get(...).

Affected methods

  • mcp.healthMcpHealthOutput
  • mcp.list_toolsMcpListToolsOutput
  • metrics.getMetricsGetOutput

Current consumer pattern (from CLI)

let v = &mcp.value;
v.get("status").and_then(|s| s.as_str()).unwrap_or("unknown")
v.get("server_count").and_then(|s| s.as_i64()).unwrap_or(0)

Proposed fix

  1. Update server handlers (crates/hero_aibroker_server/src/api_openrpc/admin/{mcp.rs,metrics.rs}) to return typed structs instead of raw Value.
  2. Update OpenRPC specs in crates/hero_aibroker_server/specs/admin.openrpc.json to declare proper response schemas (status, server_count, tool_count, requests_total, etc.).
  3. Regenerate admin.openrpc.client.generated.rs so consumers get typed accessors.
  4. Drop the result.value.get(...) walks in CLI consumers.

Surfaced during the post-spec-consolidation CLI rewrite cleanup pass.

Several admin-domain OpenRPC methods declare bare `{type: object}` result schemas, so `openrpc_client!` generates `#[serde(transparent)] { value: serde_json::Value }` outputs. Every consumer (CLI, admin UI, integration tests) has to walk raw JSON via `result.value.get(...)`. ## Affected methods - `mcp.health` → `McpHealthOutput` - `mcp.list_tools` → `McpListToolsOutput` - `metrics.get` → `MetricsGetOutput` ## Current consumer pattern (from CLI) ```rust let v = &mcp.value; v.get("status").and_then(|s| s.as_str()).unwrap_or("unknown") v.get("server_count").and_then(|s| s.as_i64()).unwrap_or(0) ``` ## Proposed fix 1. Update server handlers (`crates/hero_aibroker_server/src/api_openrpc/admin/{mcp.rs,metrics.rs}`) to return typed structs instead of raw `Value`. 2. Update OpenRPC specs in `crates/hero_aibroker_server/specs/admin.openrpc.json` to declare proper response schemas (`status`, `server_count`, `tool_count`, `requests_total`, etc.). 3. Regenerate `admin.openrpc.client.generated.rs` so consumers get typed accessors. 4. Drop the `result.value.get(...)` walks in CLI consumers. Surfaced during the post-spec-consolidation CLI rewrite cleanup pass.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker#134
No description provided.