Repository navigation
fix(app): offer Claude Code and Codex setup commands next to the CLI installer #3708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5701abb
a385200
b8ae566
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| Bring back the Claude Code and Codex CLI commands in the MCP setup panel, next to the `hdx mcp install` command, so connecting an agent no longer needs another CLI installed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| // Per-host snippet builders for the "Connect your AI assistant" | ||
| // section. Each builder takes a `DeploymentShape` (URL + access | ||
| // key) and returns the install primitive for one host: a deep link | ||
| // or a JSON config block. Nothing here emits a shell command with the | ||
| // key in it, since that lands in shell history; `hdx mcp install` | ||
| // covers the CLI-configured hosts instead. | ||
| // key) and returns the install primitive for one host: a CLI | ||
| // one-liner, a deep link, or a JSON config block. | ||
| // | ||
| // Pure functions only. Component-level state (host picker) lives | ||
| // in `McpInstallPanel.tsx`. Keeping the builders here makes unit | ||
|
|
@@ -22,6 +20,17 @@ | |
| */ | ||
| export const SERVER_NAME = 'clickstack'; | ||
|
|
||
| /** | ||
| * Environment variable the Codex CLI snippet reads the bearer token | ||
| * from. The current `codex mcp add` command has no `--header` flag; | ||
| * for a Streamable HTTP server with bearer auth it accepts | ||
| * `--bearer-token-env-var <NAME>` and reads the token from that env | ||
| * var at connect time (see https://developers.openai.com/codex/mcp). | ||
| * We emit an `export` line for the same name so the copy-paste is | ||
| * self-contained. | ||
| */ | ||
| export const CODEX_TOKEN_ENV_VAR = 'CLICKSTACK_ACCESS_KEY'; | ||
|
|
||
| export interface DeploymentShape { | ||
| /** Origin used to build the MCP URL, e.g. `https://example.com/api`. */ | ||
| apiUrl: string; | ||
|
|
@@ -30,10 +39,14 @@ export interface DeploymentShape { | |
| } | ||
|
|
||
| export interface BuiltSnippets { | ||
| /** Claude Code CLI one-liner. */ | ||
| claudeCode: string; | ||
| /** Cursor `cursor://` deep link. */ | ||
| cursor: string; | ||
| /** VS Code + Copilot `vscode:mcp/install` deep link. */ | ||
| vscode: string; | ||
| /** OpenAI Codex CLI one-liner. */ | ||
| codexCli: string; | ||
| /** OpenCode JSON config under an `mcp` block (uses `type: "remote"`). */ | ||
| openCode: string; | ||
| /** Canonical `mcpServers` JSON block for any other host. */ | ||
|
|
@@ -104,6 +117,69 @@ function buildUrl(deployment: DeploymentShape): string { | |
| return `${base}/mcp`; | ||
| } | ||
|
|
||
| /** | ||
| * Escape a value for safe inclusion inside a double-quoted shell | ||
| * argument. Defensive: today's `accessKey` is a UUIDv4 with no | ||
| * shell metacharacters, but a future format that permits `"`, `$`, | ||
| * `\`, or backtick would otherwise turn a copy-paste install into a | ||
| * shell-injection vector. | ||
| */ | ||
| function shellEscape(value: string): string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 P2 — Once the snippets read the key with Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| return value.replace(/(["\\$`])/g, '\\$1'); | ||
| } | ||
|
|
||
| /** | ||
| * Wrap a value in double quotes with the metacharacters escaped, | ||
| * for use as a standalone shell argument (e.g. the right-hand side | ||
| * of an `export`). | ||
| */ | ||
| function shellQuoteValue(value: string): string { | ||
| return `"${shellEscape(value)}"`; | ||
| } | ||
|
|
||
| /** | ||
| * Quote and escape a header value for safe inclusion inside a | ||
| * double-quoted `--header "Name: value"` shell argument. | ||
| */ | ||
| function shellQuoteHeader(name: string, value: string): string { | ||
| return `--header "${name}: ${shellEscape(value)}"`; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 P1 — The Claude Code command fails when a
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond |
||
|
|
||
| function headerArgs(headers: Record<string, string>): string { | ||
| return Object.entries(headers) | ||
| .map(([key, value]) => shellQuoteHeader(key, value)) | ||
| .join(' '); | ||
| } | ||
|
|
||
| /** | ||
| * Claude Code `mcp add` one-liner: `claude mcp add <name> | ||
| * --transport http <url> --header "..."`. Claude passes the bearer | ||
| * token inline as an `Authorization` header. | ||
| */ | ||
| function buildClaudeOneLiner(deployment: DeploymentShape): string { | ||
| const url = buildUrl(deployment); | ||
| const headers = buildHeaders(deployment); | ||
| return `claude mcp add ${SERVER_NAME} --transport http ${url} ${headerArgs(headers)}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 P2 — Claude Code command puts the raw access key in the command line, so it ends up in shell history The copied command contains Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has come up in discussion and has been deemed ok
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 P2 — Claude Code command omits Without Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| } | ||
|
|
||
| /** | ||
| * OpenAI Codex CLI `mcp add` command. Unlike Claude Code, the | ||
| * current Codex CLI (see https://developers.openai.com/codex/mcp) | ||
| * does not accept `--transport` or `--header`; its Streamable HTTP | ||
| * form is `codex mcp add <name> --url <url>` and bearer auth is | ||
| * supplied via `--bearer-token-env-var <ENV_VAR>`, which reads the | ||
| * token from the named environment variable rather than embedding | ||
| * it in the command. We prepend an `export` for that variable so | ||
| * the snippet is a self-contained copy-paste. | ||
| */ | ||
| function buildCodexOneLiner(deployment: DeploymentShape): string { | ||
| const url = buildUrl(deployment); | ||
| const token = deployment.accessKey || '<accessKey>'; | ||
| const exportLine = `export ${CODEX_TOKEN_ENV_VAR}=${shellQuoteValue(token)}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 P2 — Codex snippet writes Using Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| const addLine = `codex mcp add ${SERVER_NAME} --url ${url} --bearer-token-env-var ${CODEX_TOKEN_ENV_VAR}`; | ||
| return `${exportLine}\n${addLine}`; | ||
| } | ||
|
|
||
| /** | ||
| * Cursor `cursor://` deep link. Documented Cursor MCP install | ||
| * scheme: name in the query string, config as base64-encoded JSON. | ||
|
|
@@ -202,8 +278,10 @@ export function buildCliInstallCommand(deployment: DeploymentShape): string { | |
| */ | ||
| export function buildAllSnippets(deployment: DeploymentShape): BuiltSnippets { | ||
| return { | ||
| claudeCode: buildClaudeOneLiner(deployment), | ||
| cursor: buildCursorDeeplink(deployment), | ||
| vscode: buildVSCodeDeeplink(deployment), | ||
| codexCli: buildCodexOneLiner(deployment), | ||
| openCode: buildOpenCodeJsonBlock(deployment), | ||
| jsonBlock: buildMcpJsonBlock(deployment), | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 P2 — The Codex note tells users to set the variable in their shell profile but gives no way to do it
After the command runs, the key exists only in the current shell, so Codex breaks in every new terminal. Users get no snippet for the profile step and will likely paste the key as plain text into
.zshrc. Either give a copyable profile line that reads the key from a secret store or file, or point Codex users to the CLI installer, which writeshttp_headersinto a 0600~/.codex/config.toml(packages/cli/src/mcp/install.ts:254-276).Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond