From 0fc7d3977f16ce8c99ac1605420f1a1b4c5d5f75 Mon Sep 17 00:00:00 2001 From: "Reichenbach, Michael" <755327+Silthus@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:53:57 +0000 Subject: [PATCH 1/3] fix(skills): read the project token and host from project-get The mcp-analytics skill and the eight omnibus instrument-* skills told an agent with no project token to call the PostHog MCP tool projects-get for the project's api_token, and the omnibus skills read a region field from it for the host. projects-get lists the organization's projects without the token or a region, so the agent got neither and fell back to asking the person. project-get with no ID returns the active project's api_token and api_host; the skills now call it, and use projects-get only to find another project's ID when the active one may be wrong. Co-Authored-By: Claude Opus 5.5 --- context/skills/mcp-analytics/description.md | 4 ++-- .../skills/omnibus/instrument-error-tracking/description.md | 4 ++-- .../skills/omnibus/instrument-feature-flags/description.md | 4 ++-- context/skills/omnibus/instrument-integration/description.md | 4 ++-- .../skills/omnibus/instrument-llm-analytics/description.md | 4 ++-- context/skills/omnibus/instrument-logs/description.md | 4 ++-- context/skills/omnibus/instrument-metrics/description.md | 4 ++-- .../omnibus/instrument-product-analytics/description.md | 4 ++-- context/skills/omnibus/instrument-tracing/description.md | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/context/skills/mcp-analytics/description.md b/context/skills/mcp-analytics/description.md index 977d422c..aab0a9dd 100644 --- a/context/skills/mcp-analytics/description.md +++ b/context/skills/mcp-analytics/description.md @@ -471,8 +471,8 @@ Keep the server's existing error handling: if `main` doesn't return a `Result`, ### STEP 5: Wire up credentials - Check existing env files (`.env`, `.env.local`, etc.) for a PostHog project token. If a valid `phc_…` token and host are already set, reference those and skip the rest of this step. -- If the token is missing, use the PostHog MCP server's `projects-get` tool to fetch the project's `api_token`. If multiple projects come back, ask the user which to use. If the MCP server isn't connected, ask the user for their project token directly. -- Host: `https://us.i.posthog.com` for US Cloud, `https://eu.i.posthog.com` for EU Cloud. +- If the token is missing, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this server sends to, ask the user which to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server isn't connected, ask the user for their project token directly. +- Host: the `api_host` field of the same `project-get` response. Without it, `https://us.i.posthog.com` for US Cloud, `https://eu.i.posthog.com` for EU Cloud. - Write `POSTHOG_PROJECT_TOKEN` and `POSTHOG_HOST` to the appropriate env file and reference them in code (`process.env.*` in JS, `os.environ.get(...)` in Python) — never hardcode the token. - **TypeScript / JavaScript and Python:** a missing token must never stop the server. Both clients run disabled without one, so read it optionally and never throw on it, in development either: on STDIO the client launches the server, and a crash only shows up as a failed connection. Warn on stderr instead. Nothing loads an env file on its own, and an MCP client may start the server from another directory, so tell the user to set the variables in the `env` block of their MCP client's server config. For a start script, use the loader the project already has; if it has none, use Node's `--env-file-if-exists=.env` (Node 22.9 or later). Don't add `dotenv` to a STDIO server without `quiet: true`: by default it prints to stdout, which corrupts the stream. - **Go:** write only `POSTHOG_PROJECT_TOKEN` and read it with `os.Getenv`; the host goes in `posthog.Config.Endpoint` as in STEP 4. Go doesn't load `.env` files on its own, so tell the user to export the variable (or load it the way the project already loads config). diff --git a/context/skills/omnibus/instrument-error-tracking/description.md b/context/skills/omnibus/instrument-error-tracking/description.md index f1ca5b47..82e51d26 100644 --- a/context/skills/omnibus/instrument-error-tracking/description.md +++ b/context/skills/omnibus/instrument-error-tracking/description.md @@ -44,8 +44,8 @@ STEP 6: Upload source maps (frontend/mobile only). STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. - List the key names in `.env.example`, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create `.env.example` if the project has none. Never put real values in it. diff --git a/context/skills/omnibus/instrument-feature-flags/description.md b/context/skills/omnibus/instrument-feature-flags/description.md index 7eadedaa..5fd313a6 100644 --- a/context/skills/omnibus/instrument-feature-flags/description.md +++ b/context/skills/omnibus/instrument-feature-flags/description.md @@ -38,8 +38,8 @@ STEP 5: Instrument the feature. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. - List the key names in `.env.example`, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create `.env.example` if the project has none. Never put real values in it. diff --git a/context/skills/omnibus/instrument-integration/description.md b/context/skills/omnibus/instrument-integration/description.md index d52b32c4..89f59828 100644 --- a/context/skills/omnibus/instrument-integration/description.md +++ b/context/skills/omnibus/instrument-integration/description.md @@ -38,8 +38,8 @@ STEP 5: Identify users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file (e.g. `.env.local` for Next.js, `.env` for others) using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. - List the key names in `.env.example`, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create `.env.example` if the project has none. Never put real values in it. diff --git a/context/skills/omnibus/instrument-llm-analytics/description.md b/context/skills/omnibus/instrument-llm-analytics/description.md index 02b29678..5719692b 100644 --- a/context/skills/omnibus/instrument-llm-analytics/description.md +++ b/context/skills/omnibus/instrument-llm-analytics/description.md @@ -40,8 +40,8 @@ STEP 5: Link to users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. - List the key names in `.env.example`, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create `.env.example` if the project has none. Never put real values in it. diff --git a/context/skills/omnibus/instrument-logs/description.md b/context/skills/omnibus/instrument-logs/description.md index 1086e649..bd982579 100644 --- a/context/skills/omnibus/instrument-logs/description.md +++ b/context/skills/omnibus/instrument-logs/description.md @@ -41,8 +41,8 @@ STEP 6: Add structured properties. STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OpenTelemetry endpoint, use the same host as above with the path `/v1`: `https://us.i.posthog.com/v1` (US) or `https://eu.i.posthog.com/v1` (EU). - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-metrics/description.md b/context/skills/omnibus/instrument-metrics/description.md index df026120..2efec9cd 100644 --- a/context/skills/omnibus/instrument-metrics/description.md +++ b/context/skills/omnibus/instrument-metrics/description.md @@ -36,8 +36,8 @@ STEP 5: Keep cardinality low. STEP 6: Set up environment variables. (Skip if the PostHog SDK is already configured — `posthog.metrics` reuses the SDK's existing project token.) - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP metrics endpoint, use the same host as above with the path `/i/v1/metrics`: `https://us.i.posthog.com/i/v1/metrics` (US) or `https://eu.i.posthog.com/i/v1/metrics` (EU), with the project token as an `Authorization: Bearer` header. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-product-analytics/description.md b/context/skills/omnibus/instrument-product-analytics/description.md index fe2a3284..876b3dc1 100644 --- a/context/skills/omnibus/instrument-product-analytics/description.md +++ b/context/skills/omnibus/instrument-product-analytics/description.md @@ -53,8 +53,8 @@ STEP 8: Add error tracking. STEP 9: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. - List the key names in `.env.example`, or the env template the project already uses, with placeholder values, so the next developer knows what to set. Create `.env.example` if the project has none. Never put real values in it. diff --git a/context/skills/omnibus/instrument-tracing/description.md b/context/skills/omnibus/instrument-tracing/description.md index a8f38c40..bece62bd 100644 --- a/context/skills/omnibus/instrument-tracing/description.md +++ b/context/skills/omnibus/instrument-tracing/description.md @@ -61,9 +61,9 @@ STEP 6: Link spans to people and sessions. (Optional.) STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, 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 token instead. + - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - Use the project token (it starts with `phc_`). Do not use a personal API key (it starts with `phx_`). - - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, check the `projects-get` MCP response for a `region` field — `US` maps to `https://us.i.posthog.com`, `EU` maps to `https://eu.i.posthog.com`. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. + - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP traces endpoint, use the same host as above with the path `/i/v1/traces`: `https://us.i.posthog.com/i/v1/traces` (US) or `https://eu.i.posthog.com/i/v1/traces` (EU), with the project token as an `Authorization: Bearer` header. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. From 4eebdd81cf128d27b121f11a4e25ad355715426a Mon Sep 17 00:00:00 2001 From: "Reichenbach, Michael" <755327+Silthus@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:15:21 +0000 Subject: [PATCH 2/3] fix(skills): ask which project when the organization has several The first commit read the token from the active project and asked only when that project "may not be" the app's, which an agent cannot check. The active project is shared state on the MCP key, so in an organization with several projects the agent could write another project's token with no error. List the projects with projects-get, ask when more than one comes back, as the skills did before, then read api_token and api_host from project-get with the chosen id. Co-Authored-By: Claude Opus 5.5 --- context/skills/mcp-analytics/description.md | 2 +- context/skills/omnibus/instrument-error-tracking/description.md | 2 +- context/skills/omnibus/instrument-feature-flags/description.md | 2 +- context/skills/omnibus/instrument-integration/description.md | 2 +- context/skills/omnibus/instrument-llm-analytics/description.md | 2 +- context/skills/omnibus/instrument-logs/description.md | 2 +- context/skills/omnibus/instrument-metrics/description.md | 2 +- .../skills/omnibus/instrument-product-analytics/description.md | 2 +- context/skills/omnibus/instrument-tracing/description.md | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/context/skills/mcp-analytics/description.md b/context/skills/mcp-analytics/description.md index aab0a9dd..1a28d6d5 100644 --- a/context/skills/mcp-analytics/description.md +++ b/context/skills/mcp-analytics/description.md @@ -471,7 +471,7 @@ Keep the server's existing error handling: if `main` doesn't return a `Result`, ### STEP 5: Wire up credentials - Check existing env files (`.env`, `.env.local`, etc.) for a PostHog project token. If a valid `phc_…` token and host are already set, reference those and skip the rest of this step. -- If the token is missing, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this server sends to, ask the user which to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server isn't connected, ask the user for their project token directly. +- If the token is missing, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server isn't connected, ask the user for their project token directly. - Host: the `api_host` field of the same `project-get` response. Without it, `https://us.i.posthog.com` for US Cloud, `https://eu.i.posthog.com` for EU Cloud. - Write `POSTHOG_PROJECT_TOKEN` and `POSTHOG_HOST` to the appropriate env file and reference them in code (`process.env.*` in JS, `os.environ.get(...)` in Python) — never hardcode the token. - **TypeScript / JavaScript and Python:** a missing token must never stop the server. Both clients run disabled without one, so read it optionally and never throw on it, in development either: on STDIO the client launches the server, and a crash only shows up as a failed connection. Warn on stderr instead. Nothing loads an env file on its own, and an MCP client may start the server from another directory, so tell the user to set the variables in the `env` block of their MCP client's server config. For a start script, use the loader the project already has; if it has none, use Node's `--env-file-if-exists=.env` (Node 22.9 or later). Don't add `dotenv` to a STDIO server without `quiet: true`: by default it prints to stdout, which corrupts the stream. diff --git a/context/skills/omnibus/instrument-error-tracking/description.md b/context/skills/omnibus/instrument-error-tracking/description.md index 82e51d26..a699b48c 100644 --- a/context/skills/omnibus/instrument-error-tracking/description.md +++ b/context/skills/omnibus/instrument-error-tracking/description.md @@ -44,7 +44,7 @@ STEP 6: Upload source maps (frontend/mobile only). STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-feature-flags/description.md b/context/skills/omnibus/instrument-feature-flags/description.md index 5fd313a6..5c71e254 100644 --- a/context/skills/omnibus/instrument-feature-flags/description.md +++ b/context/skills/omnibus/instrument-feature-flags/description.md @@ -38,7 +38,7 @@ STEP 5: Instrument the feature. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-integration/description.md b/context/skills/omnibus/instrument-integration/description.md index 89f59828..f21ab3f3 100644 --- a/context/skills/omnibus/instrument-integration/description.md +++ b/context/skills/omnibus/instrument-integration/description.md @@ -38,7 +38,7 @@ STEP 5: Identify users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file (e.g. `.env.local` for Next.js, `.env` for others) using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-llm-analytics/description.md b/context/skills/omnibus/instrument-llm-analytics/description.md index 5719692b..4672fef0 100644 --- a/context/skills/omnibus/instrument-llm-analytics/description.md +++ b/context/skills/omnibus/instrument-llm-analytics/description.md @@ -40,7 +40,7 @@ STEP 5: Link to users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-logs/description.md b/context/skills/omnibus/instrument-logs/description.md index bd982579..63174bd7 100644 --- a/context/skills/omnibus/instrument-logs/description.md +++ b/context/skills/omnibus/instrument-logs/description.md @@ -41,7 +41,7 @@ STEP 6: Add structured properties. STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OpenTelemetry endpoint, use the same host as above with the path `/v1`: `https://us.i.posthog.com/v1` (US) or `https://eu.i.posthog.com/v1` (EU). - Write these values to the appropriate env file using the framework's naming convention. diff --git a/context/skills/omnibus/instrument-metrics/description.md b/context/skills/omnibus/instrument-metrics/description.md index 2efec9cd..db6cc510 100644 --- a/context/skills/omnibus/instrument-metrics/description.md +++ b/context/skills/omnibus/instrument-metrics/description.md @@ -36,7 +36,7 @@ STEP 5: Keep cardinality low. STEP 6: Set up environment variables. (Skip if the PostHog SDK is already configured — `posthog.metrics` reuses the SDK's existing project token.) - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP metrics endpoint, use the same host as above with the path `/i/v1/metrics`: `https://us.i.posthog.com/i/v1/metrics` (US) or `https://eu.i.posthog.com/i/v1/metrics` (EU), with the project token as an `Authorization: Bearer` header. - Write these values to the appropriate env file using the framework's naming convention. diff --git a/context/skills/omnibus/instrument-product-analytics/description.md b/context/skills/omnibus/instrument-product-analytics/description.md index 876b3dc1..41a0f31c 100644 --- a/context/skills/omnibus/instrument-product-analytics/description.md +++ b/context/skills/omnibus/instrument-product-analytics/description.md @@ -53,7 +53,7 @@ STEP 8: Add error tracking. STEP 9: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-tracing/description.md b/context/skills/omnibus/instrument-tracing/description.md index bece62bd..4d470f8b 100644 --- a/context/skills/omnibus/instrument-tracing/description.md +++ b/context/skills/omnibus/instrument-tracing/description.md @@ -61,7 +61,7 @@ STEP 6: Link spans to people and sessions. (Optional.) STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `project-get` tool with no ID to read the active project's `api_token`. If the active project may not be the one this app sends to, ask the user which project to use, find its ID with `projects-get`, and pass it to `project-get`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - Use the project token (it starts with `phc_`). Do not use a personal API key (it starts with `phx_`). - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP traces endpoint, use the same host as above with the path `/i/v1/traces`: `https://us.i.posthog.com/i/v1/traces` (US) or `https://eu.i.posthog.com/i/v1/traces` (EU), with the project token as an `Authorization: Bearer` header. From df377cc5db1909de1f95a321b01d18aec54fa30e Mon Sep 17 00:00:00 2001 From: "Reichenbach, Michael" <755327+Silthus@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:47:35 +0000 Subject: [PATCH 3/3] fix(skills): confirm the project before writing its token The judge found that the skills now write the token of the only project projects-get lists without a word to the user. projects-get lists only the MCP key's active organization, so an app that belongs to another organization would silently send to the wrong project. Before this PR the lookup never returned a token, so the agent always asked. Name the project from project-get and confirm it with the user before writing the token. Co-Authored-By: Claude Opus 5.5 --- context/skills/mcp-analytics/description.md | 2 +- context/skills/omnibus/instrument-error-tracking/description.md | 2 +- context/skills/omnibus/instrument-feature-flags/description.md | 2 +- context/skills/omnibus/instrument-integration/description.md | 2 +- context/skills/omnibus/instrument-llm-analytics/description.md | 2 +- context/skills/omnibus/instrument-logs/description.md | 2 +- context/skills/omnibus/instrument-metrics/description.md | 2 +- .../skills/omnibus/instrument-product-analytics/description.md | 2 +- context/skills/omnibus/instrument-tracing/description.md | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/context/skills/mcp-analytics/description.md b/context/skills/mcp-analytics/description.md index 1a28d6d5..31de55ba 100644 --- a/context/skills/mcp-analytics/description.md +++ b/context/skills/mcp-analytics/description.md @@ -471,7 +471,7 @@ Keep the server's existing error handling: if `main` doesn't return a `Result`, ### STEP 5: Wire up credentials - Check existing env files (`.env`, `.env.local`, etc.) for a PostHog project token. If a valid `phc_…` token and host are already set, reference those and skip the rest of this step. -- If the token is missing, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server isn't connected, ask the user for their project token directly. +- If the token is missing, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this server should send to. If the MCP server isn't connected, ask the user for their project token directly. - Host: the `api_host` field of the same `project-get` response. Without it, `https://us.i.posthog.com` for US Cloud, `https://eu.i.posthog.com` for EU Cloud. - Write `POSTHOG_PROJECT_TOKEN` and `POSTHOG_HOST` to the appropriate env file and reference them in code (`process.env.*` in JS, `os.environ.get(...)` in Python) — never hardcode the token. - **TypeScript / JavaScript and Python:** a missing token must never stop the server. Both clients run disabled without one, so read it optionally and never throw on it, in development either: on STDIO the client launches the server, and a crash only shows up as a failed connection. Warn on stderr instead. Nothing loads an env file on its own, and an MCP client may start the server from another directory, so tell the user to set the variables in the `env` block of their MCP client's server config. For a start script, use the loader the project already has; if it has none, use Node's `--env-file-if-exists=.env` (Node 22.9 or later). Don't add `dotenv` to a STDIO server without `quiet: true`: by default it prints to stdout, which corrupts the stream. diff --git a/context/skills/omnibus/instrument-error-tracking/description.md b/context/skills/omnibus/instrument-error-tracking/description.md index a699b48c..12f828c4 100644 --- a/context/skills/omnibus/instrument-error-tracking/description.md +++ b/context/skills/omnibus/instrument-error-tracking/description.md @@ -44,7 +44,7 @@ STEP 6: Upload source maps (frontend/mobile only). STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-feature-flags/description.md b/context/skills/omnibus/instrument-feature-flags/description.md index 5c71e254..5c18e3ff 100644 --- a/context/skills/omnibus/instrument-feature-flags/description.md +++ b/context/skills/omnibus/instrument-feature-flags/description.md @@ -38,7 +38,7 @@ STEP 5: Instrument the feature. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-integration/description.md b/context/skills/omnibus/instrument-integration/description.md index f21ab3f3..6b2f3229 100644 --- a/context/skills/omnibus/instrument-integration/description.md +++ b/context/skills/omnibus/instrument-integration/description.md @@ -38,7 +38,7 @@ STEP 5: Identify users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file (e.g. `.env.local` for Next.js, `.env` for others) using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-llm-analytics/description.md b/context/skills/omnibus/instrument-llm-analytics/description.md index 4672fef0..f5119050 100644 --- a/context/skills/omnibus/instrument-llm-analytics/description.md +++ b/context/skills/omnibus/instrument-llm-analytics/description.md @@ -40,7 +40,7 @@ STEP 5: Link to users. STEP 6: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-logs/description.md b/context/skills/omnibus/instrument-logs/description.md index 63174bd7..0b49a94d 100644 --- a/context/skills/omnibus/instrument-logs/description.md +++ b/context/skills/omnibus/instrument-logs/description.md @@ -41,7 +41,7 @@ STEP 6: Add structured properties. STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OpenTelemetry endpoint, use the same host as above with the path `/v1`: `https://us.i.posthog.com/v1` (US) or `https://eu.i.posthog.com/v1` (EU). - Write these values to the appropriate env file using the framework's naming convention. diff --git a/context/skills/omnibus/instrument-metrics/description.md b/context/skills/omnibus/instrument-metrics/description.md index db6cc510..d0e3a155 100644 --- a/context/skills/omnibus/instrument-metrics/description.md +++ b/context/skills/omnibus/instrument-metrics/description.md @@ -36,7 +36,7 @@ STEP 5: Keep cardinality low. STEP 6: Set up environment variables. (Skip if the PostHog SDK is already configured — `posthog.metrics` reuses the SDK's existing project token.) - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP metrics endpoint, use the same host as above with the path `/i/v1/metrics`: `https://us.i.posthog.com/i/v1/metrics` (US) or `https://eu.i.posthog.com/i/v1/metrics` (EU), with the project token as an `Authorization: Bearer` header. - Write these values to the appropriate env file using the framework's naming convention. diff --git a/context/skills/omnibus/instrument-product-analytics/description.md b/context/skills/omnibus/instrument-product-analytics/description.md index 41a0f31c..779fd113 100644 --- a/context/skills/omnibus/instrument-product-analytics/description.md +++ b/context/skills/omnibus/instrument-product-analytics/description.md @@ -53,7 +53,7 @@ STEP 8: Add error tracking. STEP 9: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. diff --git a/context/skills/omnibus/instrument-tracing/description.md b/context/skills/omnibus/instrument-tracing/description.md index 4d470f8b..9ccece74 100644 --- a/context/skills/omnibus/instrument-tracing/description.md +++ b/context/skills/omnibus/instrument-tracing/description.md @@ -61,7 +61,7 @@ STEP 6: Link spans to people and sessions. (Optional.) STEP 7: Set up environment variables. - 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. - If the PostHog project token is missing, use the project token that the tool or CLI which started this setup already gave you (for example in its output or instructions). - - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. + - If it gave you none, call the PostHog MCP server's `projects-get` tool to list the projects. If more than one comes back, ask the user which project to use. Then call `project-get` with that project's `id` and read its `api_token`. Before you write the token, tell the user the project's `name` and confirm it is the one this app should send to. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead. - Use the project token (it starts with `phc_`). Do not use a personal API key (it starts with `phx_`). - For the PostHog host URL: use the host that the tool or CLI which started this setup already gave you. If it gave you none, use the `api_host` field of the `project-get` response. If you still have no host from the calling tool, the MCP response, or existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud. - For the OTLP traces endpoint, use the same host as above with the path `/i/v1/traces`: `https://us.i.posthog.com/i/v1/traces` (US) or `https://eu.i.posthog.com/i/v1/traces` (EU), with the project token as an `Authorization: Bearer` header.