Skip to content

refactor(mcp): derive every advertised tool through one owner - #11268

Merged
morluto merged 2 commits into
mainfrom
refactor/one-advertised-catalog-owner
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
refactor/one-advertised-catalog-owner

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Three producers assembled "what a client receives for a tool" themselves: the MCP server (input compaction plus guidance at registration, output profile at tools/list), catalogIdentity.ts (its own input and output presentation for digests), and scripts/verify-copilot-client.mjs (its own compaction call). Served environment catalogs bypassed the advertised dialect entirely and listed recorded oneOf unions. This PR gives the composition one owner, src/contracts/advertisedTool.ts, and routes all four through it.

Refs plan W3 ("one function produces everything advertised").

Problem and expected behavior

  • Before: each site combined presentAdvertisedInput, describeAdvertisedTool and presentAdvertisedOutputSchema (or the profile check) by hand, so a change to the advertised form had to be repeated at each site. rea environment-serve listed oneOf (outside the portable dialect) on every query parameter.
  • After: advertiseTool(canonical, presentation) returns the advertised description, input schema and output schema. advertiseToolInput and advertiseToolOutput are the two halves the server needs at its two SDK hook points (registration and the tools/list rewrite). advertisedToolPresentation(outputSchemaProfile, input?) in config/mcpOutputSchemaProfile.ts maps REA's settings onto that presentation. Environment catalogs use the annotated input presentation: dialect projection only, with argument descriptions kept, because a served catalog already bounds its own size.

Change and scope

  • New owner src/contracts/advertisedTool.ts. It also owns the output-projection memo that used to live in the server transport.
  • Removed: presentAdvertisedInputSchema and describeAdvertisedTool from compactInputSchema.ts; the transport's compactedOutputSchemas cache; the profile branch in presentOutputSchemasForToolsList; catalog identity's presentedInput and presentOutputSchemas.
  • describeTool (and the deferred server's override) now receives the advertised description from the owner instead of guidance to combine.
  • Environment: advertisedEnvironmentTool(definition) is used by both the MCP registration (via transformAdvertisedInputJsonSchema, so calls are still validated against the recorded schema) and the environment card.
  • Not included: constructor signatures of the server classes are unchanged. W1 is changing MCP registration, so the registration loop is left alone. Output-schema dialect rules and the client-named repairs in compactJsonSchema.ts are the next W3 PR.
  • Known remaining gap: the dialect has no portable form for a query parameter's string | number | boolean | string[] union. After projection, that node is an untyped anyOf, which the dialect check still flags as type/untyped. The new regression test pins that this is the only remaining violation. Choosing the portable form (narrow to one type, or relax the rule for typed-branch unions) needs a decision and is not made here.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/contracts/advertisedTool.ts (new). Consumers: EvidenceMcpServerCore, DeferredEvidenceMcpServer, catalogIdentity.ts, serveEnvironment.ts, environmentTools.ts (card), scripts/verify-copilot-client.mjs.

  • Contribution scope fit and linked maintainer decision: not applicable (refactor within the existing advertised-schema boundary; W3 plan).

  • CLI and MCP/tool-catalog contract: REA's own tools/list and catalog digests are unchanged (verify:advertised-schemas summary unchanged; digest tests pass). Environment tools/list and card change: oneOf becomes anyOf, empty required: [] is dropped, and the description key moves before anyOf. The accepted values are the same.

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

  • Evidence, artifact, provenance, or reconstruction contract: none. Environment validation still uses the recorded schema.

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

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • environmentServeMcp.test.ts checks every listed served tool against advertisedInputDialectViolations; only the documented union node may remain. The repeated-query test now expects anyOf. The pinned card digest is updated.
    • The card tests (serveEnvironment.test.ts, environmentTools.test.ts) compare against advertisedEnvironmentTool.
    • compactInputSchemaMcp, serverWorkflowMcp and contractPresentation compare listed tools with advertiseTool.
  • Base reproduction: before the test updates, the same run on this branch showed the served listing carrying oneOf on the base path. On the base, the new dialect assertion fails with keyword: oneOf on each query parameter (source-derived from that listing).
  • Remaining proof gaps: the union form above. Copilot verifier change not executed (needs the Copilot CLI).

Validation performed

  • npm run check:fast — passed (typecheck, lint, architecture guards across 2844 files).
  • npm run test:focused -- src/server/environment/serveEnvironment.test.ts src/server/environment/serveEnvironmentState.test.ts src/server/environment/environmentCapacity.test.ts src/application/environment/environmentTools.test.ts src/server/DeferredEvidenceMcpServer.test.ts src/server/ProgressiveToolCatalog.test.ts tests/boundary/mcp/outputSchemaProfile.test.ts tests/boundary/mcp/serverIdentity.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/serverWorkflowMcp.test.ts tests/boundary/mcp/environmentServeMcp.test.ts tests/boundary/mcp/contractPresentation.test.ts — all pass after the test updates. The first run had 4 expected failures (environment card and listing shape), which the updated tests now cover.
  • npm run verify:advertised-schemas — passed; committed summary unchanged.
  • npx oxfmt --check on changed files — clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for REA's catalog. Served environment schemas change form, but the set of accepted calls does not.
  • 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 server's registration and tools/list rewrite, catalog identity and the
Copilot verifier each assembled the advertised description, input and
output schema themselves. src/contracts/advertisedTool.ts now owns that
composition; served environment catalogs (MCP listing and card) go through
the same owner's dialect projection, keeping argument descriptions.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T15:14:46.174318Z
We couldn’t complete this review. Comment @codex review to try again.
3937765 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge, with no new actionable findings.

Summary

The PR makes advertisedTool.ts the shared owner of advertised descriptions and schemas.

  • REA's MCP tools now get their advertised fields from one shared owner.
  • Served environment tools now show schemas in the advertised dialect.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  C["Canonical tool schemas"] --> A["advertisedTool.ts"]
  P["Presentation settings"] --> A
  A --> S["MCP tool listings"]
  A --> D["Catalog digests"]
  A --> E["Environment cards and listings"]
  A --> V["Copilot verifier"]
  C --> K["Canonical call validation"]
Loading

Reviews (2) · Last reviewed commit: "test(mcp): pin each remaining environmen..." · Reviewed by Greptile

@morluto
morluto merged commit 500c1f4 into main Nov 15, 2026
7 checks passed
@morluto
morluto deleted the refactor/one-advertised-catalog-owner branch November 15, 2026 15:54
morluto added a commit that referenced this pull request Nov 15, 2026
…ect projection (#11207)

* refactor(mcp): leave input literal portability to the advertised dialect projection

* test(mcp): leave listed-input literal portability to the dialect check

* test(mcp): trigger normalization dependency cases with non-portable patterns

* refactor(mcp): let the dialect projection own input patterns and dependency prose (#11238)

* refactor(mcp): let the dialect projection own input patterns and dependency prose

* refactor(mcp): drop the unused import from the output schema presentation

* test(mcp): force the reduced form by depth now that the projection re-emits patterns

* test(mcp): take advertised input from the one advertised-tool owner after #11268

* test(mcp): check the base64 pad-bit widening on the advertised input, not the registered one
@morluto morluto added the area: mcp MCP server, transport, and tool registration label 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant