Skip to content

Perform JSON Schema input validation of MCP requests#907

Merged
jviotti merged 1 commit into
mainfrom
rpc-schema-routes
May 15, 2026
Merged

Perform JSON Schema input validation of MCP requests#907
jviotti merged 1 commit into
mainfrom
rpc-schema-routes

Conversation

@jviotti
Copy link
Copy Markdown
Member

@jviotti jviotti commented May 15, 2026

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Re-trigger cubic

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 15, 2026

🤖 Augment PR Summary

Summary: This PR adds JSON Schema–driven validation for MCP/JSON-RPC request inputs by validating each tool’s params.arguments against a precompiled Blaze template.

Changes:

  • Introduces an rpcSchema route argument for several API actions and stores it on the action instances.
  • Replaces hand-written argument/type checks in MCP handlers with Blaze Evaluator::validate against the RPC input schema template.
  • Adds Action::blaze_template() as a shared helper to load precompiled Blaze templates (blaze-fast.metapack/blaze-exhaustive.metapack) from the schemas directory.
  • Updates route generation to pass the correct rpcSchema for list, schema artifacts, evaluate/trace, and search endpoints.
  • Adjusts action library linking to expose Blaze/compiler and metapack dependencies needed by the new shared helper.

Technical Notes: RPC input schemas (e.g., .../schemas/search/rpc.json) define constraints like required fields, bounds (e.g., limit 1..100), and enums; these are now enforced consistently via schema validation rather than duplicated in C++.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

if (!arguments.defines("schema") || !arguments.at("schema").is_string() ||
!arguments.defines("instance")) {
// TODO: Cache the compiled template across invocations
const auto rpc_schema_template{this->blaze_template(
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/actions/action_jsonschema_evaluate_v1.h:79: this->blaze_template(this->rpc_schema_, ...) will assert/throw if rpcSchema wasn’t provided by the router (or the corresponding metapack is missing/corrupt), which would turn a request-time input-validation step into a process-terminating failure. Is that failure mode intended for runtime request handling, or should it degrade to an InvalidParams-style error?

Severity: medium

Other Locations
  • src/actions/action_jsonschema_trace_v1.h:81
  • src/actions/action_schema_search_v1.h:172
  • src/actions/action_serve_explorer_artifact_v1.h:70
  • src/actions/action_serve_schema_artifact_v1.h:74

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Index (community)

Details
Benchmark suite Current: f0834bb Previous: a0983a2 Ratio
Add one schema (0 existing) 240 ms 242 ms 0.99
Add one schema (100 existing) 25 ms 23 ms 1.09
Add one schema (1000 existing) 85 ms 76 ms 1.12
Add one schema (10000 existing) 683 ms 942 ms 0.73
Update one schema (1 existing) 18 ms 23 ms 0.78
Update one schema (101 existing) 25 ms 24 ms 1.04
Update one schema (1001 existing) 98 ms 75 ms 1.31
Update one schema (10001 existing) 693 ms 623 ms 1.11
Cached rebuild (1 existing) 5 ms 5 ms 1
Cached rebuild (101 existing) 7 ms 7 ms 1
Cached rebuild (1001 existing) 30 ms 26 ms 1.15
Cached rebuild (10001 existing) 270 ms 274 ms 0.99
Index 100 schemas 111 ms 142 ms 0.78
Index 1000 schemas 947 ms 1082 ms 0.88
Index 10000 schemas 17438 ms 13546 ms 1.29

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Index (enterprise)

Details
Benchmark suite Current: f0834bb Previous: a0983a2 Ratio
Add one schema (0 existing) 232 ms 230 ms 1.01
Add one schema (100 existing) 26 ms 27 ms 0.96
Add one schema (1000 existing) 79 ms 84 ms 0.94
Add one schema (10000 existing) 693 ms 803 ms 0.86
Update one schema (1 existing) 20 ms 20 ms 1
Update one schema (101 existing) 27 ms 27 ms 1
Update one schema (1001 existing) 78 ms 84 ms 0.93
Update one schema (10001 existing) 664 ms 686 ms 0.97
Cached rebuild (1 existing) 6 ms 7 ms 0.86
Cached rebuild (101 existing) 8 ms 9 ms 0.89
Cached rebuild (1001 existing) 28 ms 31 ms 0.90
Cached rebuild (10001 existing) 243 ms 269 ms 0.90
Index 100 schemas 116 ms 114 ms 1.02
Index 1000 schemas 1023 ms 1022 ms 1.00
Index 10000 schemas 14332 ms 14180 ms 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@jviotti jviotti merged commit 11e4993 into main May 15, 2026
5 checks passed
@jviotti jviotti deleted the rpc-schema-routes branch May 15, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant