# Set up with AI

> Let Claude Code, Cursor, Windsurf, VS Code Copilot or ChatGPT install AppHelm for you, using llms.txt, the public docs MCP server, a ready-made prompt and the apphelm init command.

Source: https://apphelm.dev/docs/ai-setup

A coding assistant can install AppHelm into your project, add flags and error capture, and check that the first event arrived. It needs two things: the docs, which are public and need no key, and your product id and keys, which only you can give it.

| What | Needs a key? | Where |
| --- | --- | --- |
| The docs as markdown (`llms.txt`, `llms-full.txt`, `/docs/<slug>.md`) | No | `https://apphelm.dev/llms.txt` |
| The docs MCP server: search, read pages, get install steps | No | `https://apphelm.dev/mcp/docs` |
| `npx @sansavision/apphelm init`: detect the framework and write the code | No, with `--workspace` and `--product`; or log in with `apphelm login` | Your terminal |
| The product MCP server: your flags, issues, insights and data | Yes, a server key | `https://apphelm.dev/mcp` ([MCP servers](https://apphelm.dev/docs/mcp)) |
| Sending events from the installed SDK | Yes, the key for your platform | [Keys, scopes and environments](https://apphelm.dev/docs/keys-and-environments) |

## The docs as markdown

Every docs page is also plain markdown, written for language models:

- `https://apphelm.dev/llms.txt` lists every page with a one-line description and a link to its markdown.
- `https://apphelm.dev/llms-full.txt` is every page in one file.
- `https://apphelm.dev/docs/<slug>.md` is one page, for example `https://apphelm.dev/docs/feature-flags.md`. Add `?lang=python` (or any language id: `nextjs`, `ios`, `go` …) to keep only that language's code.

Code samples in the markdown are labelled with their platform, and links are absolute, so an assistant can follow them.

## The docs MCP server

The docs MCP server is public and read-only. It needs no key, never asks for one and never returns one. It speaks Streamable HTTP at `https://apphelm.dev/mcp/docs`.

| Tool | Takes | Returns |
| --- | --- | --- |
| `list_doc_pages` | nothing | Every page: slug, title, section, description and URLs |
| `search_docs` | `query` (2 to 200 characters), `limit` (1 to 25, default 8) | The best matching sections with a snippet and their URLs |
| `get_doc_page` | `slug`, and optionally `language` | One page as markdown; with `language`, each code sample for that platform only |
| `get_install_plan` | `platform`, and optionally `productId` (`prd_…`) and `workspaceId` (`org_…`) | The install steps for one platform: package source, install command, environment variables, files with code, and how to verify |

`get_install_plan` returns the same plan as the Setup wizard and `apphelm init`. Its keys are placeholders; the assistant must ask you for yours. The platform ids are `nextjs`, `react`, `vue`, `svelte`, `html`, `node`, `react-native`, `ios`, `android`, `python`, `jvm`, `go`, `ruby`, `php`, `flutter`, `dotnet`, `elixir` and `rust`.

The server also offers the `llms.txt` map as a resource (`apphelm-docs://llms.txt`) and a prompt, `install_apphelm`, that tells the assistant how to install AppHelm into the current project.

### Connect your assistant

### Claude Code
Run this in your project. `--scope project` writes it to `.mcp.json` so your team gets it too.

```bash
claude mcp add --transport http --scope project apphelm-docs https://apphelm.dev/mcp/docs
```

### Cursor
Add to `.cursor/mcp.json` in the project (or `~/.cursor/mcp.json` for every project):

```json
{
  "mcpServers": {
    "apphelm-docs": { "url": "https://apphelm.dev/mcp/docs" }
  }
}
```

### Windsurf
Add to `~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "apphelm-docs": { "serverUrl": "https://apphelm.dev/mcp/docs" }
  }
}
```

### VS Code (GitHub Copilot agent mode)
Add to `.vscode/mcp.json`:

```json
{
  "servers": {
    "apphelm-docs": { "type": "http", "url": "https://apphelm.dev/mcp/docs" }
  }
}
```

### Claude and ChatGPT apps
In Claude, add a custom connector with the URL `https://apphelm.dev/mcp/docs` and no authentication. ChatGPT accepts remote MCP servers as custom connectors where your plan allows them; use the same URL and choose no authentication. Without connectors, paste `https://apphelm.dev/llms.txt` into the chat and ask it to read the pages it needs.

## A prompt that installs AppHelm

Paste this into your assistant from the root of your project. It works with or without the docs MCP server.

```text
Install AppHelm (https://apphelm.dev) in this project.

1. Read https://apphelm.dev/llms.txt. If the apphelm-docs MCP server is connected, use it
   (search_docs, get_doc_page, get_install_plan) instead of fetching pages.
2. Work out the platform from the project files (package.json, Podfile or Package.swift,
   build.gradle(.kts), pubspec.yaml, pyproject.toml or requirements.txt, go.mod, Gemfile,
   composer.json, *.csproj, Cargo.toml, mix.exs). Tell me what you found.
3. Get the install plan for that platform (get_install_plan, or
   https://apphelm.dev/docs/install.md?lang=<platform>).
4. Ask me for my workspace id (org_…), product id (prd_…) and the key the plan needs.
   Never invent ids or keys. Put keys only in the environment variables the plan names,
   never in source files that run in a browser or ship in an app, and make sure env files
   with secrets are git-ignored.
5. Add the package and the files from the plan, merging into existing files and keeping my
   code style. Do not overwrite anything without asking.
6. For browser code, wire setConsent({ analytics: true }) to my consent banner, or tell me
   where it has to go: the browser SDK sends nothing until analytics consent is given.
7. Set environment and release from my existing configuration if there is any.
8. Tell me how to check the first event arrived: run the app once, then press Check connection
   in AppHelm Setup. If nothing arrives, turn on the SDK's debug option and read
   https://apphelm.dev/docs/troubleshooting.md.
```

For later work, ask for the feature by name ("add a feature flag around the new checkout", "capture errors with source maps") and the assistant can read the matching page with your language: `get_doc_page` with `slug: "feature-flags"` and `language: "python"`, or `https://apphelm.dev/docs/feature-flags.md?lang=python`.

## The apphelm init command

`npx @sansavision/apphelm init` does the same installation from your terminal, without an assistant. An assistant can run it for you too.

```bash
# With your ids, no login needed:
npx @sansavision/apphelm init --workspace org_… --product prd_…

# Or log in once (opens a browser page an owner or administrator approves), then init finds your ids:
npx @sansavision/apphelm login
npx @sansavision/apphelm init
```

What it does:

- **Detects the platform** from `package.json` (React Native or Expo, Next.js, Nuxt or Vue, SvelteKit or Svelte, React, then server frameworks such as Express, Fastify, Hono, Koa or NestJS) or from files at the project root (`pubspec.yaml`, `Podfile`, `build.gradle`, `pyproject.toml`, `go.mod`, `Gemfile`, `composer.json`, `mix.exs`, `Cargo.toml`, `pom.xml`, `*.csproj`, an Xcode project, `index.html`). `--platform <id>` overrides it.
- **Shows the plan and asks** before changing anything. `--yes` skips the question, `--dry-run` only prints the plan, and without a terminal it prints the plan and changes nothing.
- **Never overwrites.** An environment variable that is already set is kept. A file that exists is left alone and its snippet is printed for you to merge. A TypeScript snippet is printed, not written, in a JavaScript project.
- **Writes keys only to an env file** (`.env.local` for Next.js, React, Vue and Svelte; `.env` for Node, Python, JVM and React Native), adds that file to `.gitignore`, and never puts a server key in code. Keys it was not given are left as commented placeholders to fill in.
- **Installs packages** only with `--install`, and only npm, pnpm, yarn, bun or pip commands, with the package manager your lockfile shows.

| Flag | What it does |
| --- | --- |
| `--dir <path>` | The project to change (default: the current directory) |
| `--platform <id>` | Skip detection |
| `--workspace <org_…>`, `--product <prd_…>` | The ids, when you are not logged in or the key sees several products |
| `--browser-key <ahl_pub_…>` | The browser key to write (or set `APPHELM_BROWSER_KEY`) |
| `--server-key <ahl_live_…>`, `--app-key <ahl_live_…>` | A server key, or an `events:write`-only key for a mobile app |
| `--create-browser-key --origin <https://…>` | Create a browser key for that origin first. Needs a logged-in key with `products:write`. |
| `--yes`, `--dry-run`, `--install`, `--json` | Apply without asking; only print; run the install commands; print JSON for scripts and assistants |

The [CLI reference](https://apphelm.dev/docs/cli) covers `login` and every other command.

## Keep your assistant on track

Commit a short note so every assistant on the team instruments AppHelm the same way. Put it in `AGENTS.md`, `CLAUDE.md`, `.cursor/rules` or `.github/copilot-instructions.md`, whichever your tools read:

```markdown
## AppHelm

- Docs: https://apphelm.dev/llms.txt (MCP: https://apphelm.dev/mcp/docs). Read the page for a
  feature before using it; append `?lang=<our platform>` to a page's .md URL.
- The client is created once in <path/to/apphelm file>. Import it; never create a second one.
- Keys come from environment variables only: <NEXT_PUBLIC_APPHELM_KEY / APPHELM_API_KEY>.
  Never hard-code a key, never put a server key (ahl_live_) in browser or app code.
- Event names are snake_case, object then past-tense verb: `invoice_sent`, `signup_completed`.
  Add properties, not new event names, for variations. Never put emails, names or free text
  in event properties.
- Identify users with our internal user id at sign-in, and reset at sign-out.
- Feature flags: check once where the behaviour forks; the off path must always work.
- Errors: let uncaught errors reach AppHelm; use captureException only where we handle an
  error and still want to know about it.
- Browser: nothing is sent before setConsent({ analytics: true }) from our consent banner.
```

## Operate AppHelm with the product MCP server

Once events flow, the product MCP server at `https://apphelm.dev/mcp` lets an assistant read and change your AppHelm data: list flags and change them, search issues and resolve them, read insights and experiment results. It needs a server key as a Bearer token, and the key's scopes decide which tools work:

```json
{
  "mcpServers": {
    "apphelm": {
      "url": "https://apphelm.dev/mcp",
      "headers": { "Authorization": "Bearer ${APPHELM_API_KEY}" }
    }
  }
}
```

Give it a key with only the scopes the work needs. To let an agent create products and browser keys, create a **Key for an AI agent** in Settings → API keys. [MCP servers](https://apphelm.dev/docs/mcp) lists every tool and its scope.

## Best practices

- **Give the assistant your ids, and the key only through the environment.** Paste ids into the chat; set keys yourself in your env file or secret store when you can, so they never enter a transcript.
- **Review the diff.** Check that the key is read from the environment, that browser code calls `setConsent`, and that server code flushes before exit.
- **Keep docs and code on the same version.** The docs describe SDK 0.8.1. If your project pins an older version, upgrade it or ask the assistant to read that version's changelog.
- **Use the docs server for docs and the product server for data.** The docs server can never see your workspace; the product server can, within its key's scopes.

## Troubleshooting

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| The assistant cannot connect to `https://apphelm.dev/mcp/docs` | The client only supports local (stdio) servers, or an old transport | Update the client, or give it `https://apphelm.dev/llms.txt` to read instead |
| The assistant invented a key or an id | It was not given one | Give it your ids; set keys in the environment yourself. A made-up key is answered `401`. |
| `apphelm init` says it cannot tell the framework | No recognised file at the project root | Run it from the project root, or pass `--platform <id>` |
| `apphelm init` says it needs your workspace and product | Not logged in, and no ids given | Pass `--workspace org_… --product prd_…`, or run `apphelm login` first |
| `--create-browser-key` is refused | The logged-in key lacks `products:write` | Log in again and tick `products:write`, or create the browser key in Setup |
| Code was added but nothing arrives | Consent not given, wrong origin or key, or the process exits before sending | See [Troubleshooting](https://apphelm.dev/docs/troubleshooting) |
