Skip to content

fix(helper-mcp): sdk ^1.32.0, zod ^4.6.7 and the patched express chain (abilityai/trinity-enterprise#1117) - #4291

Merged
vybe merged 7 commits into
devfrom
AndriiPasternak31/ent1117-s2-helper-mcp-zod4
Nov 6, 2026
Merged

vybe merged 7 commits into
devfrom
AndriiPasternak31/ent1117-s2-helper-mcp-zod4

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

Part of abilityai/trinity-enterprise#1117.

Journey Impact: none: dependency update of the published docs MCP helper; the ask_trinity tool behaves the same for valid input

Problem

src/helper-mcp is the published trinity-docs-mcp npm package. It has seven open Critical/High Dependabot alerts:

The zod advisory has no 3.x fix. Because this is a published package, consumers resolve from the package.json ranges and never see our lockfile. Updating the lock alone would leave every fresh install vulnerable.

Fix

  • Ranges: @modelcontextprotocol/sdk moves from ^1.30.0 to ^1.32.0, and zod from ^3.24.1 to ^4.6.7.
  • Lock: sdk 1.32.2, zod 4.6.7, proxy-addr 2.0.8, body-parser 2.4.0 (content-type 2.1.0), qs 6.17.1, fast-uri 3.1.9, hono 4.13.16, @hono/node-server 2.1.6, ip-address 10.7.6. Nothing is removed.
  • Version:
    • package.json moves to 0.2.0, because a runtime dependency changed major.
    • The server now reads its reported version (serverInfo.version and the startup log) from its own package.json instead of a hard-coded string. The publish workflow writes the release version into that field before it builds, so every release reports the version that is actually installed.
    • A package.json with no version, an empty version or a non-string version stops the server at startup.
  • zod 4 needs no source change.

What clients will notice:

  • Advertised schema: the ask_trinity input schema no longer contains "additionalProperties": false. This comes from zod 4: sdk 1.32.2 with zod 3 still emits it. Unknown keys were accepted and dropped before, and still are; they are not sent to the docs endpoint.
  • Error wording: validation messages read differently, for example Too big: expected string to have <=4000 characters at question instead of String must contain at most 4000 character(s) at question.
  • Error shape for plain text: unchanged. A rejected call returns a JSON-RPC result with isError: true and text starting MCP error -32602: Input validation error, and the docs endpoint is not called.
  • Text with characters outside the Basic Multilingual Plane (emoji, for example):
    • zod 4 counts length in code points, where zod 3 counted UTF-16 code units. Such a question now passes the schema up to 4000 code points.
    • The tool's own guard then enforces the 4000-unit cap. It answers isError: true with The question is N characters — the limit is 4000. Shorten it and try again., not the −32602 text.
    • No input that was rejected before is accepted now, and the docs endpoint is still not called for any of them.

Release

This merges to dev and reaches main with the next release cut. Neither step publishes 0.2.0 on its own.

Why nothing publishes automatically: on a push to main, publish-helper-mcp.yml derives the version from the latest helper-mcp-v* tag. None exists, so it computes 0.1.0, finds that version on npm, and skips.

The CI publish step has never succeeded:

  • The workflow has run seven times.
  • Five runs (2026-07-26 to 2026-08-06) were made while the package was still named @abilityai/trinity-docs-mcp. All five reached npm publish and failed there; their logs have expired.
  • The only release, 0.1.0, was published by hand.
  • Both runs since the rename to trinity-docs-mcp skipped. So publishing through npm trusted publishing (OIDC) has never run for this package.

Before pushing the tag, a maintainer with the npm login opens npmjs.com → trinity-docs-mcp → Settings → Trusted Publisher and confirms there is a GitHub Actions publisher with:

  • Organization: the owner exactly as GitHub reports it, Abilityai (capital A)
  • Repository: trinity
  • Workflow filename: publish-helper-mcp.yml
  • Environment: none
  • Publishing directly with npm publish allowed, not only staged publishing

npm does not validate these fields when they are saved, and it treats them as case-sensitive and exact.

Release steps:

  1. Wait until the release that carries this change from dev reaches main. Then let that push's Publish Helper MCP to npm run finish. It should log Publishing version: 0.1.0 and skip.
  2. Push the tag helper-mcp-v0.2.0 on that main commit. Order matters: if the tag exists before a main run reads tags, that run would publish 0.2.1 as well.

After the tag, check:

  • The tag's run shows Publish to npm succeeded.
  • npm view trinity-docs-mcp version returns 0.2.0.
  • npm view [email protected] dist.attestations is not empty.
  • npx -y [email protected] logs v0.2.0 ready.
  • The seven alerts close. They track main.

Evidence

  • npm audit: before, critical 1, high 3, moderate 5; after, found 0 vulnerabilities.
  • tsc: clean before and after. The test files also type-check under strict mode.
  • npm test: 26/26 before, 50/50 after.
  • scripts/smoke.mjs (pack, install, stdio): green on Node 18.20.8, 22 and 24, reporting v0.2.0. With the version rewritten to 0.2.1, as the publish workflow does, it reports v0.2.1.

The new tests pin:

  • Size limit:
    • A 4001-character question is rejected, both through the Client and as the raw JSON-RPC frame. The frame is a result, not an error.
    • A question of exactly 4000 characters is accepted.
  • Invalid arguments: a number, null, an array or a missing value for question, and null or a number for session_id, each return the −32602 result naming the field. The endpoint is not called.
  • Astral text:
    • 4001 UTF-16 units in 2001 code points is stopped by the tool's guard.
    • 4000 units is accepted.
    • 4001 code points is rejected by the schema.
  • Unknown keys are accepted and not forwarded.
  • The exact advertised schema.
  • Version: the reported version equals package.json's, and a manifest with no version, an empty version or a numeric version is refused.
  • Dependency floors: the lockfile copies of the sdk, zod, proxy-addr and body-parser, and the declared sdk and zod ranges, stay at or above the first patched versions.

These tests fail on the old dependencies:

  • the schema test, with + additionalProperties: false;
  • the first astral test, because zod 3 rejects it with the −32602 text;
  • all four floor checks, for example node_modules/proxy-addr is 2.0.7, below 2.0.8.

Mutation checks:

  • Loosening question to z.coerce.string() fails three of the invalid-argument tests.
  • Loosening session_id to nullable or any fails the session cases.
  • Hard-coding the version fails the version test once the version is rewritten.
  • Falling back to a default version instead of refusing fails the manifest cases.
  • Reverting the sdk, in the lock or in the range, fails its floor check.

Fresh install of the packed tarball outside the repo, with no lockfile, on Node 18.20.8 (the lowest engines allows) and on Node 24: initialize, tools/list, ask_trinity and the oversize rejection all behave as above.

Not covered

  • The npm publish itself. It runs only from main plus the tag. It needs the trusted-publisher check above, and it would be this workflow's first successful publish.
  • Owner casing for provenance. package.json has repository.url as git+https://github.com/abilityai/trinity.git, all lowercase, while GitHub reports the owner as Abilityai. npm says that field must exactly match the GitHub repository for provenance. Whether npm compares the owner case-insensitively there, or in the trusted-publisher fields, is not verified. The first tag publish will show it.
  • Node 18 consumers. npm resolves @hono/node-server 1.19.18 there, because 2.x requires Node ≥20. That version is inside a Moderate advisory (GHSA-rmxm-3fg6-px4f, serveStatic). Only the SDK's HTTP server transport uses that code, and this package is stdio-only. Raising engines to >=20 would close it; that is left as a separate decision.
  • Consumer projects that already have zod 3 and install this package directly, not through npx, which installs in isolation. npm can hoist the SDK next to the project's zod 3. The SDK then renders the advertised schema without maxLength and the descriptions. Validation still rejects oversize and invalid input in that layout. 0.1.0 rendered the full schema there, but the README documents only npx.
  • The live docs endpoint. Every check here uses a local stub.

….6.7 (Abilityai/trinity-enterprise#1117)

trinity-docs-mcp is a published npm package, so consumers resolve from the
package.json ranges rather than this lockfile. Raise the SDK floor to
^1.32.0 (fixed releases for the four SDK advisories) and move zod to
^4.6.7 (the zod advisory has no 3.x fix). The lock also picks up the
patched express chain: proxy-addr 2.0.8, body-parser 2.4.0, qs 6.17.1,
fast-uri 3.1.9, hono 4.13.16, @hono/node-server 2.1.6, ip-address 10.7.6.

npm audit: critical 1, high 3, moderate 5 before; 0 after.

Runtime behaviour is unchanged. Under zod 4 the advertised ask_trinity
inputSchema no longer carries additionalProperties:false (extra keys were
and still are accepted), and validation messages are worded differently.
A new test pins the observed contract: an oversize question comes back as
a JSON-RPC result with isError:true and "MCP error -32602: Input
validation error" text, without reaching the docs endpoint.
…ityai/trinity-enterprise#1117)

The previous commit changes a runtime dependency major, so the next
trinity-docs-mcp release should be 0.2.0 rather than an automatic patch.
SERVER_VERSION (reported as serverInfo.version) and package.json now say
0.2.0; the release is cut by pushing the tag helper-mcp-v0.2.0.
…bilityai/trinity-enterprise#1117)

A number, null, an array or a missing value for question, and null or a
number for session_id, each return the -32602 input-validation result
naming the field, and the docs endpoint is never called. A schema that
coerced question to a string would now fail three of these cases.

zod 4 counts a string's length in code points, zod 3 counted UTF-16 code
units. Pin what that means here: 4001 UTF-16 units in 2001 code points
passes the schema and is stopped by the client guard with its own text,
4000 units is accepted, and 4001 code points is still rejected by the
schema. The unknown-key test now also checks the forwarded body.
…ched dependency floors (Abilityai/trinity-enterprise#1117)

SERVER_VERSION was a string literal, so any release whose version the
publish workflow writes into package.json (every automatic patch release)
would report a stale number in serverInfo and the startup log. Read it
from the package's own package.json, which sits one level above both
src/ and dist/ and is always in the published tarball. A missing version
fails at startup instead of reporting an empty one.

Also pin that the lockfile copies of @modelcontextprotocol/sdk, zod,
proxy-addr and body-parser, and the declared sdk and zod ranges, stay at
or above the first patched versions of the advisories fixed here.
…ops startup (Abilityai/trinity-enterprise#1117)

readPackageVersion now takes the manifest URL and is exported, so the
refusal path is tested directly: no version field, an empty version and a
numeric version each throw "package.json at ... has no version", and a
valid version is returned. A version that silently fell back to a default
would fail all three refusal cases.

@obasilakis obasilakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed (code review + /validate-pr, lane B). Approving.

Mutation: reverting package.json/lock to the dev base turns 6/50 tests red (astral text, exact schema, four dependency floors). Local: tsc clean, npm test 50/50, npm audit 0.

Non-blocking:

  • src/helper-mcp/src/server.ts:18 — SERVER_VERSION is read at module load, so a bad package.json throws during import, outside main().catch. Node still exits non-zero, but without the [trinity-docs] fatal: line. Reading it inside createServer/main routes it through the handler.
  • The serverInfo version test passes when the version is hard-coded as "0.2.0", since that equals package.json. Asserting against a version rewritten in the test would pin it.
  • Several cases in ent1117-s2-input-validation.test.ts also pass on zod 3. They are pins, not evidence for the bump.

@AndriiPasternak31
AndriiPasternak31 marked this pull request as ready for review November 6, 2026 19:08
@vybe
vybe merged commit 3acf8ef into dev Nov 6, 2026
29 of 30 checks passed
yunyminaya pushed a commit to yunyminaya/trinity that referenced this pull request Nov 11, 2026
Abilityai/trinity-enterprise#1117) (Abilityai#4291)

* fix(helper-mcp): move to @modelcontextprotocol/sdk ^1.32.0 and zod ^4.6.7 (Abilityai/trinity-enterprise#1117)

trinity-docs-mcp is a published npm package, so consumers resolve from the
package.json ranges rather than this lockfile. Raise the SDK floor to
^1.32.0 (fixed releases for the four SDK advisories) and move zod to
^4.6.7 (the zod advisory has no 3.x fix). The lock also picks up the
patched express chain: proxy-addr 2.0.8, body-parser 2.4.0, qs 6.17.1,
fast-uri 3.1.9, hono 4.13.16, @hono/node-server 2.1.6, ip-address 10.7.6.

npm audit: critical 1, high 3, moderate 5 before; 0 after.

Runtime behaviour is unchanged. Under zod 4 the advertised ask_trinity
inputSchema no longer carries additionalProperties:false (extra keys were
and still are accepted), and validation messages are worded differently.
A new test pins the observed contract: an oversize question comes back as
a JSON-RPC result with isError:true and "MCP error -32602: Input
validation error" text, without reaching the docs endpoint.

* chore(helper-mcp): version 0.2.0 for the zod 4 dependency major (Abilityai/trinity-enterprise#1117)

The previous commit changes a runtime dependency major, so the next
trinity-docs-mcp release should be 0.2.0 rather than an automatic patch.
SERVER_VERSION (reported as serverInfo.version) and package.json now say
0.2.0; the release is cut by pushing the tag helper-mcp-v0.2.0.

* test(helper-mcp): pin wrong-type, null and astral ask_trinity inputs (Abilityai/trinity-enterprise#1117)

A number, null, an array or a missing value for question, and null or a
number for session_id, each return the -32602 input-validation result
naming the field, and the docs endpoint is never called. A schema that
coerced question to a string would now fail three of these cases.

zod 4 counts a string's length in code points, zod 3 counted UTF-16 code
units. Pin what that means here: 4001 UTF-16 units in 2001 code points
passes the schema and is stopped by the client guard with its own text,
4000 units is accepted, and 4001 code points is still rejected by the
schema. The unknown-key test now also checks the forwarded body.

* fix(helper-mcp): report the installed package version and pin the patched dependency floors (Abilityai/trinity-enterprise#1117)

SERVER_VERSION was a string literal, so any release whose version the
publish workflow writes into package.json (every automatic patch release)
would report a stale number in serverInfo and the startup log. Read it
from the package's own package.json, which sits one level above both
src/ and dist/ and is always in the published tarball. A missing version
fails at startup instead of reporting an empty one.

Also pin that the lockfile copies of @modelcontextprotocol/sdk, zod,
proxy-addr and body-parser, and the declared sdk and zod ranges, stay at
or above the first patched versions of the advisories fixed here.

* test(helper-mcp): pin that a package.json without a usable version stops startup (Abilityai/trinity-enterprise#1117)

readPackageVersion now takes the manifest URL and is exported, so the
refusal path is tested directly: no version field, an empty version and a
numeric version each throw "package.json at ... has no version", and a
valid version is returned. A version that silently fell back to a default
would fail all three refusal cases.

(cherry picked from commit 3acf8ef)
vybe added a commit to jordanallenlewis/determinity that referenced this pull request Nov 19, 2026
main carries 7 commits that are not ancestors of dev: the ent#1117 security
back-ports (Abilityai#4291, Abilityai#4294, Abilityai#4314, Abilityai#4315, Abilityai#4399, Abilityai#4400) and the llms.txt refresh
(Abilityai#4287). Every one of them is already on dev in its original form, so this is a
merge with dev's tree kept as-is (strategy ours). It records main as a parent so
the dev -> main release PR no longer conflicts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.

3 participants