Skip to content

Accept bounded native MCP metadata and prepare 0.1.6 - #14

Merged
FlyOverCoderKY merged 3 commits into
mainfrom
claude/fix-native-mcp-metadata-20261111
Nov 11, 2026
Merged

FlyOverCoderKY merged 3 commits into
mainfrom
claude/fix-native-mcp-metadata-20261111

Conversation

@FlyOverCoderKY

@FlyOverCoderKY FlyOverCoderKY commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Native MCP clients attach extension fields to tool-call _meta. Codex 0.167 adds callId, threadId and sessionId. The strict progressToken-only object rejects these calls before dispatch with an invalid-request response.

Implementation

  • Accept opaque JSON metadata extensions within the existing complete-request limits while validating progressToken.
  • Enforce the five tool argument schemas, authorization scopes, caller ownership and request budgets.
  • Exercise native-shaped metadata through the actual official SDK transport and all five operations in the packaged protocol fixture.
  • Prepare the four synchronized 0.1.6 packages and their exact internal dependency graph.

Validation

The real SDK baseline succeeds without extensions. Two native-shaped requests fail against the old validator. Previous commit d52933b passed actual Node 22 and 24 CI with 1,017 tests across 23 files plus 128 release tests in each lane, with zero skips. CodeQL passed.

All five initial review findings now have targeted coverage and clarified documentation. Current Node 22 and 24 checks each pass 48 focused Memory tests, formatting, types, the example, release checks and registry-backed packaged protocol proofs. Those proofs send opaque extension metadata through all five operations in both legacy and report-aware workflows.

An earlier redundant local full run was interrupted and is recorded as unqualified. Fresh complete CI, CodeQL and the current-head OpenRouter action are required before merge.

The reviewed four-package release will be published after merge. The host integrations will use the verified synchronized graph and matching Support Desk dependency alignment before replaying actual native-client acceptance.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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
🔒 Security Review ✅ Completed 2026-11-11T22:20:21.486333Z d52933b 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.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #14 (review)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: d52933b0648b715d4bcd7e3d47d0b09e220fc318
Judge: openai/gpt-5.6-luna
Cost: $0.2483 (lanes $0.2462 + judge $0.0022)

Lanes

  • openai/gpt-6.1-sol: ok (1 finding(s), 46.1s, 132955+1778 tokens (86787 cached), 4 tool round(s), via Azure, $0.16)
  • z-ai/glm-5.3-flash: ok (4 finding(s), 436.2s, 1869315+55897 tokens (1799424 cached), 28 tool round(s), via InferenceNet, $0.0901)

Findings

🔵 Issue 1 — Non-discriminating metadata node-budget regression

tests/agent-security.test.ts:544 · nit · identified by openai/gpt-6.1-sol

The maxNodes: 16 case still passes if metadata is entirely omitted from node-budget accounting: the ordinary tool-call envelope already exceeds that limit. Consequently, this regression cannot detect the metadata-specific budget bypass it claims to prevent.

parseKnowledgeAgentJson in packages/mcp/src/schemas.ts counts object keys as well as values and containers. The request in this test has 17 counted nodes before adding _meta, so it receives a capacity rejection independently of the 16-element metadata array. Use a limit that admits the envelope and small metadata but rejects the larger extension, and assert that the small-metadata control reaches dispatch.

I checked the parser, readKnowledgeAgentJsonRequest, the fixture's limit configuration, and the other maxNodes cases in tests/agent-security.test.ts. The production parser currently bounds metadata correctly; this is a defect in the new regression's ability to pin that behavior.

🔵 Issue 2 — Non-JSON _meta test cases only pin whole-body JSON validity, not metadata handling

tests/agent-security.test.ts:585 · nit · identified by z-ai/glm-5.3-flash

If the metadata schema were deleted entirely, the it.each(["NaN", "Infinity", "undefined"]) test would still pass unchanged.

All three cases embed the non-JSON token into the full request body ("_meta":{"value":NaN}), so the entire body is unparseable JSON. The observed 400 invalid_request comes from JSON.parse failing inside parseKnowledgeAgentJson (packages/mcp/src/schemas.ts, after the character scan), before any _meta-specific schema runs. The test therefore cannot fail for any metadata-specific regression and its title ("does not accept non-JSON metadata value") overclaims what is pinned.

The surrounding metadata tests (progressToken bounds, budget ceilings, prototype-named keys) are genuinely metadata-specific; only this one is a generic JSON-validity pin. A rename or a comment noting it exercises the JSON boundary — not the metadata schema — would keep the suite honest for future maintainers.

🔵 Issue 3 — README wording "validating known progressToken values" reads as a value allowlist

packages/mcp/README.md:18 · nit · identified by z-ai/glm-5.3-flash

A host security reviewer reading the package README could conclude the adapter only accepts progress tokens it has previously issued or registered, and misjudge the trust boundary when approving the 0.1.6 adoption.

The code (packages/mcp/src/mcp.ts:57-60) validates only the progressToken shape — a string of at most 128 characters or a safe integer — not membership in any set of known values. The parallel sentence in docs/RELEASING.md:92 ("retaining known progress-token validation") attaches "known" to the validation, which is accurate; the README sentence attaches it to "values". Rephrasing to "retaining the existing progress-token validation" removes the ambiguity.

🔵 Issue 4 — Broadened _meta acceptance on initialize, ping, tools/list and notifications is untested

packages/mcp/src/mcp.ts:60 · nit · identified by z-ai/glm-5.3-flash

The documented claim "accepts bounded opaque MCP params._meta extensions" can silently diverge from actual behavior on four of the six envelopes it applies to.

