Skip to content

fix(mcp): derive server version from package - #107785

Closed
gesh wants to merge 1 commit into
masterfrom
posthog/mcp-server-version-from-package
Closed

gesh wants to merge 1 commit into
masterfrom
posthog/mcp-server-version-from-package

Conversation

@gesh

@gesh gesh commented Sep 28, 2026

Copy link
Copy Markdown
Member

Problem

MCP clients and analytics can report a stale server version after the package version changes.

Why: The server duplicates package metadata in a string constant. The two values can diverge.

Refs #101133

Changes

  • The server now reads its advertised version from the MCP package metadata.
  • MCP Analytics: Existing $mcp_server_version events use the package version. This change adds no event or property.
  • No user interface changes.

How did you test this code?

  • pnpm --filter=@posthog/mcp run typecheck
  • pnpm --filter=@posthog/mcp run test:hono -- tests/hono/analytics.test.ts tests/hono/request-context.test.ts

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Release status

  • No feature flag controls this change
  • This change is behind a feature flag and is not available to users
  • This change makes a previously flagged feature available to everyone

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Codex, GPT-5.6

Skills invoked: writing-simplified-technical-english and writing-pr-descriptions.

The open PR search found no matching version-source fix. The change uses existing package metadata and adds no new analytics behavior.


Created with PostHog Desktop

Generated-By: PostHog Desktop
Task-Id: f297bd3a-39f9-4b2c-8c5e-ba8a282424d7
@gesh gesh self-assigned this Sep 28, 2026
@gesh
gesh requested a review from a team September 28, 2026 14:41
@trunk-io

trunk-io Bot commented Sep 28, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@gesh gesh added the skip-inkeep-docs Use this label to skip an Inkeep docs PR in posthog.com label Sep 28, 2026 — with PostHog
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Trunk lane — non-backend lane (svc:mcp)

This PR is assigned to the non-backend lane (svc:mcp). It does not run backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[Low risk] Updates a version constant to read from package metadata.

The version source is sound, but the test expectations should be updated before merging so the next package bump does not fail the Hono suite.

Reviews (1) · Last reviewed commit: "fix(mcp): derive server version from pac..."


export const MCP_SERVER_NAME = 'PostHog'
export const MCP_SERVER_VERSION = '1.0.0'
export const MCP_SERVER_VERSION = packageJson.version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Version bumps will fail tests When services/mcp/package.json is bumped, this value will change, but two assertions in request-context.test.ts still require '1.0.0'. The intended version update will fail the Hono tests. Derive those expectations from the package version too.

Prompt To Fix With AI
This is a comment left during a code review.
Path: services/mcp/src/lib/constants.ts
Line: 24

Comment:
**Version bumps will fail tests** When `services/mcp/package.json` is bumped, this value will change, but two assertions in `request-context.test.ts` still require `'1.0.0'`. The intended version update will fail the Hono tests. Derive those expectations from the package version too.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: PostHog/posthog/.coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: e8a14e7a-4e06-49d9-936d-e050a24d80ce

📥 Commits

Reviewing files that changed from the base of the PR and between e1fcc28 and 9ef067b.

📒 Files selected for processing (1)
  • services/mcp/src/lib/constants.ts

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

MCP_SERVER_VERSION now uses the version from package.json instead of the hard-coded value 1.0.0.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 9ef06

The server will advertise the MCP package’s declared version instead of a separate literal. The supplied response paths use this value, and no actionable merge risk is established beyond normal checks.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description is complete and relevant. It explains the problem, user-visible change, testing performed, release status, documentation status, and agent involvement. The Agent context does not inclu…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-inkeep-docs Use this label to skip an Inkeep docs PR in posthog.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant