Skip to content

fix: create-mcp-server bundle resolution + daily CLI checks#50

Merged
hifi-phil merged 4 commits intodevfrom
fix/create-mcp-server-published-cli
Apr 21, 2026
Merged

fix: create-mcp-server bundle resolution + daily CLI checks#50
hifi-phil merged 4 commits intodevfrom
fix/create-mcp-server-published-cli

Conversation

@hifi-phil
Copy link
Copy Markdown
Contributor

Summary

  • fix the published CLIrequire("../../package.json") resolved correctly from source but not from the bundled dist/index.js, so installs via npx @umbraco-cms/create-umbraco-mcp-server crashed on boot in beta.9/10/11. Switched to a JSON import so tsup inlines the version at build time.
  • clearer discover errors + admin creds overridediscover hardcoded admin@test.com / SecurePass1234 and misattributed login failures to the Umbraco 17.3 OAuth first-boot regression. Now accepts UMBRACO_ADMIN_EMAIL / UMBRACO_ADMIN_PASSWORD, and a discriminated AutoCreateFailure type routes each failure mode to the right guidance.
  • catch future bundle regressions before publish — added a --version flag plus a PR-time bundle smoke step (node dist/index.js --version) that would have caught the bug immediately, and a daily scheduled workflow that exercises the full E2E + the currently-published npm artifact. On failure it opens a GitHub issue @-mentioning the repo owner for email delivery via GitHub's notification system.

Why now

The bundle bug shipped through three releases (beta.9, beta.10, beta.11) because every existing E2E imports src/... and never runs the bundled output. The smoke step + scheduled run close that gap.

Test plan

  • npm test -w packages/create-mcp-server (121 passed)
  • npm run compile -w packages/create-mcp-server
  • npm run test:e2e -w packages/create-mcp-server locally (19/19 passed after rebuild)
  • node packages/create-mcp-server/dist/index.js --version prints 17.0.0-beta.11
  • Monitor CI on this PR
  • Trigger scheduled-daily.yml via workflow_dispatch once merged to verify the scheduled job works

Follow-up

  • @hifi-phil in scheduled-daily.yml is inferred from commit trailers — correct if wrong.
  • This fix needs to ship in a release (beta.12) to reach users on npm; the local repo is already unaffected after rebuild.

🤖 Generated with Claude Code

hifi-phil and others added 4 commits April 21, 2026 08:46
The CLI read its own version with createRequire(import.meta.url) +
require("../../package.json"). The path was correct from the source
file (src/init/nuget-versions.ts), but after tsup bundles everything
into dist/index.js, import.meta.url points at dist/, so the same
relative path no longer finds package.json — npx-installed CLIs
crashed with "Cannot find module '../../package.json'" at module load.

Switched to `import pkg from "../package.json" with { type: "json" }`
so the version is inlined by the bundler at build time.

Also adds a --version / -v flag to the CLI so the bundled entry point
can be smoke-tested without going through the interactive scaffold
prompts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`discover` auto-creates the API user by logging in as admin first.
Previously it hardcoded admin@test.com / SecurePass1234 (the PSW
unattended-install defaults), so running discover against an
existing Umbraco with different admin credentials failed with an
error that misleadingly pointed at the Umbraco 17.3 OAuth-client
first-boot regression.

- UMBRACO_ADMIN_EMAIL / UMBRACO_ADMIN_PASSWORD env vars override
  the defaults, so users with an existing Umbraco can auto-create
  the API user without editing source.
- Distinguish admin-login failures from bearer-token failures via
  a discriminated AutoCreateFailure type. Only the bearer-token
  case surfaces the "restart Umbraco" advice; admin-login failures
  now say what actually went wrong and point at the env vars.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The existing CLI E2E imports source (src/...) and never executes
the bundled dist/index.js, so bundle-time regressions (like the
recent require("../../package.json") bug) don't surface until
after publish. Two additions close that gap:

- PR suite: a new "CLI bundle smoke test" step after the CLI
  build runs `node dist/index.js --version`. Takes seconds and
  fails immediately on module-load errors in the bundled output.

- Scheduled daily workflow (scheduled-daily.yml, 06:00 UTC):
  - published-cli-smoke: runs `npx @umbraco-cms/create-umbraco-mcp-server@latest`
    (and @beta) against a clean runner, scaffolds, installs, and
    typechecks. Catches regressions in the currently-published
    artifact (bundle bugs, missing files entries, broken deps).
  - cli-e2e: the full 19-step deterministic E2E, identical to the
    PR job but scheduled so tooling drift surfaces without waiting
    for a PR.
  - notify-on-failure: opens a GitHub issue @-mentioning the repo
    owner on failure, so notifications go out via GitHub's email
    system without needing SMTP secrets.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the explicit notify-on-failure job. GitHub already emails the
user who last modified a scheduled workflow file when a run fails
(provided Actions notifications are enabled), so the separate issue
job was redundant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hifi-phil hifi-phil merged commit 5e918f0 into dev Apr 21, 2026
7 checks passed
@hifi-phil hifi-phil mentioned this pull request Apr 21, 2026
6 tasks
hifi-phil added a commit that referenced this pull request Apr 21, 2026
Fixes                                                                                                                                                                                                                                                                      
  -----                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                             
  - `@umbraco-cms/create-umbraco-mcp-server`: resolve bundled package.json                                                                                                                                                                                                   
    via an inlined JSON import. The CLI read its own version with                                                                                                                                                                                                            
    `require("../../package.json")`, which resolved correctly from source                                                                                                                                                                                                    
    but not from the bundled `dist/index.js` — npx-installed CLIs crashed                                                                                                                                                                                                    
    with "Cannot find module '../../package.json'" at module load. Bug                                                                                                                                                                                                       
    shipped undetected through beta.9, beta.10, and beta.11 because every                                                                                                                                                                                                    
    existing E2E imports source (`../../src/...`) and never executes the                                                                                                                                                                                                     
    bundled output. (#50)                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                             
  Features                                                                                                                                                                                                                                                                   
  --------                                         

  - `UMBRACO_ADMIN_EMAIL` / `UMBRACO_ADMIN_PASSWORD` env var overrides for                                                                                                                                                                                                   
    `discover`, so the API user can be auto-created against an existing
    Umbraco whose admin credentials differ from PSW's unattended-install                                                                                                                                                                                                     
    defaults. (#50)                                                                                                                                                                                                                                                          
  - `--version` / `-v` flag on the CLI. (#50)                                                                                                                                                                                                                                
  - `check-api-user.ts` now distinguishes admin-login failures from                                                                                                                                                                                                          
    bearer-token failures via a discriminated `AutoCreateFailure` type.                                                                                                                                                                                                      
    Only the bearer-token case surfaces the "restart Umbraco (17.3                                                                                                                                                                                                           
    regression)" advice; admin-login failures point at the env vars. (#50)                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                             
  CI hardening                                                                                                                                                                                                                                                               
  ------------                                                                                                                                                                                                                                                               
                                                   
  - PR bundle smoke test: `node dist/index.js --version` runs after the CLI                                                                                                                                                                                                  
    build. Catches module-load regressions in the bundled output in
    seconds. Would have failed on the PR that introduced the package.json                                                                                                                                                                                                    
    bug. (#50)                                                                                                                                                                                                                                                               
  - Scheduled daily workflow (scheduled-daily.yml, 06:00 UTC): a                                                                                                                                                                                                             
    `published-cli-smoke` job that scaffolds and compiles against the                                                                                                                                                                                                        
    currently-published @latest (and @beta) npm artifact, plus a full                                                                                                                                                                                                        
    `cli-e2e` job so tooling drift (Umbraco updates, PSW updates, .NET SDK                                                                                                                                                                                                   
    changes) surfaces without waiting for a PR. Failure notifications rely                                                                                                                                                                                                   
    on GitHub's built-in scheduled-workflow emails. (#50)
@hifi-phil hifi-phil deleted the fix/create-mcp-server-published-cli branch April 27, 2026 09:39
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