Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/steps/add-mcp-server-to-clients/MCPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export abstract class DefaultMCPClient extends MCPClient {
}

async addServer(apiKey: string): Promise<{ success: boolean }> {
return this._addServerType(apiKey, 'streamable-http');
}

async _addServerType(
apiKey: string,
type: 'sse' | 'streamable-http',
): Promise<{ success: boolean }> {
try {
const configPath = await this.getConfigPath();
const configDir = path.dirname(configPath);
Expand All @@ -44,7 +51,7 @@ export abstract class DefaultMCPClient extends MCPClient {

const newServerConfig = {
mcpServers: {
posthog: getDefaultServerConfig(apiKey),
posthog: getDefaultServerConfig(apiKey, type),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ describe('ClaudeMCPClient', () => {

await client.addServer(mockApiKey);

expect(getDefaultServerConfigMock).toHaveBeenCalledWith(mockApiKey);
expect(getDefaultServerConfigMock).toHaveBeenCalledWith(
mockApiKey,
'streamable-http',
);
});
});

Expand Down
4 changes: 4 additions & 0 deletions src/steps/add-mcp-server-to-clients/clients/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export class CursorMCPClient extends DefaultMCPClient {
async getConfigPath(): Promise<string> {
return Promise.resolve(path.join(os.homedir(), '.cursor', 'mcp.json'));
}

async addServer(apiKey: string): Promise<{ success: boolean }> {
return this._addServerType(apiKey, 'sse');
}
}
9 changes: 7 additions & 2 deletions src/steps/add-mcp-server-to-clients/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ export const DefaultMCPClientConfig = z
})
.passthrough();

export const getDefaultServerConfig = (apiKey: string) => ({
type MCPServerType = 'sse' | 'streamable-http';

export const getDefaultServerConfig = (
apiKey: string,
type: MCPServerType,
) => ({
command: 'npx',
args: [
'-y',
'mcp-remote@latest',
'https://mcp.posthog.com/mcp',
`https://mcp.posthog.com/${type === 'sse' ? 'sse' : 'mcp'}`,
'--header',
`Authorization:\${POSTHOG_AUTH_HEADER}`,
],
Expand Down
Loading