Skip to content

Commit cb909f6

Browse files
authored
Merge pull request #116 from PostHog/matt/use-projects-get-for-env-vars
fix: use projects-get MCP tool for env var setup in instrument skills
2 parents f49ae6a + 283bfe0 commit cb909f6

6 files changed

Lines changed: 25 additions & 6 deletions

File tree

transformation-config/skills/omnibus/instrument-error-tracking/description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ STEP 6: Upload source maps (frontend/mobile only).
3636
- Follow the platform-specific reference for upload configuration (build plugins, CI scripts, etc.).
3737

3838
STEP 7: Set up environment variables.
39-
- If an env-file-tools MCP server is connected, use check_env_keys to see which keys already exist, then use set_env_values to create or update the PostHog API key and host.
39+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
40+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
41+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
42+
- Write these values to the appropriate env file using the framework's naming convention.
4043
- Reference these environment variables in code instead of hardcoding them.
4144

4245
STEP 8: Verify and clean up.

transformation-config/skills/omnibus/instrument-feature-flags/description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ STEP 5: Instrument the feature.
3232
- You must read a file immediately before attempting to write it.
3333

3434
STEP 6: Set up environment variables.
35-
- If an env-file-tools MCP server is connected, use check_env_keys to see which keys already exist, then use set_env_values to create or update the PostHog API key and host.
35+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
36+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
37+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
38+
- Write these values to the appropriate env file using the framework's naming convention.
3639
- Reference these environment variables in code instead of hardcoding them.
3740

3841
## Reference files

transformation-config/skills/omnibus/instrument-integration/description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ STEP 5: Identify users.
3030
- If both frontend and backend exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to the server-side code.
3131

3232
STEP 6: Set up environment variables.
33-
- Store the PostHog API key and host in environment variables (e.g. `.env` or framework-specific env files).
33+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
34+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
35+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
36+
- Write these values to the appropriate env file (e.g. `.env.local` for Next.js, `.env` for others) using the framework's naming convention.
3437
- Reference these environment variables in code instead of hardcoding them.
3538

3639
STEP 7: Verify and clean up.

transformation-config/skills/omnibus/instrument-llm-analytics/description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ STEP 5: Link to users.
3636
- Associate LLM generations with identified users via distinct IDs when possible.
3737

3838
STEP 6: Set up environment variables.
39-
- If an env-file-tools MCP server is connected, use check_env_keys then set_env_values to configure the PostHog API key and host.
39+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
40+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
41+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
42+
- Write these values to the appropriate env file using the framework's naming convention.
4043
- Reference these environment variables in code instead of hardcoding them.
4144

4245
## Reference files

transformation-config/skills/omnibus/instrument-logs/description.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ STEP 6: Add structured properties.
3737
- Prefer structured log formats with key-value properties over plain text messages.
3838

3939
STEP 7: Set up environment variables.
40-
- If an env-file-tools MCP server is connected, use check_env_keys then set_env_values to configure the PostHog API key, host, and OpenTelemetry endpoint.
40+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
41+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
42+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
43+
- For the OpenTelemetry endpoint, use `https://us.i.posthog.com/v1` (US) or `https://eu.i.posthog.com/v1` (EU).
44+
- Write these values to the appropriate env file using the framework's naming convention.
4145
- Reference these environment variables in code instead of hardcoding them.
4246

4347
## Reference files

transformation-config/skills/omnibus/instrument-product-analytics/description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ STEP 8: Add error tracking.
4545
- Add PostHog exception capture error tracking to relevant files, particularly around critical user flows and API boundaries.
4646

4747
STEP 9: Set up environment variables.
48-
- If an env-file-tools MCP server is connected, use check_env_keys to see which keys already exist, then use set_env_values to create or update the PostHog API key and host.
48+
- Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step.
49+
- If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead.
50+
- For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud.
51+
- Write these values to the appropriate env file using the framework's naming convention.
4952
- Reference these environment variables in code instead of hardcoding them.
5053

5154
STEP 10: Verify and clean up.

0 commit comments

Comments
 (0)