Skip to content

feat(integrations): migrate PostHog, Sentry and X MCP onto the shared setup flow#4199

Merged
muddlebee merged 2 commits into
mainfrom
feat/setup-specs-batch5
Jul 22, 2026
Merged

feat(integrations): migrate PostHog, Sentry and X MCP onto the shared setup flow#4199
muddlebee merged 2 commits into
mainfrom
feat/setup-specs-batch5

Conversation

@muddlebee

Copy link
Copy Markdown
Collaborator

Part of #4168. Follows #4191 (batch 1), #4194 (batch 2), #4196 (batch 3), and #4197 (batch 4).

Describe the changes you have made in this PR -

Fifth migration batch onto the shared setup flow: PostHog MCP, Sentry MCP, X MCP.

These were the "constant / derived fields" gap from #4168 — their CLI handlers hard-code mode/command/args (and never prompt for them) with comments like "do NOT reintroduce a transport selection." Rather than inventing SetupField.constant for this batch, the specs only declare the fields a user is actually asked for. For these three hosted/streamable-HTTP servers, PostHogMCPConfig / SentryMCPConfig / XMCPConfig already default mode to streamable-http and leave command/args empty — the same values every setup path was hard-coding — so omitting them from the persisted credentials is equivalent to writing them.

OpenClaw is intentionally not in this batch. Its CLI hard-codes mode=stdio, but OpenClawConfig's default is streamable-http. Omitting mode would silently flip transport. That one still needs SetupField.constant (or an explicit persist of the fixed stdio mode) before it can migrate.

What this fixes for the three that did migrate

Previously opensre integrations setup posthog_mcp|sentry_mcp|x_mcp only wrote the integration store. The matching wizard configurators already wrote store + keyring + .env. Same deploy-preflight footgun as the earlier batches. Both surfaces now go through apply_setup.

Demo/Screenshot for feature changes and bug fixes -

Env round-trip guard for the three MCP specs:

$ uv run python -m pytest tests/integrations/test_setup_spec_env_round_trip.py -q
.......                                                                  [100%]
7 passed

CLI spec-setup suite including the new handlers:

$ uv run python -m pytest tests/integrations/test_cli_spec_setup.py -q
.............................s                                           [100%]
29 passed, 1 skipped

(The skip is x_mcp: every required field has a default URL, so the "blank required field" case does not apply.)


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

#4168 listed these four as blocked on a new SetupField.constant feature. I checked whether that feature is actually required for each:

  1. posthog_mcp / sentry_mcp / x_mcp — setup hard-codes the same defaults the pydantic config models already have for transport. Omitting those fields from the spec is safer than prompting for them (which configure_from_spec / _run_spec_setup would do for every field today) and avoids inventing a new spec feature for a case the config layer already covers.
  2. openclaw — setup's fixed stdio conflicts with the config default (streamable-http). Omitting would change behavior. Left hand-rolled until SetupField.constant exists.

Key pieces:

  • integrations/{posthog_mcp,sentry_mcp,x_mcp}/setup.py — prompted fields only; verifier wired explicitly.
  • config/constants/{posthog_mcp,sentry_mcp,x_mcp}.py — shared env names for writer + catalog reader.
  • Wizard MCP configurators collapse to configure_from_spec; REST PostHog/Sentry configurators left alone (batch 2 owns those).

Edge cases: optional project_id / host / auth_token clear every tier when blanked; URL defaults are offered as prompt prefills and applied by apply_setup so enter-to-accept works without a typed value.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

