Repository navigation
feat(mcp): accept common argument-name aliases for procedure and search tools - #2148
pablodiazjorge wants to merge 28 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ch tools Agents send address to procedure-scoped tools and query to search tools. Canonical validation now renames these aliases to procedure and pattern when only the alias is present, so handlers and recorded Evidence parameters see the canonical key. Inputs with both keys are still rejected, and advertised schemas list only canonical keys.
e057def to
06b761a
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thanks, @pablodiazjorge, for the focused alias implementation in #2148. I prepared one additional regression on top of It checks that canonical and aliased Formatting, the focused contract and MCP tests (2 files, 9 tests), typecheck, and This covers Evidence parameter normalization for the current alias implementation. It does not take a position on the unresolved discussion in #2146 about accepting aliases versus strict validation with clearer remediation. If useful, this commit is ready to cherry-pick into your existing PR. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thanks @jaelliot, that's a useful check to pin down. I cherry-picked your commit into the branch, keeping your authorship. On Windows 11 the new test passes with the existing alias tests (5/5) and the file is formatted. On the aliases-versus-strict-validation question in morluto/rea#2146: if @morluto prefers it, I'm happy to switch to option 2, a validation error that names the canonical key. |
|
CI note: the only failing test is unrelated to this change. |
|
@greptileai review |
[Medium impact] The PR appears safe to merge; no blocking issue was found. SummaryThe PR adds
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["MCP arguments"] --> B["Named input contract"]
B --> C{"Both spellings supplied?"}
C -->|Yes| D["Reject call"]
C -->|No| E["Rename alias to canonical key"]
E --> F["Apply original checks and defaults"]
F --> G["Handler and Evidence"]
Reviews (24) · Last reviewed commit: "Merge upstream/main into feat/mcp-input-..." · Reviewed by Greptile |
Source-reviewed changes. Tests, builds and check reruns were skipped at maintainer request.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00a0711424
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d06d3c0a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The MCP adapter previously accepted hidden spellings while the named schemas advertised canonical inputs only. Commit 4d06d3c moves compatibility to the named official/enhanced/function contracts: one parser renames caller keys without mutating their values, applies canonical validation exactly once, and explicitly rejects requests containing both spellings. Its input projection advertises the accepted object alternatives; the existing shared presentation still owns client-compatible root flattening and compact presentation. The adapter rewrite and obsolete canonical-only tests were removed. Owner regressions cover values, defaults, refinements, single execution of field transforms, ambiguity and advertised validation; SDK tools/list/Ajv and real MCP-call coverage was updated. Actual SDK/client schema conversion remains unverified because execution was disabled. Source and affected-consumer inspection, targeted formatting with two threads, and git diff --check completed. Regression coverage was authored; tests, builds, typechecks, lint, provider execution and CI reruns were skipped at the user’s request. |
|
Thanks @morluto. I ran what was skipped on
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25e93ae214
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open. The alias schema projection now preserves a required selector constraint after the shared MCP presentation flattens the root union: missing canonical/alias selectors and requests containing both spellings are excluded independently of optional/defaulted fields. This is owned by the named alias contract and is covered by advertised-schema and MCP-call regression cases. The fix is live at 25e93ae. Source/consumer inspection and |
|
The TS2375 at |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52d2a2d37b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
TL;DR: Fixed. The PR text now matches the code on both points I reported. On head 90f7011, This follows my earlier result on head 46ad54d. Head is now 90f7011, a merge of main. Its base is main 034342b. The server now reports 6.5.0. Thanks, pablodiazjorge, for updating the PR text and for the
The same counts as my earlier result. I drove the real stdio server again, with no binary open, in the full and compact profiles. Both gave the same answers. A call that gets past validation returns "No app is open". That error is the pass signal.
Advertised schemas. I checked The two PR text points. The body now says Not run
The box was shared with other test jobs. Timings are not benchmarks. Test setupCommandsnpm ci && npm run build && npm run test:prepare
node scripts/run-development-tests.mjs focused src/contracts/inputKeyAliases.test.ts tests/boundary/mcp/inputKeyAliasesMcp.test.ts
node scripts/run-development-tests.mjs focused tests/boundary/filesystem/productCatalog.test.ts
node scripts/rea.mjs mcp # driven over stdio: initialize, tools/list, tools/call
REA_MCP_INPUT_SCHEMA_PROFILE=compact node scripts/rea.mjs mcpThe stdio script is the same as last time, plus five 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@morluto, a short status note: the branch is merged with today's main ( |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@morluto, the branch is now up to date with the 6.8.0 release ( |
Drop selector sentences that the shared input-group description already states, and keep canonical property descriptions off alias spellings.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b6b9034d5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| property === null | ||
| ) | ||
| return [name, property]; | ||
| const { description: _description, ...rest } = property as Record< |
There was a problem hiding this comment.
Preserve canonical descriptions on alias properties
With REA_MCP_INPUT_SCHEMA_PROFILE=full, dropping the copied description here does not leave the alias neutral: toolInputSchemaWithMetadata subsequently invokes presentInputJsonSchema, whose PROPERTY_DESCRIPTIONS.query fallback labels it “Non-empty feature or text query to investigate.” This is fresh behavior beyond the removed selector sentence: for search_bytes, query is normalized to the masked-byte pattern and only accepts hex/?? syntax, so tools/list now guides models to send text that the runtime rejects (and optional filters such as get_objc_classes accept query: "" despite “Non-empty”). Preserve the canonical property's semantics or suppress the key-based fallback for alias properties.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks, fixed in 918a144. address has no key-based fallback, but query does, so dropping the copied description let the full profile describe search_bytes.query as a non-empty text query. Alias properties now carry Same as <canonical>. instead of a copy or nothing. That states the exact semantics on every tool, including search_bytes and the optional filters, and keeps the catalog within the frame: 1,047,927 bytes on Linux, 649 under. A new boundary test checks address on procedure_pseudo_code and query on search_strings and search_bytes in the full profile; it fails on 7b6b903.
An alias left without a description received the key-based fallback, which describes query as a text query even where it takes a byte pattern.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 918a144e70
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // accepted alternatives here for schema consumers. | ||
| return { | ||
| ...projected, | ||
| ...(alternatives.length > 0 ? { anyOf: alternatives } : {}), |
There was a problem hiding this comment.
Keep the Windows catalog within the stdio frame
On Windows, when a host uses the full input profile with output schemas off and enforces the repository's 1 MiB catalog frame, advertising these alternatives makes tools/list 1,049,062 bytes (the Windows run recorded for this change), exceeding 1,048,576; tests/boundary/mcp/outputSchemaProfile.test.ts:89-118 therefore already fails on this head. Such hosts cannot load any tools, so the aliases need a smaller advertisement (or the frame/delivery contract must be changed) before this profile remains usable.
AGENTS.md reference: AGENTS.md:L53-L54
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in dd000cb by advertising a smaller schema.
The aliases no longer advertise root alternatives. The projection now returns one strict object, which accepts exactly the alternatives:
- their properties, with
additionalProperties: false; - the keys that every alternative requires;
- the same
notexclusions, so one spelling per selector.
That removes the input-group sentence and the minProperties that the shared root-union presentation added to each tool. The aliases now cost 2,734 bytes instead of 5,082. The full catalog with output schemas off measures 1,045,579 bytes on Linux (2,997 under) and 1,046,979 bytes on Windows (1,597 under), and outputSchemaProfile.test.ts passes on both.
@morluto, this moves flattening into the alias projection, against the comment that kept the exact alternatives there for schema consumers. The accepted set is unchanged, and the unit and MCP tests check it with Ajv. I'm happy to revisit if you'd rather keep the alternatives and change the frame instead.
One object with the same exclusions accepts exactly the alternatives and avoids the per-tool input-group text, so the full catalog fits the 1 MiB frame on Windows too.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
#8649 resolved #2146 the other way: |
Summary
Fixes #2146.
Agents carry argument names from one tool to the next. After
resolve_containing_procedure,xrefsorread_bytes, which takeaddress, they sendaddressto procedure-scoped tools that takeprocedure; and they sendqueryto the search tools, which takepattern. Strict input validation rejects these calls before they reach REA. In the study described in the issue (40 runs, 321 REA calls) this caused 18 input validation failures in 10 runs, and the agent recovered in 9 of them.The two later studies in rea-lab, with the same pinned REA 6.4.0, saw the same mistake: in study 2, 7 of the 9 MCP input validation errors sent
addressorquery, and 6 of those went to tools this PR covers (the seventh waslist_strings, which takes no filter); in study 3, both of them wereprocedure_pseudo_codewithaddress.This PR makes the named tool contracts accept those two spellings, advertise them, and parse them into the canonical key before the handler runs. The current implementation is @morluto's rework of the first version (see Change and scope).
Problem and expected behavior
Before:
search_strings {"query": "ACCESS"}returnsInput validation error: Invalid arguments for tool search_strings: pattern: Invalid input: expected string, received undefined, Unrecognized key: "query".After: the call is parsed as
{"pattern": "ACCESS"}, and the handler and the recorded Evidence parameters see onlypattern. The same applies toaddresson tools whose input declaresprocedure.Unchanged:
Supply either pattern or query, not both(orprocedure or address).Change and scope
src/contracts/inputKeyAliases.tsholds a fixed list of two pairs,addressforprocedureandqueryforpattern, andcompatibleToolInputSchemawraps a named contract's input: it accepts strict alternatives with either spelling, rejects both together, and parses into the canonical key. A pair applies only when the input declares the canonical key and not the alias. On the current head that is:address(12 tools):analyze_function,annotate_native_function,inspect_native_api,procedure_address,procedure_assembly,procedure_callees,procedure_callers,procedure_info,procedure_pseudo_code,procedure_references,read_function_instructions,trace_native_values. In all of themproceduretakes a procedure name or address.query(5 tools):analyze_swift_types,get_objc_classes,search_procedures,search_strings, andsearch_bytes. In the first fourpatternis a name or text filter.search_bytesreached main in feat(native): search analyzed memory for masked byte patterns #2341 after this PR was opened, and therepatternis a masked byte pattern such as48 8B ?? ?? 89;querygets exactly the same validation, so text sent asqueryis rejected with the byte-pattern format error rather than reinterpreted. If you would rather keepqueryto text filters, excludingsearch_bytesis a one-line change.compatibleToolInputSchema, so one contract owns both spellings and the canonical parsed output. The MCP server no longer rewrites raw caller arguments.additionalProperties: false, the keys every alternative requires, and anotrule that rejects both spellings (and requires one when the selector is required), in the full and compact profiles. An alias property is described asSame as <canonical>.(for exampleSame as procedure.) rather than with a copy of the canonical description.docs/mcp-contracts.mddocuments this in a new "Compatible input spellings" subsection.Catalog budget: the aliases as first advertised cost 7,104 bytes across the 17 tools, mostly text repeated in every tool: a selector sentence, the shared root-union presentation's input-group sentence and
minProperties, and alias properties that copied their canonical description. That took the full input catalog with output schemas omitted 1,373 bytes over the 1 MiB frame thatoutputSchemaProfile.test.tsenforced then. 7b6b903, 918a144 and dd000cb remove the repetition: the projection advertises the one strict object above instead of root alternatives, so the shared presentation adds nothing. #7379 has since removed that frame for full input. With main at65f1c4473, the aliases cost 2,734 bytes in the full input catalog with output schemas omitted (908,170 bytes on Linux, 905,436 without them) and 2,136 bytes in the default compact catalog (568,933 bytes on Linux). I kept the flat object because it costs 2,734 bytes where the alternatives cost 5,082 for the same accepted set. It departs from the earlier comment that kept the exact alternatives in the projection for schema consumers; the unit and MCP tests check the accepted set with Ajv. If you would rather go back to the alternatives now that the frame is gone, that is your call.The first version of this PR renamed aliases inside
EvidenceMcpServer.registerTooland kept advertised schemas canonical-only. @morluto moved ownership into the named contracts and advertised the alternatives (4d06d3c, 25e93ae, 12a989a, 52d2a2d); 663ea6f types the compatible schemas underexactOptionalPropertyTypes.Not included:
Contract and boundary impact
src/contracts/inputKeyAliases.tsand the contract builders that use it).address(on the 12 tools above) or onlyquery(on the 5 tools above) now validate, andtools/listadvertises both spellings for those tools. The CLI is unchanged.annotate_native_functionis among the 12 tools; the alias only names its target procedure and does not change its mutation authority.docs/public/product-catalog.json), package, or installation impact: none;productCatalog.test.tspasses on this head.Evidence and regression coverage
Tests added or updated:
src/contracts/inputKeyAliases.test.ts(8 tests): which inputs get aliases, caller values preserved, both spellings advertised as one strict object and parsed while ambiguity, a missing selector and unknown keys are rejected, alias properties described by their canonical spelling, canonical checks and refinements retained, optional selectors accepted with either spelling or neither but not both, transforms parsed once, and contracts without compatible keys left unwrapped.tests/boundary/mcp/inputKeyAliasesMcp.test.ts(9 tests): the full tool catalog onEvidenceMcpServerover an in-memory MCP client, with and without the compact profile: aliases accepted, alias values validated before dispatch, both spellings rejected, accepted aliases advertised through SDK conversion (checked with Ajv), alias descriptions that name the canonical spelling instead of a key-based fallback in the full profile, and canonical parameters recorded in Evidence after an alias call.Base reproduction or other evidence: on main,
search_strings {"query"}andprocedure_pseudo_code {"address"}fail withUnrecognized key. @CassieFox23 verified head 46ad54d on Linux over stdio MCP (comment).User-visible CLI/MCP output, from the built server over stdio on Windows, head e171684, identical with the default compact profile and with
REA_MCP_INPUT_SCHEMA_PROFILE=full(no binary open, so a call that passes validation returnstarget_unavailable; a rejected call returnsinvalid_request, and the table quotes itsdetails.issues[].message):search_strings {"query": "ACCESS"}procedure_pseudo_code {"address": "0x401000"}search_bytes {"query": "48 8B ?? ?? 89"}search_bytes {"query": "ACCESS"}pattern: Use hexadecimal byte pairs or ?? wildcards, the same as{"pattern": "ACCESS"}search_strings {"query": "a", "pattern": "b"}Supply either pattern or query, not bothprocedure_pseudo_code {"adress": "0x401000"}procedure: Invalid input: expected string, received undefined, Unrecognized key: "adress"Remaining proof gaps: no real-provider session was run with the change; validation happens before any provider call.
For evidence-bearing changes:
Validation performed
Windows 11 x64 (10.0.26300), Node 24.22.1, head e171684 (this branch updated with main at the 6.8.0 release, 160d821), with the Windows native controls from the published
[email protected]package:npx vitest run src/contracts tests/boundary/mcp/inputKeyAliasesMcp.test.ts: 215 passed.npm run build,npm run test:prepare,npm run checkandnpm run docs:check: passed; thennpx vitest run tests/boundary/filesystem/productCatalog.test.ts: 10 passed.npx vitest run src/contracts src/server src/config tests/boundary/mcp: 1867 passed, 23 failed, 96 skipped. The same 23 tests, in 18 files outside this change, fail on main at 160d821 on this host with the same native controls, so the change adds no failure.REA_MCP_INPUT_SCHEMA_PROFILEunset (compact, the default since 6.8.0) and set tofull.ff6d96bce(head66dde5165; one import conflict insrc/contracts/enhancedToolContracts.ts, both imports kept):tsc,src/contractsplus the alias and analysis-detail boundary tests (249 passed), the catalog tests (54 passed),npm run checkandnpm run docs:checkpassed.dd000cbca:npm run build,npm run test:prepare,npm run checkandnpm run docs:checkpassed.src/contracts,src/serverand the alias, compact-schema, schema-validity, contract-presentation, doctor, output-schema-profile, v-mode and catalog tests: 462 passed and 1 failed,advertisedPatternsVMode.test.ts, which fails the same way on main on Windows ([Bug] Windows hosts advertise an absolute-path pattern that fails v-mode compilation #7151).outputSchemaProfile.test.tspasses on Windows (1,046,979 bytes); withprocess.platformreported aslinuxwhile the modules load, it measures 1,045,579 bytes (1,049,949 on66dde5165, matching CI).npx vitest run src/contracts src/server src/config tests/boundary/mcp: 2,007 tests, with the same 23 failures as the run one1716846dabove and no new ones.235e8bc05(4c4069178; one import conflict insrc/contracts/functionWorkflowToolContracts.ts, both imports kept;npm cifor zod 4.6.6) and at65f1c4473(7dbfd6b54, no conflicts):npm run build,npm run test:prepare,npm run docs:check, typecheck, lint, format, knip, architecture guards,knip:productionandlint:typedpassed. The alias, output-schema-profile and v-mode tests, plus the four files that failed CI on4c4069178and were fixed on main by fix(windows): restore native verification fixture coverage #7479 and fix(ci): align static checks and regression fixtures with current contracts #7349 (WindowsNativeLoader,safeOutputTreeCloseFailures,electronMcp,providerBinding): 58 passed.npx vitest run src/contracts src/server src/config tests/boundary/mcp: 2,015 passed and 22 failed, all among the 25 that fail on clean main at235e8bc05on this host (symlinks, Unix sockets and a file name with a tab), none new.Compatibility, safety, and release
Author readiness
Human owner: @pablodiazjorge
Review checklist
type(scope): outcome.