Skip to content

ci: format fetch-spec-types output with prettier#1782

Open
felixweinberger wants to merge 2 commits intomainfrom
fweinberger/fetch-spec-types-prettier
Open

ci: format fetch-spec-types output with prettier#1782
felixweinberger wants to merge 2 commits intomainfrom
fweinberger/fetch-spec-types-prettier

Conversation

@felixweinberger
Copy link
Copy Markdown
Contributor

Formats the output of scripts/fetch-spec-types.ts with prettier before writing to disk, so the nightly update-spec-types workflow produces lint-clean output.

Motivation and Context

The nightly update-spec-types workflow has been failing since lefthook was added in #1003. The pre-push hook runs pnpm run lint:all, which rejects the freshly-fetched spec.types.ts because it uses the upstream spec repo's formatting (double quotes, different line wrapping) rather than this repo's prettier config.

Last night's run (March 26) failed with:

[warn] src/types/spec.types.ts
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
error: failed to push some refs

This also means nightly PRs will now show only semantic diffs instead of ~100KB of formatting noise.

How Has This Been Tested?

Ran pnpm run fetch:spec-types locally — output now passes pnpm --filter @modelcontextprotocol/core lint. The resulting diff against main is 6 lines (commit SHA header + @nullable + @maxItems 100 annotations) instead of 118KB.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Uses prettier's Node API (resolveConfig + format) to pick up .prettierrc.json automatically, so any future config changes apply without touching this script.

Heads up: once this lands and the nightly runs, the resulting PR will revert extensions?: { [key: string]: JSONObject } back to { [key: string]: object } in ClientCapabilities/ServerCapabilities — the JSONObject variant was a manual edit in #1630 that diverges from the upstream spec. If JSONObject is the intended type, it should be changed in schema/draft/schema.ts upstream.

The nightly update-spec-types workflow is failing because lefthook's
pre-push hook (added in #1003) runs `pnpm run lint:all`, which rejects
the freshly-fetched spec.types.ts for not matching prettier style.

Format the output via prettier's Node API using the project config
before writing it to disk. This also reduces nightly PR diffs to only
semantic changes, not formatting noise.
@felixweinberger felixweinberger requested a review from a team as a code owner March 27, 2026 11:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

⚠️ No Changeset found

Latest commit: 59ef872

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1782

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1782

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1782

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1782

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1782

commit: 59ef872

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

LGTM, straightforward fix to format fetched spec types with prettier before writing.

Extended reasoning...

Overview

This PR modifies a single CI script (scripts/fetch-spec-types.ts) to run prettier on the fetched spec types before writing them to disk. The change adds 3 lines of prettier API calls (resolveConfig, format) and removes the direct writeFileSync of unformatted content. This fixes the nightly update-spec-types workflow which has been failing since lefthook pre-push hooks were added.

Security risks

None. This is a build/CI script that formats code before writing it locally. No user input, no network-facing code, no auth changes.

Level of scrutiny

Low scrutiny appropriate. This is a small, mechanical change to a CI helper script. The prettier API usage is standard and idiomatic (resolveConfig + format with filepath for parser inference). The script is not production code — it runs during development/CI to sync upstream spec types.

Other factors

  • No bugs were found by the automated analysis.
  • No outstanding reviewer comments to address.
  • No changeset needed since this is a CI-only change with no version bump implications.
  • The code correctly uses spread to merge the resolved config with the filepath option, which is the standard prettier Node API pattern.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

LGTM — straightforward fix to format fetched spec types with prettier so the nightly CI workflow stops failing on lint.

Extended reasoning...

Overview

This PR modifies a single CI script (scripts/fetch-spec-types.ts) to add prettier formatting before writing the fetched spec types to disk. The change is 3 lines of new code: importing prettier, resolving the project config, and formatting the content before writing. This fixes the nightly update-spec-types workflow which has been failing because lefthook runs lint checks on push.

Security risks

None. This is a build/CI script that runs locally or in CI, not production code. The prettier API usage is standard (resolveConfig + format) with no user-controlled inputs beyond what was already there.

Level of scrutiny

Low scrutiny appropriate. This is a small, mechanical change to a CI helper script. The implementation follows the standard prettier Node API pattern and the motivation is clearly explained with a concrete CI failure example.

Other factors

  • No outstanding reviewer comments to address
  • No bugs found by the bug hunting system
  • No changeset needed (CI-only change, no version bump)
  • The PR description helpfully notes a downstream effect (JSONObject vs object reversion) which shows good communication but is not a concern with this PR itself
  • prettier is already a devDependency in the project

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