diff --git a/src/steps/add-mcp-server-to-clients/MCPClient.ts b/src/steps/add-mcp-server-to-clients/MCPClient.ts index 0e470492..f193fa34 100644 --- a/src/steps/add-mcp-server-to-clients/MCPClient.ts +++ b/src/steps/add-mcp-server-to-clients/MCPClient.ts @@ -36,7 +36,7 @@ export abstract class DefaultMCPClient extends MCPClient { } async addServer(apiKey: string): Promise<{ success: boolean }> { - return this._addServerType(apiKey, 'streamable-http'); + return this._addServerType(apiKey, 'sse'); } async _addServerType( diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts b/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts index 073ddb6e..92bd7017 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts +++ b/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts @@ -326,7 +326,7 @@ describe('ClaudeMCPClient', () => { expect(getDefaultServerConfigMock).toHaveBeenCalledWith( mockApiKey, - 'streamable-http', + 'sse', ); }); }); diff --git a/src/steps/add-mcp-server-to-clients/clients/claude-code.ts b/src/steps/add-mcp-server-to-clients/clients/claude-code.ts new file mode 100644 index 00000000..d1c19689 --- /dev/null +++ b/src/steps/add-mcp-server-to-clients/clients/claude-code.ts @@ -0,0 +1,66 @@ +import { DefaultMCPClient } from '../MCPClient'; +import { DefaultMCPClientConfig, getDefaultServerConfig } from '../defaults'; +import { z } from 'zod'; +import { execSync } from 'child_process'; + +export const ClaudeCodeMCPConfig = DefaultMCPClientConfig; + +export type ClaudeCodeMCPConfig = z.infer; + +export class ClaudeCodeMCPClient extends DefaultMCPClient { + name = 'Claude Code'; + + constructor() { + super(); + } + + isClientSupported(): Promise { + try { + execSync('claude --version', { stdio: 'ignore' }); + return Promise.resolve(true); + } catch { + return Promise.resolve(false); + } + } + + isServerInstalled(): Promise { + try { + // check if posthog in output + const output = execSync('claude mcp list', { + stdio: 'pipe', + }); + + if (output.toString().includes('posthog')) { + return Promise.resolve(true); + } + } catch { + // + } + + return Promise.resolve(false); + } + + getConfigPath(): Promise { + throw new Error('Not implemented'); + } + + addServer(apiKey: string): Promise<{ success: boolean }> { + const config = getDefaultServerConfig(apiKey, 'sse'); + + const command = `claude mcp add-json posthog -s user '${JSON.stringify( + config, + )}'`; + + execSync(command); + + return Promise.resolve({ success: true }); + } + + removeServer(): Promise<{ success: boolean }> { + const command = `claude mcp remove --scope user posthog`; + + execSync(command); + + return Promise.resolve({ success: true }); + } +} diff --git a/src/steps/add-mcp-server-to-clients/index.ts b/src/steps/add-mcp-server-to-clients/index.ts index 5c070bc1..e7ec1165 100644 --- a/src/steps/add-mcp-server-to-clients/index.ts +++ b/src/steps/add-mcp-server-to-clients/index.ts @@ -12,9 +12,14 @@ import { CursorMCPClient } from './clients/cursor'; import { ClaudeMCPClient } from './clients/claude'; import { getPersonalApiKey } from '../../mcp'; import type { CloudRegion } from '../../utils/types'; +import { ClaudeCodeMCPClient } from './clients/claude-code'; export const getSupportedClients = async (): Promise => { - const allClients = [new CursorMCPClient(), new ClaudeMCPClient()]; + const allClients = [ + new CursorMCPClient(), + new ClaudeMCPClient(), + new ClaudeCodeMCPClient(), + ]; const supportedClients: MCPClient[] = []; for (const client of allClients) {