Skip to content

Add MCP methods to applicable actions#900

Merged
jviotti merged 3 commits into
mainfrom
rpc-methods
May 14, 2026
Merged

Add MCP methods to applicable actions#900
jviotti merged 3 commits into
mainfrom
rpc-methods

Conversation

@jviotti
Copy link
Copy Markdown
Member

@jviotti jviotti commented May 14, 2026

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.

2 issues found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/actions/action_schema_search_v1.h">

<violation number="1" location="src/actions/action_schema_search_v1.h:178">
P1: Validate MCP `limit` range before converting to `size_t`; negative integers currently wrap to huge values and can cause pathological searches.</violation>
</file>

<file name="src/actions/action_serve_explorer_artifact_v1.h">

<violation number="1" location="src/actions/action_serve_explorer_artifact_v1.h:75">
P1: Validate `arguments.path` before appending it to `absolute_path`; current code allows absolute paths and parent-directory traversal to escape the explorer base directory.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/actions/action_schema_search_v1.h Outdated
Comment thread src/actions/action_serve_explorer_artifact_v1.h Outdated
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 14, 2026

🤖 Augment PR Summary

Summary: This PR adds Model Context Protocol (MCP) support to applicable actions so they can be invoked via JSON-RPC tool calls.

Changes:

  • Introduced a new sourcemeta::one::mcp library and helpers to format MCP tool success/error envelopes.
  • Added a default Action::mcp(...) handler (method-not-found) and exposed URI-to-path conversion via uri_to_path.
  • Implemented MCP handlers for schema evaluation, schema tracing, schema search, and schema/explorer artifact serving actions.
  • Refactored JSON Schema evaluation/trace code paths to accept a parsed JSON instance (and made source-position tracking optional).
  • Updated build system to include the new MCP library and added unit tests for MCP envelopes and new action helpers.

Technical Notes: MCP responses are returned as JSON-RPC result envelopes with isError and optional structuredContent; REST behavior remains unchanged.

🤖 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. 3 suggestions posted.

Fix All in Augment

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

}
const auto path{arguments.at("path").to_string()};
if (!path.empty()) {
absolute_path /= path;
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 14, 2026

Choose a reason for hiding this comment

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

src/actions/action_serve_explorer_artifact_v1.h:75: In the MCP "list" path, user-controlled arguments.path is appended directly to absolute_path, so an absolute path (or .. segments) can escape base()/explorer and read unexpected files via metapack_read_json. Consider constraining this input to a safe relative path before joining.

Severity: high

Fix This in Augment

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

Comment thread src/actions/schema_directory.cc Outdated
}

return this->base_ / "schemas" / uri_path / "%";
return std::filesystem::path{uri_path};
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 14, 2026

Choose a reason for hiding this comment

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

src/actions/schema_directory.cc:36: uri_to_path() returns a filesystem path built directly from the URI path without rejecting traversal segments (e.g. ..), which then flows into schema_directory() and various MCP handlers to access the filesystem. This can allow schema URIs to resolve outside the intended base()/schemas subtree.

Severity: high

Other Locations
  • src/actions/action_jsonschema_evaluate_v1.h:82
  • src/actions/action_jsonschema_trace_v1.h:84
  • src/actions/action_serve_schema_artifact_v1.h:75
  • src/actions/action_serve_explorer_artifact_v1.h:83

Fix This in Augment

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

Comment thread src/actions/action_schema_search_v1.h Outdated
if (!arguments.at("limit").is_integer()) {
return sourcemeta::one::jsonrpc_make_error_invalid_params(request_id);
}
limit = static_cast<std::size_t>(arguments.at("limit").to_integer());
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 14, 2026

Choose a reason for hiding this comment

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

src/actions/action_schema_search_v1.h:178: MCP limit accepts any integer and is cast to std::size_t, so negative values can wrap to a huge limit and very large values bypass the REST-side bounds. This may lead to unexpected search sizes or resource usage; consider validating the range similarly to the REST handler.

Severity: medium

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: fabf1f3 Previous: ef38b58 Ratio
Add one schema (0 existing) 240 ms 235 ms 1.02
Add one schema (100 existing) 26 ms 24 ms 1.08
Add one schema (1000 existing) 85 ms 76 ms 1.12
Add one schema (10000 existing) 899 ms 645 ms 1.39
Update one schema (1 existing) 19 ms 17 ms 1.12
Update one schema (101 existing) 26 ms 25 ms 1.04
Update one schema (1001 existing) 87 ms 75 ms 1.16
Update one schema (10001 existing) 732 ms 649 ms 1.13
Cached rebuild (1 existing) 6 ms 5 ms 1.20
Cached rebuild (101 existing) 8 ms 7 ms 1.14
Cached rebuild (1001 existing) 31 ms 26 ms 1.19
Cached rebuild (10001 existing) 283 ms 241 ms 1.17
Index 100 schemas 111 ms 117 ms 0.95
Index 1000 schemas 888 ms 969 ms 0.92
Index 10000 schemas 14074 ms 12809 ms 1.10

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: fabf1f3 Previous: ef38b58 Ratio
Add one schema (0 existing) 239 ms 239 ms 1
Add one schema (100 existing) 27 ms 29 ms 0.93
Add one schema (1000 existing) 85 ms 87 ms 0.98
Add one schema (10000 existing) 817 ms 730 ms 1.12
Update one schema (1 existing) 20 ms 22 ms 0.91
Update one schema (101 existing) 27 ms 32 ms 0.84
Update one schema (1001 existing) 84 ms 89 ms 0.94
Update one schema (10001 existing) 786 ms 744 ms 1.06
Cached rebuild (1 existing) 7 ms 7 ms 1
Cached rebuild (101 existing) 9 ms 10 ms 0.90
Cached rebuild (1001 existing) 31 ms 34 ms 0.91
Cached rebuild (10001 existing) 303 ms 278 ms 1.09
Index 100 schemas 119 ms 123 ms 0.97
Index 1000 schemas 1127 ms 1052 ms 1.07
Index 10000 schemas 13177 ms 15181 ms 0.87

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

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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/actions/base.cc">

<violation number="1" location="src/actions/base.cc:38">
P2: The new string-based absolute-path check is weaker than `std::filesystem::path::is_absolute()` and can let platform-specific absolute paths bypass validation.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Comment thread src/actions/base.cc
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.

1 issue found across 21 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="enterprise/server/include/sourcemeta/one/enterprise_server_actions.h">

<violation number="1" location="enterprise/server/include/sourcemeta/one/enterprise_server_actions.h:34">
P1: Storing `allowed_origin_` and `registry_url_` as `std::string_view` introduces a lifetime bug. These values should be owned by `EnterpriseMCP` because they are used after construction and inside async callbacks.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added 2 commits May 14, 2026 16:28
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti jviotti merged commit a0983a2 into main May 14, 2026
5 checks passed
@jviotti jviotti deleted the rpc-methods branch May 14, 2026 20:52
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