Skip to content

fix(mcp): present discover_tools input through the selected profile - #10592

Merged
morluto merged 43 commits into
mainfrom
fix/compact-discover-tools-input
Nov 15, 2026
Merged

morluto merged 43 commits into
mainfrom
fix/compact-discover-tools-input

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Under REA_MCP_TOOL_CATALOG_PROFILE=hot-cold, discover_tools bypassed the selected input presentation: with the default compact input profile it still advertised its canonical schema, including default values for offset and limit (clients apply advertised defaults themselves, #5322) and nested annotations the compact profile strips from every other tool. This routes every listed input schema, transport discovery included, through one server-owned presentation.

Stacked on #10582 (and #10567). Follow-up named in #10567's review notes. Refs #9347.

Problem and expected behavior

  • Trigger: start rea mcp with REA_MCP_TOOL_CATALOG_PROFILE=hot-cold and the default input profile, then tools/list. discover_tools.inputSchema.properties.offset carried "default": 0 and limit "default": 3; the dialect baseline recorded this as input keyword default: 2 for the compact profile.
  • Invariant: the configured input profile decides what every listed tool advertises. Only the canonical schema validates calls.
  • Two paths were affected: the eager server registered discovery with super.registerTool, and the deferred production server (default stdio start) was constructed without the selected presentation because it serves recorded tool schemas, while discovery is not recorded.

Change and scope

  • EvidenceMcpServerCore.presentInputSchema is the one place that applies the selected input presentation; registerTool and enableProgressiveCatalog both use it.
  • DeferredEvidenceMcpServer now takes an options object (maximumInputElements, compactPresentation); deferredRuntime passes the presentation for the selected profile. Recorded tool schemas are unchanged (they are still borrowed from the build-owned catalog); only discovery uses it.
  • The compact baseline loses its input keyword default entry, so a regression fails the existing exact-match check.
  • Borrowed Evidence inputs (squashed from fix(mcp): keep the Evidence union on described borrowed inputs #10597): borrowEvidenceInput installs its advertised projection in the borrowed parser's constructor, so a call site's .describe() copy keeps it. Restored declaration: match_native_functions.left/right advertise the Evidence union instead of unconstrained values in every profile. This is why the full baseline counts rise (any-of fewer-than-two-branches 168 to 176, untyped-branch 136 to 142, const, oneOf, prefixItems, propertyNames, type-list, type:null, untyped); advertisedDialectBaseline.ts and docs/development/testing.md now admit growth only for such a named restored declaration.
  • Not included: the remaining baselined dialect keys (next PR in this stack), and the progressive catalog identity, which already differs per input profile through its base digest.

Contract and boundary impact

  • Semantic owner and earliest changed stage: EvidenceMcpServerCore.presentInputSchema (server registration). Consumers: SDK tools/list for every registration, including discover_tools.

  • Contribution scope fit and linked maintainer decision: not applicable (fix within the existing MCP presentation boundary).

  • CLI and MCP/tool-catalog contract: compact-profile discover_tools.inputSchema loses default, nested descriptions and $schema, matching other tools. Full profile unchanged. Server-side validation unchanged.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none; recorded catalogs do not contain discover_tools.

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/mcp/advertisedDialect.test.ts: new case compares discover_tools under full (defaults kept) and compact (exact compact form); the compact baseline drops input keyword default.
    • tests/boundary/mcp/deferredRuntime.test.ts: the hot-cold stdio cases now assert the deferred server advertises the compact discovery schema with no default.
  • Base reproduction: with the src/server change reverted, both advertisedDialect.test.ts cases failed (2 failed / 30). With only the deferredRuntime.ts wiring reverted, the two default-profile hot-cold cases in deferredRuntime.test.ts failed (2 failed / 36).
  • Remaining proof gaps: no real client exercised.

Validation performed

  • npm run test:focused -- tests/boundary/mcp/deferredRuntime.test.ts src/server/DeferredEvidenceMcpServer.test.ts tests/boundary/mcp/advertisedDialect.test.ts — 3 files, 83 tests passed.
  • npm run test:focused -- tests/boundary/mcp/deferredRuntime.test.ts tests/boundary/mcp/advertisedDialect.test.ts src/server/ProgressiveToolCatalog.test.ts src/server/DeferredEvidenceMcpServer.test.ts — 4 files, 94 tests passed (before the constructor options refactor).
  • npm run check:fast — typecheck and lint passed.
  • npx oxfmt --check on changed files — clean.
  • After merging the updated base (2026-11-15): npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/mcp/deferredRuntime.test.ts src/server/DeferredEvidenceMcpServer.test.ts: 88 passed; npm run check:fast passed; npm run docs:check passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Defaults still apply server-side when omitted.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new authority or side effects.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

The hot-cold catalog registered discover_tools directly with the SDK, so
the default compact input profile still advertised its canonical schema,
including page-size defaults clients apply on their own (#5322). Route
every listed input schema, transport discovery included, through one
server-owned presentation, and pass the selected presentation to the
deferred server, which serves recorded tool schemas but not discovery.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T09:46:14.023081Z 0909ac7 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable issue remains from the reviewed changes.

Summary

Routes discover_tools through the selected input presentation in both eager and deferred servers. It also preserves borrowed Evidence declarations across .describe() copies.

  • Discovery uses the selected input profile in every server path.
  • Borrowed Evidence inputs keep their public shape after descriptions are added.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Profile["Selected input profile"] --> Eager["Eager server"]
  Profile --> Deferred["Deferred server"]
  Eager --> Present["Shared input presentation"]
  Deferred --> Discovery["discover_tools"]
  Discovery --> Present
  Deferred --> Recorded["Profile-specific recorded tool schemas"]
  Present --> Listed["tools/list"]
  Recorded --> Listed
  Calls["tools/call"] --> Canonical["Canonical input parser"]
  Canonical --> Handler["Tool handler"]
Loading

Reviews (16) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

… into HEAD

# Conflicts:
#	scripts/lib/verify-package-core.mjs
#	src/contracts/advertisedDialectBaseline.ts
#	tests/boundary/mcp/advertisedDialect.test.ts
# Conflicts:
#	tests/boundary/mcp/advertisedDialect.test.ts
# Conflicts:
#	docs/development/testing.md
#	scripts/lib/verify-package-core.mjs
#	src/contracts/advertisedDialectBaseline.ts
#	tests/boundary/mcp/advertisedDialect.test.ts
#	tests/boundary/mcp/advertisedPatternsVMode.test.ts
* fix(mcp): keep the Evidence union on described borrowed inputs

borrowEvidenceInput installed its advertised projection on one schema
instance. A call site's .describe() rebuilds the schema from its
definition, so match_native_functions advertised left and right as
unconstrained values in every input profile. Install the projection in
the borrowed parser's constructor so derived schemas keep it, for both
borrowed inputs and borrowed arrays.

* test(mcp): select the borrowed Evidence contract from its family
@morluto
morluto changed the base branch from fix/portable-advertised-patterns to main November 15, 2026 09:06
…tools-input

# Conflicts:
#	docs/development/testing.md
#	src/contracts/advertisedDialectBaseline.ts
…tools-input

# Conflicts:
#	src/contracts/advertisedDialectBaseline.ts
@morluto
morluto merged commit babfc87 into main Nov 15, 2026
14 checks passed
@morluto
morluto deleted the fix/compact-discover-tools-input branch November 15, 2026 10:08
@morluto morluto added area: mcp MCP server, transport, and tool registration bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant