Skip to content

Commit 4fcbf8a

Browse files
joshsnyPostHog Code
andauthored
fix(mcp): drop /sse transport, always install /mcp (#429)
Co-authored-by: PostHog Code <code@posthog.com>
1 parent 557ec08 commit 4fcbf8a

7 files changed

Lines changed: 22 additions & 104 deletions

File tree

src/steps/add-mcp-server-to-clients/MCPClient.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ export abstract class DefaultMCPClient extends MCPClient {
3232

3333
getServerConfig(
3434
apiKey: string | undefined,
35-
type: 'sse' | 'streamable-http',
3635
selectedFeatures?: string[],
3736
local?: boolean,
3837
): MCPServerConfig {
39-
return getDefaultServerConfig(apiKey, type, selectedFeatures, local);
38+
return getDefaultServerConfig(apiKey, selectedFeatures, local);
4039
}
4140

4241
async isServerInstalled(local?: boolean): Promise<boolean> {
@@ -64,15 +63,6 @@ export abstract class DefaultMCPClient extends MCPClient {
6463
apiKey?: string,
6564
selectedFeatures?: string[],
6665
local?: boolean,
67-
): Promise<{ success: boolean }> {
68-
return this._addServerType(apiKey, 'sse', selectedFeatures, local);
69-
}
70-
71-
async _addServerType(
72-
apiKey: string | undefined,
73-
type: 'sse' | 'streamable-http',
74-
selectedFeatures?: string[],
75-
local?: boolean,
7666
): Promise<{ success: boolean }> {
7767
try {
7868
const configPath = await this.getConfigPath();
@@ -91,7 +81,6 @@ export abstract class DefaultMCPClient extends MCPClient {
9181

9282
const newServerConfig = this.getServerConfig(
9383
apiKey,
94-
type,
9584
selectedFeatures,
9685
local,
9786
);

src/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,33 @@ import {
66

77
describe('defaults', () => {
88
describe('buildMCPUrl', () => {
9-
it('should build base URL for streamable-http type', () => {
10-
const url = buildMCPUrl('streamable-http');
9+
it('should build base URL', () => {
10+
const url = buildMCPUrl();
1111
expect(url).toBe('https://mcp.posthog.com/mcp');
1212
});
1313

14-
it('should build base URL for sse type', () => {
15-
const url = buildMCPUrl('sse');
16-
expect(url).toBe('https://mcp.posthog.com/sse');
17-
});
18-
1914
it('should use localhost for local mode', () => {
20-
const url = buildMCPUrl('streamable-http', undefined, true);
15+
const url = buildMCPUrl(undefined, true);
2116
expect(url).toBe('http://localhost:8787/mcp');
2217
});
2318

2419
it('should add features param when not all features selected', () => {
25-
const url = buildMCPUrl('streamable-http', ['dashboards', 'insights']);
20+
const url = buildMCPUrl(['dashboards', 'insights']);
2621
expect(url).toBe(
2722
'https://mcp.posthog.com/mcp?features=dashboards,insights',
2823
);
2924
});
30-
31-
it('should not add region param in local mode', () => {
32-
const url = buildMCPUrl('streamable-http', undefined, true);
33-
expect(url).toBe('http://localhost:8787/mcp');
34-
});
3525
});
3626

3727
describe('getDefaultServerConfig', () => {
3828
it('should return config with auth header when API key provided', () => {
39-
const config = getDefaultServerConfig('phx_test123', 'sse');
29+
const config = getDefaultServerConfig('phx_test123');
4030
expect(config).toEqual({
4131
command: 'npx',
4232
args: [
4333
'-y',
4434
'mcp-remote@latest',
45-
'https://mcp.posthog.com/sse',
35+
'https://mcp.posthog.com/mcp',
4636
'--header',
4737
'Authorization:${POSTHOG_AUTH_HEADER}',
4838
],
@@ -53,21 +43,18 @@ describe('defaults', () => {
5343
});
5444

5545
it('should return config without auth header for OAuth mode (no API key)', () => {
56-
const config = getDefaultServerConfig(undefined, 'sse');
46+
const config = getDefaultServerConfig(undefined);
5747
expect(config).toEqual({
5848
command: 'npx',
59-
args: ['-y', 'mcp-remote@latest', 'https://mcp.posthog.com/sse'],
49+
args: ['-y', 'mcp-remote@latest', 'https://mcp.posthog.com/mcp'],
6050
});
6151
expect(config).not.toHaveProperty('env');
6252
});
6353
});
6454

6555
describe('getNativeHTTPServerConfig', () => {
6656
it('should return config with headers when API key provided', () => {
67-
const config = getNativeHTTPServerConfig(
68-
'phx_test123',
69-
'streamable-http',
70-
);
57+
const config = getNativeHTTPServerConfig('phx_test123');
7158
expect(config).toEqual({
7259
url: 'https://mcp.posthog.com/mcp',
7360
headers: {
@@ -77,7 +64,7 @@ describe('defaults', () => {
7764
});
7865

7966
it('should return config without headers for OAuth mode (no API key)', () => {
80-
const config = getNativeHTTPServerConfig(undefined, 'streamable-http');
67+
const config = getNativeHTTPServerConfig(undefined);
8168
expect(config).toEqual({
8269
url: 'https://mcp.posthog.com/mcp',
8370
});

src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ describe('ClaudeMCPClient', () => {
326326

327327
expect(getDefaultServerConfigMock).toHaveBeenCalledWith(
328328
mockApiKey,
329-
'sse',
330329
undefined,
331330
undefined,
332331
);
@@ -339,7 +338,6 @@ describe('ClaudeMCPClient', () => {
339338

340339
expect(getDefaultServerConfigMock).toHaveBeenCalledWith(
341340
undefined,
342-
'sse',
343341
undefined,
344342
undefined,
345343
);

src/steps/add-mcp-server-to-clients/clients/cursor.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,9 @@ export class CursorMCPClient extends DefaultMCPClient {
2727

2828
getServerConfig(
2929
apiKey: string | undefined,
30-
type: 'sse' | 'streamable-http',
3130
selectedFeatures?: string[],
3231
local?: boolean,
3332
): MCPServerConfig {
34-
return getNativeHTTPServerConfig(apiKey, type, selectedFeatures, local);
35-
}
36-
37-
async addServer(
38-
apiKey?: string,
39-
selectedFeatures?: string[],
40-
local?: boolean,
41-
): Promise<{ success: boolean }> {
42-
return this._addServerType(
43-
apiKey,
44-
'streamable-http',
45-
selectedFeatures,
46-
local,
47-
);
33+
return getNativeHTTPServerConfig(apiKey, selectedFeatures, local);
4834
}
4935
}

src/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import z from 'zod';
22
import * as path from 'path';
33
import * as os from 'os';
44
import { DefaultMCPClient, MCPServerConfig } from '../MCPClient';
5-
import { buildMCPUrl } from '../defaults';
5+
import { getNativeHTTPServerConfig } from '../defaults';
66
import { runtimeEnv } from '@env';
77

88
export const VisualStudioCodeMCPConfig = z
@@ -79,30 +79,13 @@ export class VisualStudioCodeClient extends DefaultMCPClient {
7979
}
8080

8181
getServerConfig(
82-
apiKey: string,
83-
type: 'sse' | 'streamable-http',
82+
apiKey: string | undefined,
8483
selectedFeatures?: string[],
8584
local?: boolean,
8685
): MCPServerConfig {
8786
return {
8887
type: 'http',
89-
url: buildMCPUrl(type, selectedFeatures, local),
90-
headers: {
91-
Authorization: `Bearer ${apiKey}`,
92-
},
88+
...getNativeHTTPServerConfig(apiKey, selectedFeatures, local),
9389
};
9490
}
95-
96-
async addServer(
97-
apiKey: string,
98-
selectedFeatures?: string[],
99-
local?: boolean,
100-
): Promise<{ success: boolean }> {
101-
return this._addServerType(
102-
apiKey,
103-
'streamable-http',
104-
selectedFeatures,
105-
local,
106-
);
107-
}
10891
}

src/steps/add-mcp-server-to-clients/clients/zed.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import z from 'zod';
22
import * as path from 'path';
33
import * as os from 'os';
44
import { DefaultMCPClient, MCPServerConfig } from '../MCPClient';
5-
import { buildMCPUrl } from '../defaults';
5+
import { getNativeHTTPServerConfig } from '../defaults';
66
import { runtimeEnv } from '@env';
77

88
export const ZedMCPConfig = z
@@ -70,30 +70,13 @@ export class ZedClient extends DefaultMCPClient {
7070
}
7171

7272
getServerConfig(
73-
apiKey: string,
74-
type: 'sse' | 'streamable-http',
73+
apiKey: string | undefined,
7574
selectedFeatures?: string[],
7675
local?: boolean,
7776
): MCPServerConfig {
7877
return {
7978
enabled: true,
80-
url: buildMCPUrl(type, selectedFeatures, local),
81-
headers: {
82-
Authorization: `Bearer ${apiKey}`,
83-
},
79+
...getNativeHTTPServerConfig(apiKey, selectedFeatures, local),
8480
};
8581
}
86-
87-
async addServer(
88-
apiKey: string,
89-
selectedFeatures?: string[],
90-
local?: boolean,
91-
): Promise<{ success: boolean }> {
92-
return this._addServerType(
93-
apiKey,
94-
'streamable-http',
95-
selectedFeatures,
96-
local,
97-
);
98-
}
9982
}

src/steps/add-mcp-server-to-clients/defaults.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,9 @@ export const ALL_FEATURE_VALUES = Object.values(AVAILABLE_FEATURES)
213213
.flat()
214214
.map((feature) => feature.value);
215215

216-
type MCPServerType = 'sse' | 'streamable-http';
217-
218-
export const buildMCPUrl = (
219-
type: MCPServerType,
220-
selectedFeatures?: string[],
221-
local?: boolean,
222-
) => {
216+
export const buildMCPUrl = (selectedFeatures?: string[], local?: boolean) => {
223217
const host = local ? 'http://localhost:8787' : 'https://mcp.posthog.com';
224-
const baseUrl = `${host}/${type === 'sse' ? 'sse' : 'mcp'}`;
218+
const baseUrl = `${host}/mcp`;
225219

226220
const isAllFeaturesSelected =
227221
selectedFeatures &&
@@ -244,12 +238,11 @@ export const buildMCPUrl = (
244238

245239
export const getNativeHTTPServerConfig = (
246240
apiKey: string | undefined,
247-
type: MCPServerType,
248241
selectedFeatures?: string[],
249242
local?: boolean,
250243
) => {
251244
const config: Record<string, unknown> = {
252-
url: buildMCPUrl(type, selectedFeatures, local),
245+
url: buildMCPUrl(selectedFeatures, local),
253246
};
254247

255248
// Only add auth header if API key is provided (not OAuth mode)
@@ -264,11 +257,10 @@ export const getNativeHTTPServerConfig = (
264257

265258
export const getDefaultServerConfig = (
266259
apiKey: string | undefined,
267-
type: MCPServerType,
268260
selectedFeatures?: string[],
269261
local?: boolean,
270262
) => {
271-
const urlWithFeatures = buildMCPUrl(type, selectedFeatures, local);
263+
const urlWithFeatures = buildMCPUrl(selectedFeatures, local);
272264

273265
// OAuth mode: no auth header, let MCP handle OAuth
274266
if (!apiKey) {

0 commit comments

Comments
 (0)