- add IntegrationSetupSpec for posthog_mcp, sentry_mcp, and x_mcp
- route CLI + wizard through apply_setup so keyring/.env stay in sync
- omit fixed transport fields; config defaults already match hosted HTTP
- share MCP env-var names via config/constants and catalog readers
- extend CLI + env round-trip coverage for the three MCP specs
@github-actions

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This is the fifth batch in a series of migrations (#4168) that brings PostHog MCP, Sentry MCP, and X MCP onto the shared apply_setup setup flow. The core fix is that opensre integrations setup <service> previously only persisted to the integration store, while the wizard counterparts wrote store + keyring + .env; now both surfaces go through apply_setup and all three tiers are written consistently.

  • Three new config/constants/{posthog_mcp,sentry_mcp,x_mcp}.py modules centralize the env var names used by both setup.py and the integration's from_env() loader, and the catalog reader in _catalog_impl.py is updated to use those constants.
  • Three integrations/{posthog_mcp,sentry_mcp,x_mcp}/setup.py spec files declare only the fields a user is prompted for; transport fields (mode, command, args) and read_only are intentionally omitted because PostHogMCPConfig, SentryMCPConfig, and XMCPConfig already carry model-level defaults (mode=\"streamable-http\", read_only=True, bearer_token=\"\") that match what every setup path previously hard-coded.
  • The wizard configurators for PostHog MCP and Sentry MCP collapse to one-liner configure_from_spec(...) calls; the hand-rolled CLI handlers do likewise with _run_spec_setup(...).

Confidence Score: 5/5

Safe to merge — the migration is mechanical and each new spec was verified against the model's field defaults before omitting fields from the spec.

Every field omitted from the three new specs (mode, command, args, read_only, bearer_token) has a model-level default that exactly matches what the old hand-rolled handlers hard-coded, so no credentials change at runtime. The core fix — that opensre integrations setup now writes to the integration store, keyring, and .env instead of just the store — is exercised by both the env round-trip test and the CLI spec-setup suite.

No files require special attention.

Important Files Changed

Filename Overview
integrations/posthog_mcp/setup.py New spec file declaring url / auth_token / project_id for PostHog MCP; transport fields intentionally omitted since PostHogMCPConfig defaults match the previously hard-coded values.
integrations/sentry_mcp/setup.py New spec file declaring url / auth_token / host (optional) for Sentry MCP; same transport-omission rationale as PostHog MCP.
integrations/x_mcp/setup.py New spec file declaring url (defaulted) / auth_token (optional) for X MCP; bearer_token intentionally omitted since XMCPConfig defaults it to empty string and it was always empty in setup.
integrations/cli.py Replaces three hand-rolled setup handlers with _run_spec_setup(SPEC) one-liners; removes direct imports of build/validate functions no longer needed by cli.py itself.
surfaces/cli/wizard/configurators/posthog.py _configure_posthog_mcp() collapses from ~95 lines to a one-liner; SECONDARY import retained and used by the unchanged _configure_posthog() intro string.
surfaces/cli/wizard/configurators/sentry.py _configure_sentry_mcp() collapses to a one-liner; SECONDARY retained for use by _configure_sentry()'s intro string.
tests/integrations/test_cli_spec_setup.py Adds three new parametrized test cases for the migrated handlers; adds the StopIteration guard for specs where every required field has a default.
tests/integrations/test_setup_spec_env_round_trip.py Extends the env round-trip guard to cover all three new specs; submitted values map cleanly to the declared env var constants.

Reviews (2): Last reviewed commit: "fix(integrations): resolve main conflict..." | Re-trigger Greptile

- merge upstream/main into feat/setup-specs-batch5
- keep batch5 MCP specs alongside batches 2–4 setup migrations
- use shared env constants in posthog/sentry/x MCP config_from_env
@muddlebee

Copy link
Copy Markdown
Collaborator Author

@greptile review

@muddlebee
muddlebee merged commit 24da012 into main Jul 22, 2026
36 of 37 checks passed
@muddlebee
muddlebee deleted the feat/setup-specs-batch5 branch July 22, 2026 17:59
@github-actions

Copy link
Copy Markdown
Contributor

🐉 Legend says enough merged PRs and you ascend. @muddlebee is dangerously close. 🌤️


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

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