fix(mcp): sync User-Agent version with package.json and add CLI validation tests#343
fix(mcp): sync User-Agent version with package.json and add CLI validation tests#343aptsalt wants to merge 3 commits intostripe:mainfrom
Conversation
…LI tests - VERSION in userAgent.ts was stuck at 0.3.1 while package.json is 0.3.3 - Add test coverage for validateApiKey, validateStripeAccount, and --tools deprecation Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
| @@ -1,4 +1,5 @@ | |||
| const VERSION = '0.3.1'; | |||
| // Keep in sync with version field in package.json | |||
| const VERSION = '0.3.3'; | |||
There was a problem hiding this comment.
can we use the VERSION constant exported here https://github.com/stripe/ai/blob/main/tools/typescript/src/shared/constants.ts#L8 ?
There was a problem hiding this comment.
Good call! I looked into importing from tools/typescript/src/shared/constants.ts but since @stripe/mcp is a separate package (no dependency on the typescript toolkit), that import won't resolve.
Two options I see:
-
Enable
resolveJsonModule+ import from ownpackage.json— butrootDir: "./src"in tsconfig blocks importing../package.json. Would need to adjust rootDir or add a build-time injection like tsup does for the shared package. -
Replicate the shared pattern — use
process.env.PACKAGE_VERSIONand inject it at build time via the build script.
Which approach do you prefer? Happy to implement either. Option 2 seems most consistent with how the shared toolkit already handles it.
There was a problem hiding this comment.
i like option 2! thank you!
There was a problem hiding this comment.
Done! Just pushed the implementation. userAgent.ts now reads from process.env.PACKAGE_VERSION which gets injected at build time by scripts/inject-version.js same pattern the shared toolkit uses via tsup's define. No more manual version syncing. All tests pass.
matv-stripe
left a comment
There was a problem hiding this comment.
thank you @aptsalt , left a small comment
Replace hardcoded VERSION constant with process.env.PACKAGE_VERSION, injected at build time by scripts/inject-version.js. This mirrors the pattern used by the shared toolkit (tsup define in tools/typescript) and eliminates manual version sync between userAgent.ts and package.json. - userAgent.ts: read VERSION from process.env.PACKAGE_VERSION - scripts/inject-version.js: post-tsc step replaces the env reference with the actual version from package.json - jest.setup.ts: sets PACKAGE_VERSION for test environment - package.json: updated build script to run inject-version.js Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Implemented Option 2! Here's what the new commit does:
const VERSION = process.env.PACKAGE_VERSION || '0.0.0-development';
All 24 tests pass ✅, build injects version correctly ( |
Summary
userAgent.tshardcodedVERSION = '0.3.1'butpackage.jsonis at0.3.3, causing the User-Agent header to report an incorrect version to Stripe serversvalidateApiKey,validateStripeAccount, and--toolsdeprecation handlingChanges
tools/modelcontextprotocol/src/userAgent.ts: Sync hardcoded version to0.3.3(with comment to keep in sync withpackage.json)tools/modelcontextprotocol/src/test/index.test.ts: Add 6 new test cases coveringvalidateApiKey(4 cases),validateStripeAccount(2 cases), and--toolsdeprecation (1 case)Test plan
Related: Noticed during version bump in #330