From 5701abbf42a412ef2d215b70adec09d136335150 Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 18:46:15 +1100 Subject: [PATCH 1/3] fix(app): offer Claude Code and Codex setup commands next to the CLI installer The commands read the access key from a hidden prompt, so it stays out of shell history and agent chats. Codex also gets a note that it needs the variable set wherever it runs. Refs HDX-6080 --- .changeset/mcp-manual-claude-codex.md | 8 +++ .../ClickStackOnboarding/McpInstallPanel.tsx | 51 ++++++++++++++++--- .../__tests__/McpInstallPanel.test.tsx | 10 ++++ .../__tests__/installSnippets.test.ts | 42 +++++++++++++++ .../ClickStackOnboarding/installSnippets.ts | 31 +++++++++-- .../__tests__/McpServerSection.test.tsx | 29 +++++++++-- 6 files changed, 157 insertions(+), 14 deletions(-) create mode 100644 .changeset/mcp-manual-claude-codex.md diff --git a/.changeset/mcp-manual-claude-codex.md b/.changeset/mcp-manual-claude-codex.md new file mode 100644 index 000000000..b28d96c2c --- /dev/null +++ b/.changeset/mcp-manual-claude-codex.md @@ -0,0 +1,8 @@ +--- +'@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. The commands ask for the access key at a hidden prompt, so it +stays out of shell history and agent chats. diff --git a/packages/app/src/components/ClickStackOnboarding/McpInstallPanel.tsx b/packages/app/src/components/ClickStackOnboarding/McpInstallPanel.tsx index 6851a0a1d..82f0e43f0 100644 --- a/packages/app/src/components/ClickStackOnboarding/McpInstallPanel.tsx +++ b/packages/app/src/components/ClickStackOnboarding/McpInstallPanel.tsx @@ -2,14 +2,17 @@ import { useMemo, useState } from 'react'; import { Group, SegmentedControl, Stack, Text } from '@mantine/core'; import { IconBraces, + IconBrandOpenai, IconBrandVisualStudio, IconCode, IconRobot, + IconTerminal2, } from '@tabler/icons-react'; import { CopySnippet } from './CopySnippet'; import { DeeplinkInstall } from './DeeplinkInstall'; import { + ACCESS_KEY_ENV_VAR, buildAllSnippets, buildCliInstallCommand, type BuiltSnippets, @@ -17,10 +20,14 @@ import { } from './installSnippets'; // ChatGPT is intentionally absent: no native MCP yet, and bridges are a -// user-side decision better tracked in docs than in this UI. Claude Code -// and Codex are configured through shell commands, which would put the key -// in shell history, so the CLI installer above covers them instead. -type AgentHost = 'cursor' | 'vscode-copilot' | 'opencode' | 'other'; +// user-side decision better tracked in docs than in this UI. +type AgentHost = + | 'claude-code' + | 'cursor' + | 'vscode-copilot' + | 'codex-cli' + | 'opencode' + | 'other'; interface HostChoice { id: AgentHost; @@ -28,8 +35,10 @@ interface HostChoice { } const CHOICES: HostChoice[] = [ + { id: 'claude-code', label: 'Claude Code' }, { id: 'cursor', label: 'Cursor' }, { id: 'vscode-copilot', label: 'VS Code' }, + { id: 'codex-cli', label: 'Codex CLI' }, { id: 'opencode', label: 'OpenCode' }, { id: 'other', label: 'Other' }, ]; @@ -47,10 +56,11 @@ interface McpInstallPanelProps { /** * Host picker plus the install primitive (CLI command, deep link, or JSON - * block) for the chosen host. The access key is masked in every snippet. + * block) for the chosen host. The access key is masked wherever a snippet + * inlines it. */ export default function McpInstallPanel({ deployment }: McpInstallPanelProps) { - const [host, setHost] = useState('cursor'); + const [host, setHost] = useState('claude-code'); const snippets = useMemo(() => buildAllSnippets(deployment), [deployment]); @@ -96,10 +106,14 @@ export default function McpInstallPanel({ deployment }: McpInstallPanelProps) { function HostIcon({ id }: { id: AgentHost }) { switch (id) { + case 'claude-code': + return ; case 'cursor': return ; case 'vscode-copilot': return ; + case 'codex-cli': + return ; case 'opencode': return ; case 'other': @@ -118,8 +132,19 @@ interface HostInstallProps { accessKey: string; } +const SHELL_COMMAND_LABEL = + 'Run in your terminal, then paste your API access key and press Enter. Nothing shows as you paste:'; + function HostInstall({ host, snippets, accessKey }: HostInstallProps) { switch (host) { + case 'claude-code': + return ( + + ); + case 'cursor': return ( ); + case 'codex-cli': + return ( + + + + Codex reads {ACCESS_KEY_ENV_VAR} each time it starts, so also set it + in your shell profile. + + + ); + case 'opencode': return ( { + it('defaults to the Claude Code command, which prompts for the key', () => { + renderPanel(); + expect( + screen.getByText(/^read -rs CLICKSTACK_ACCESS_KEY && claude mcp add/), + ).toBeInTheDocument(); + expect(screen.queryByText(new RegExp(ACCESS_KEY))).not.toBeInTheDocument(); + }); +}); + describe('McpInstallPanel CLI installer', () => { it('shows the npx command, which carries no access key', () => { renderPanel(); diff --git a/packages/app/src/components/ClickStackOnboarding/__tests__/installSnippets.test.ts b/packages/app/src/components/ClickStackOnboarding/__tests__/installSnippets.test.ts index fae76810e..dbb72086c 100644 --- a/packages/app/src/components/ClickStackOnboarding/__tests__/installSnippets.test.ts +++ b/packages/app/src/components/ClickStackOnboarding/__tests__/installSnippets.test.ts @@ -1,4 +1,5 @@ import { + ACCESS_KEY_ENV_VAR, buildAllSnippets, type DeploymentShape, SERVER_NAME, @@ -9,6 +10,43 @@ const DEPLOYMENT: DeploymentShape = { accessKey: 'k_abcdef123456', }; +describe('buildAllSnippets > Claude Code', () => { + it('reads the key from a hidden prompt into the header', () => { + const { claudeCode } = buildAllSnippets(DEPLOYMENT); + + expect(claudeCode).toBe( + `read -rs ${ACCESS_KEY_ENV_VAR} && claude mcp add --scope user --transport http ${SERVER_NAME} https://hyperdx.example.com/api/mcp --header "Authorization: Bearer $${ACCESS_KEY_ENV_VAR}"`, + ); + }); +}); + +describe('buildAllSnippets > Codex CLI', () => { + it('reads the key from a hidden prompt into the bearer-token env var', () => { + const { codexCli } = buildAllSnippets(DEPLOYMENT); + + expect(codexCli).toBe( + `read -rs ${ACCESS_KEY_ENV_VAR} && export ${ACCESS_KEY_ENV_VAR} && ` + + `codex mcp add ${SERVER_NAME} --url https://hyperdx.example.com/api/mcp --bearer-token-env-var ${ACCESS_KEY_ENV_VAR}`, + ); + }); + + it('does NOT use the deprecated --transport or --header flags', () => { + const { codexCli } = buildAllSnippets(DEPLOYMENT); + + expect(codexCli).not.toContain('--transport'); + expect(codexCli).not.toContain('--header'); + }); +}); + +describe('buildAllSnippets > shell commands', () => { + it('keep the access key out of the command', () => { + const { claudeCode, codexCli } = buildAllSnippets(DEPLOYMENT); + + expect(claudeCode).not.toContain(DEPLOYMENT.accessKey); + expect(codexCli).not.toContain(DEPLOYMENT.accessKey); + }); +}); + describe('buildAllSnippets > Cursor', () => { it('emits a cursor:// URL with a URL-safe base64-encoded config that round-trips', () => { const { cursor } = buildAllSnippets(DEPLOYMENT); @@ -134,8 +172,10 @@ describe('buildAllSnippets > host coverage', () => { const all = buildAllSnippets(DEPLOYMENT); expect(all).toMatchObject({ + claudeCode: expect.stringContaining('claude mcp add'), cursor: expect.stringContaining('cursor://'), vscode: expect.stringContaining('vscode:mcp/install'), + codexCli: expect.stringContaining(`codex mcp add ${SERVER_NAME}`), openCode: expect.stringContaining(`"${SERVER_NAME}"`), jsonBlock: expect.stringContaining(`"${SERVER_NAME}"`), }); @@ -144,6 +184,8 @@ describe('buildAllSnippets > host coverage', () => { it('keys the JSON block on the same fixed server name in every output', () => { const all = buildAllSnippets(DEPLOYMENT); + expect(all.claudeCode).toContain(SERVER_NAME); + expect(all.codexCli).toContain(SERVER_NAME); expect(all.cursor).toContain(`name=${SERVER_NAME}`); expect(all.vscode).toContain(SERVER_NAME); expect(all.openCode).toContain(`"${SERVER_NAME}"`); diff --git a/packages/app/src/components/ClickStackOnboarding/installSnippets.ts b/packages/app/src/components/ClickStackOnboarding/installSnippets.ts index 713f7bfc6..0ae4a7ef7 100644 --- a/packages/app/src/components/ClickStackOnboarding/installSnippets.ts +++ b/packages/app/src/components/ClickStackOnboarding/installSnippets.ts @@ -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 shell +// command, 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,12 @@ */ export const SERVER_NAME = 'clickstack'; +/** + * Variable the shell snippets read the key into. `read -rs` takes it from a + * hidden prompt, so the key never appears in the command or shell history. + */ +export const ACCESS_KEY_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 +34,14 @@ export interface DeploymentShape { } export interface BuiltSnippets { + /** Claude Code `mcp add` command; prompts for the key. */ + claudeCode: string; /** Cursor `cursor://` deep link. */ cursor: string; /** VS Code + Copilot `vscode:mcp/install` deep link. */ vscode: string; + /** OpenAI Codex CLI `mcp add` command; prompts for the key. */ + codexCli: string; /** OpenCode JSON config under an `mcp` block (uses `type: "remote"`). */ openCode: string; /** Canonical `mcpServers` JSON block for any other host. */ @@ -104,6 +112,19 @@ function buildUrl(deployment: DeploymentShape): string { return `${base}/mcp`; } +// One line, so `read` waits for the keyboard instead of consuming the next +// pasted line in shells without bracketed paste. +const READ_KEY = `read -rs ${ACCESS_KEY_ENV_VAR}`; + +function buildClaudeCommand(deployment: DeploymentShape): string { + return `${READ_KEY} && claude mcp add --scope user --transport http ${SERVER_NAME} ${buildUrl(deployment)} --header "Authorization: Bearer $${ACCESS_KEY_ENV_VAR}"`; +} + +/** Codex has no `--header` flag; it reads the token from the named env var. */ +function buildCodexCommand(deployment: DeploymentShape): string { + return `${READ_KEY} && export ${ACCESS_KEY_ENV_VAR} && codex mcp add ${SERVER_NAME} --url ${buildUrl(deployment)} --bearer-token-env-var ${ACCESS_KEY_ENV_VAR}`; +} + /** * Cursor `cursor://` deep link. Documented Cursor MCP install * scheme: name in the query string, config as base64-encoded JSON. @@ -202,8 +223,10 @@ export function buildCliInstallCommand(deployment: DeploymentShape): string { */ export function buildAllSnippets(deployment: DeploymentShape): BuiltSnippets { return { + claudeCode: buildClaudeCommand(deployment), cursor: buildCursorDeeplink(deployment), vscode: buildVSCodeDeeplink(deployment), + codexCli: buildCodexCommand(deployment), openCode: buildOpenCodeJsonBlock(deployment), jsonBlock: buildMcpJsonBlock(deployment), }; diff --git a/packages/app/src/components/TeamSettings/__tests__/McpServerSection.test.tsx b/packages/app/src/components/TeamSettings/__tests__/McpServerSection.test.tsx index 49c835d50..ff12b3592 100644 --- a/packages/app/src/components/TeamSettings/__tests__/McpServerSection.test.tsx +++ b/packages/app/src/components/TeamSettings/__tests__/McpServerSection.test.tsx @@ -67,16 +67,15 @@ describe('McpServerSection', () => { expect(screen.queryByTestId('mcp-server-section')).not.toBeInTheDocument(); }); - it('offers only file and deep-link hosts for manual setup', () => { + it('renders all six host options when the deployment shape is valid', () => { renderSection(); + expect(screen.getByText('Claude Code')).toBeInTheDocument(); expect(screen.getByText('Cursor')).toBeInTheDocument(); expect(screen.getByText('VS Code')).toBeInTheDocument(); + expect(screen.getByText('Codex CLI')).toBeInTheDocument(); expect(screen.getByText('OpenCode')).toBeInTheDocument(); expect(screen.getByText('Other')).toBeInTheDocument(); - // Their setup is a shell command with the key in it; the CLI covers them. - expect(screen.queryByText('Claude Code')).not.toBeInTheDocument(); - expect(screen.queryByText('Codex CLI')).not.toBeInTheDocument(); }); // Auth-gate parity with `ApiKeysSection`: when `me` resolves to @@ -98,6 +97,14 @@ describe('McpServerSection', () => { ).toBeInTheDocument(); }); + it('renders the fixed clickstack server name in the install snippet', () => { + renderSection(); + + expect( + screen.getByText(/claude mcp add .* clickstack /), + ).toBeInTheDocument(); + }); + // `MeApiResponseSchema.accessKey` is `z.string()` non-nullable // and the User model generates one at account creation, so an // empty access key isn't reachable from the API in practice. @@ -111,6 +118,20 @@ describe('McpServerSection', () => { expect(screen.queryByTestId('mcp-server-section')).not.toBeInTheDocument(); }); + it('switches to the Codex CLI snippet when the host picker selects Codex CLI', async () => { + const user = userEvent.setup(); + renderSection(); + + await user.click(screen.getByText('Codex CLI')); + + expect( + screen.getByText( + /codex mcp add clickstack --url .*--bearer-token-env-var/, + ), + ).toBeInTheDocument(); + expect(screen.queryByText(/claude mcp add/)).not.toBeInTheDocument(); + }); + it('renders the Cursor deeplink button with a cursor:// href when Cursor is selected', async () => { const user = userEvent.setup(); renderSection(); From a3852004584526a1e2c2f792169e7dc0d210bd8c Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 18:47:28 +1100 Subject: [PATCH 2/3] fix(app): trim the organization API keys description --- packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx b/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx index 1cfa80b43..9219aa891 100644 --- a/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx +++ b/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx @@ -119,8 +119,7 @@ export default function OrgApiKeysSection() { Organization API keys - Keys owned by the team. They keep working when the person who - created them leaves. + Keys owned by the team.