Skip to content

feat: use PostHog MCP projects-get to auto-retrieve API key in instrument skills#25

Closed
MattBro wants to merge 1 commit intomainfrom
matt/use-mcp-for-api-key-in-skills
Closed

feat: use PostHog MCP projects-get to auto-retrieve API key in instrument skills#25
MattBro wants to merge 1 commit intomainfrom
matt/use-mcp-for-api-key-in-skills

Conversation

@MattBro
Copy link
Copy Markdown
Collaborator

@MattBro MattBro commented Apr 13, 2026

Problem

The instrument-* skills (integration, product-analytics, feature-flags, error-tracking, llm-analytics, logs) need the user's PostHog project API key and host URL to write into .env files when setting up the SDK. Currently they either:

  • Ask the user inline ("what's your API key?")
  • Write placeholder values
  • Reference an env-file-tools MCP server that doesn't exist in the plugin context

Meanwhile, the PostHog MCP server is already connected and authenticated via OAuth, and projects-get returns the api_token for every project.

Changes

Updated the env var setup step in all 6 instrument-* SKILL.md files to:

  1. Check if PostHog env vars already exist (skip if so)
  2. Call projects-get from the PostHog MCP to retrieve the api_token
  3. Handle multi-project orgs (ask user which project)
  4. Gracefully fall back to asking the user if MCP isn't connected/authenticated
  5. Default to US/EU Cloud host URLs
  6. Write values using framework-specific env var naming conventions

How did you test this code

  • Verified projects-get returns api_token via the MCP tools
  • Confirmed the env-file-tools MCP references were dangling (not available in plugin context)
  • Audited all 13 skills to confirm only instrument-* skills are affected
  • Checked reference/example files to verify framework-specific env var naming is handled by existing references

Changelog

No - this is an internal skill improvement, not a user-facing feature.

…ment skills

Previously, the instrument-* skills either asked users for their API key
inline, wrote placeholder values, or referenced an env-file-tools MCP
server that isn't available in the plugin context. Now skills use the
already-authenticated PostHog MCP server's projects-get tool to
retrieve the api_token automatically, with graceful fallback if the
MCP server is not connected or authenticated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@skoob13
Copy link
Copy Markdown
Contributor

skoob13 commented Apr 14, 2026

@MattBro, these skills are auto-synced. You should update them in https://github.com/PostHog/context-mill.

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.

2 participants