The single metadata schema feeds basicParams, which the change effectively enables for initialize params, ping params, tools/list params, notifications/initialized params (via the rpcNotification refine) and notifications/cancelled params (via cancelledParams) — not just tools/call. That breadth is spec-correct, but every new test in tests/agent-security.test.ts and the fixture's mcpCall exercise only tools/call. If a later refactor splits these envelopes and gives, say, initialize its own strict _meta object, no test would fail while the README/RELEASING contract still advertises acceptance.

I checked tests/agent-transports.conformance.test.ts, tests/agent-reports.test.ts, and the fixture for any existing _meta coverage of those methods — there is none. One raw-envelope test (e.g., initialize with extension metadata returning 200, and a notification with _meta returning 202) would pin the shared-schema behavior the docs now promise.

🔵 Issue 5 — Versioned agent API contract doc omits the new _meta acceptance policy

docs/AGENT_API.md:279 · nit · identified by z-ai/glm-5.3-flash

When 0.1.6 is tagged and published, the frozen wire contract at that tag will not document a wire-visible behavior change that the release notes advertise.

AGENTS.md designates docs/AGENT_API.md as required reading before changing transport boundaries, and this PR changes exactly that boundary: request params._meta now accepts bounded opaque extensions on every MCP envelope. The "MCP composition" section records neighboring details (strict UTF-8 reader, bounded client metadata/capabilities, stateless servers, JSON-mode framing) but says nothing about request _meta, so a host auditing the contract alone cannot verify the "bounded, non-authoritative, never stored" claims that docs/RELEASING.md and packages/mcp/README.md make. No sentence in the doc becomes false — the gap is omission, verified by grepping the doc for _meta, metadata, and extension wording.

A short paragraph in the MCP composition section (acceptance scope, ceilings shared with the complete message, non-authority, non-persistence) would keep the tag-frozen contract complete for the release.

Workflow run

Comment thread tests/agent-security.test.ts Resolved
Comment thread tests/agent-security.test.ts Resolved
Comment thread packages/mcp/README.md Resolved
Comment thread packages/mcp/src/mcp.ts Resolved
@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author
  • r1-5 fixed in d5faa3d. AGENT_API MCPcontract describes sixenvelopeacceptance, complete-message bounds, noauthority/persistence/result/fetch/commandderivation; OAuthmetadata distinguished.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: d5faa3da900690174951487f83c3f08386059dd5
Judge: openai/gpt-5.6-luna (repaired(canonical+1): source coverage preserved before publication cap)
Cost: $0.1437 (lanes $0.1428 + judge $0.0009)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 17.3s, 51054+477 tokens (29139 cached), 3 tool round(s), via Azure, $0.0687)
  • z-ai/glm-5.3-flash: ok (1 finding(s), 289.7s, 1333791+30927 tokens (1169024 cached), 30 tool round(s), via Crusoe, $0.0741)

Round 2 resolution

  • 5 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (0 bug-severity).

Findings

🟠 Issue 1 — Stale "known progress-token validation" claim survives in docs/RELEASING.md 0.1.6 candidate section

docs/RELEASING.md:92 · risk · identified by z-ai/glm-5.3-flash

This commit's purpose was to correct the metadata documentation: docs/AGENT_API.md now states progressToken keeps only shape validation ("a string of at most 128 characters or a safe integer, without a registered-value allowlist") and packages/mcp/README.md was reworded the same way. packages/mcp/src/mcp.ts confirms the implementation: requestId is z.string().max(128) | safe int inside a catchall(z.unknown()) metadata object — no value registry exists.

docs/RELEASING.md (the "Unpublished 0.1.6 candidate" section added by this PR) still carries the pre-fix wording: "The adapter accepts bounded opaque params._meta values used by native clients while retaining known progress-token validation". Read naturally, that claims validation against known/registered token values, which the code does not implement and which the corrected contract now explicitly denies. A maintainer or host using RELEASING.md to qualify the 0.1.6 release would assume a security property (an allowlist) that does not exist.

Secondary instance of the same stale wording: the pre-existing test title tests/agent-security.test.ts:458 — "retains MCP metadata object and known progress-token validation". Its assertions only pin shape rejection (null/false/0.5/MAX_SAFE_INTEGER + 1/129-char string rejected, 7 accepted), so it is cosmetic, but it repeats the phrase this commit removed from the docs.

What I checked: the implementation schema in packages/mcp/src/mcp.ts, the corrected sentences in docs/AGENT_API.md and packages/mcp/README.md, and a repo-wide grep for "known progress" / "validating known" — only these two instances remain. No prior findings were listed this round, so this is reported as a new finding rather than a resolution.

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed r2-1 in 78349c2. The release notes now state that an optional progressToken must be a string of at most 128 characters or a safe integer. The matching test title uses the same shape terminology. The 48 focused Memory cases, formatting and type checks passed on Node 22 and 24. Fresh current-head GitHub checks and OpenRouter review are running.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 78349c2d12a8a0f59a5e41da7c9bb8bae6dac667
Judge: openai/gpt-5.6-luna
Cost: $0.0523 (lanes $0.0521 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 17.4s, 45498+553 tokens (31114 cached), 3 tool round(s), via Azure, $0.0491)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 45.0s, 24465+1597 tokens (10240 cached), 3 tool round(s), via Inceptron, $0.0031)

Round 3 resolution

  • ✅ r2-1 fixed correctly — Stale "known progress-token validation" claim survives in docs/RELEASING.md 0.1.6 candidate section: docs/RELEASING.md:92–93 now explicitly describes the optional progressToken as a string of at most 128 characters or a safe integer, without a registered-value allowlist. This matches the schema in packages/mcp/src/mcp.ts and the existing API documentation.

The renamed security test accurately describes shape validation; its rejection cases and assertions remain unchanged. Repository refere…

  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY
FlyOverCoderKY merged commit b2946e1 into main Nov 11, 2026
5 checks passed
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