Skip to content

Include the version in User-Agent, from a single source of truth #40

Closed

Description

@dangrondahl

Description

src/client/kosli-client.ts:93 sends a bare User-Agent: kosli-mcp-server with every API request. Adding the version — kosli-mcp-server/0.5.0 — would let the Kosli backend tell versions apart: which releases are actually in use, whether a regression correlates with a version, and how quickly users pick up new releases.

There is already a version string, and it is wrong

src/index.ts:17 registers the MCP server as:

const server = new McpServer({
  name: "kosli",
  version: "0.1.0",
});

The package is at 0.5.0. Every MCP client has been told this server is 0.1.0 since shortly after the first release. So this isn't only about adding a version to one header — it's about having one place the version comes from, because the copy we already have has silently rotted.

Two constraints that rule out the obvious approaches

1. Reading package.json at runtime breaks the .mcpb bundle.
scripts/pack-mcpb.sh:31 copies package.json into the staging dir so npm install --omit=dev can run, then line 34 deletes it before zipping. So readFileSync(new URL("../package.json", import.meta.url)) works under npx and throws for every Claude Desktop bundle user.

2. Importing ../package.json breaks the compiler layout.
tsconfig.json sets rootDir: "src", so a JSON import from outside src/ moves the outDir layout and dist/index.js is no longer where bin expects it — even though resolveJsonModule is on.

Proposal

Add src/version.ts exporting a single VERSION constant, consumed by both kosli-client.ts and index.ts. Guard it with a test that reads package.json and asserts they match — tests run from the repo root, so the test can do what the shipped code can't. Drift then fails CI instead of shipping.

Alternative worth considering: generate src/version.ts during npm run build from package.json. No manual step, but it adds a generated file to the build and a stale copy in a fresh checkout before the first build.

Either way, CLAUDE.md's Releasing section should list the version bump as touching package.json and this constant together.

Tasks

  • Add src/version.ts with a single VERSION constant
  • Use it in the User-Agent header in KosliClient
  • Use it in the McpServer registration, replacing the stale 0.1.0
  • Add a test asserting it matches package.json
  • Update the two existing User-Agent assertions in test/client/kosli-client.test.ts (lines 106, 217)
  • Note the coupling in CLAUDE.md's Releasing section

Activity

  1. added
    bug
    enhancement
    on Aug 11, 2026
  2. self-assigned this
    on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions