Repository navigation
feat: include the version in User-Agent from a single source of truth - #41
Conversation
Requests now send 'kosli-mcp-server/0.5.0' instead of a bare 'kosli-mcp-server', so the backend can tell releases apart. Also fixes a version that had silently rotted: src/index.ts registered the MCP server as 0.1.0, so every client has been told that since shortly after the first release, through to 0.5.0. VERSION is a literal in src/version.ts rather than a read of package.json, because neither alternative works: rootDir is 'src', so importing ../package.json shifts the outDir layout and breaks the bin path; and pack-mcpb.sh strips package.json from the bundle after installing deps, so reading it at runtime throws for .mcpb users. test/version.test.ts closes the loop — tests run from the repo root, so the test can read package.json even though the shipped code cannot. Verified it fails on drift, not just passes when aligned. Closes #40
|
Claude finished @dangrondahl's task in 4m 8s —— View job Review:
|
package.json is the source of truth — release.yml verifies the tag against it and npm publishes from it. src/version.ts is a mirror that exists only because the shipped code cannot read package.json at runtime. Previously that mirror had to be updated by hand, so a contributor could bump package.json and ship a stale VERSION; the test caught it only after the fact. Now npm's version lifecycle hook runs sync-version and stages the result, so 'npm version <x> --no-git-tag-version' moves package.json, package-lock.json, and src/version.ts in one command. Verified end to end: 'npm version 0.5.1 --no-git-tag-version' regenerated src/version.ts at 0.5.1 and staged it, then reverting to 0.5.0 regenerated it again. CONTRIBUTING gains a Versioning section; CLAUDE.md's Releasing section now names package.json as authoritative and covers the PR-then-tag flow the branch ruleset requires.
CLAUDE.md's Conventions bullet still described the bare 'User-Agent: kosli-mcp-server' and said to preserve it — the instruction that would motivate reverting this PR's change. It now documents the versioned form and where the version comes from. Also adds src/version.ts to 'Things not to do' alongside the other generated files. 'Never edit by hand' previously lived only in the Releasing section, which is read at release time rather than at edit time.
The version hook staged only src/version.ts. npm stages nothing itself under --no-git-tag-version, so the documented 'git commit -m' would have committed the new src/version.ts alongside an unbumped package.json — caught by CI, but a confusing half-state in the flow that exists to remove a two-file footgun. Verified: staged output is now all three files, where before it was src/version.ts alone. The semver check also rejected build metadata, which npm accepts (npm version 1.0.0+build.1). Since package.json is written before this hook runs, rejecting a version npm considers valid left the repo bumped with a stale src/version.ts — the exact state this is meant to prevent. '+' is a valid HTTP token character, so nothing downstream needed the restriction. Widened here and in the matching test assertion.
Release prep for **0.6.0**. A draft for now: it gets rebased once #97 (CodeQL) merges, then marked ready. `npm version minor --no-git-tag-version` moves `package.json`, `package-lock.json` and the generated `src/version.ts` together. `manifest.json` gets the version at pack time. Nothing else changes. ## What's in 0.6.0 (since 0.5.0) ###⚠️ Changes that affect existing setups - **No configured org (#65).** `KOSLI_ORG` and the Desktop extension's *Organization* setting are removed. Every org-scoped call names its org through the execute tools' `org` input, so no request lands in an org the caller didn't name. An existing config that still sets `KOSLI_ORG` starts fine and logs that the value is ignored, but calls that relied on the default are now refused until an org is given. - **Node ≥ 22 (#38).** It was ≥ 20. ### Fixes - **Evidence downloads work again (#88, fixes #86).** Since 16 Oct, every `get_attestation_evidence` call failed: our token was forwarded to the pre-signed S3 URL. Text files come back as text, and binary files return a clear error. - **The `.mcpb` bundle starts on Node 22.0 – 22.6 (#87).** It didn't before. - **No known vulnerabilities in the bundled dependencies (#96).** `npm audit --omit=dev` is clean. ### Features - **`org` input on the execute tools (#65).** - **`User-Agent` carries the version (#41):** `kosli-mcp-server/<version>`. ### Dependencies - **Runtime:** `@modelcontextprotocol/sdk` 1.29.0 → 1.32.1 (#29, #71, #79). - **Dev:** TypeScript 7 (#45), with emitted output byte-identical to 5.9. vitest 5 (#93). - **Catalog:** regenerated from the OpenAPI spec (#50, #53, #60, #69, #78). ### Release confidence (CI only) Typecheck of tests and scripts, a stdio smoke test against `dist/` and the unzipped bundle (including Node 22.0.0), `mcpb validate`, and `release.yml` publishing only after every check (#87). There's also a phased Claude review (#90), Dependabot grouping with a 7-day cooldown, and CodeQL (#97). ## Checked locally on this branch - Build, typecheck, 122 tests. - The smoke test reports `server advertises version 0.6.0`, both from `dist/` and from the unzipped bundle. - `kosli-mcp-server-0.6.0.mcpb`: the manifest says 0.6.0 and `mcpb validate` passes. ## Before tagging (after merge) - [ ] Rebase onto `main` once #97 merges, then mark ready. - [ ] Install the 0.6.0 `.mcpb` in Claude Desktop, including an upgrade over 0.5.0 with an org configured. - [ ] Run `KOSLI_API_TOKEN=… KOSLI_SMOKE_ORG=<org> npm run smoke` on `main`. - [ ] Download one piece of evidence via `get_attestation_evidence`. - [ ] `git tag -a v0.6.0 -m "v0.6.0" <merge commit> && git push origin v0.6.0`. `release.yml` does the rest.
Closes #40.
Requests now send
kosli-mcp-server/0.5.0instead of a barekosli-mcp-server, so the backend can tell releases apart.Also fixes a rotted version
src/index.tsregistered the MCP server asversion: "0.1.0". Every MCP client has been told that since shortly after the first release — through 0.2.0, 0.2.1, 0.3.0, 0.4.0 and 0.5.0. It now uses the same constant.Why a literal, not a read of package.json
Both obvious approaches are broken here, which is the whole reason this needed a decision rather than a one-liner:
../package.json—tsconfig.jsonsetsrootDir: "src", so a JSON import from outsidesrc/shifts theoutDirlayout anddist/index.jsis no longer wherebinpoints.scripts/pack-mcpb.shcopiespackage.jsoninto staging fornpm install --omit=dev, then deletes it before zipping. SoreadFileSync(new URL("../package.json", import.meta.url))works undernpxand throws for every Claude Desktop bundle user.So
src/version.tsexports a literal, with the reasoning in a comment so the next person doesn't "improve" it into one of the above.The guard
A literal can drift — that's exactly how
0.1.0survived five releases.test/version.test.tsreadspackage.jsonand asserts they match. Tests run from the repo root, so the test can do what the shipped code can't.I verified the guard fails, rather than only checking it passes:
It also asserts
VERSIONis plain semver, since it's interpolated into a header.Verification
npm run buildclean;npm test67 passed (was 65).dist/client/kosli-client.js:66carries the template literal, anddist/version.jsexports0.5.0.CLAUDE.md's Releasing section now listspackage.jsonandsrc/version.tsas moving together, and recommendsnpm version --no-git-tag-versionso the lockfile keeps pace.