@@ -7,12 +7,13 @@ export abstract class MCPClient {
77 name : string ;
88 abstract getConfigPath ( ) : Promise < string > ;
99 abstract getServerPropertyName ( ) : string ;
10- abstract isServerInstalled ( ) : Promise < boolean > ;
10+ abstract isServerInstalled ( local ?: boolean ) : Promise < boolean > ;
1111 abstract addServer (
1212 apiKey : string ,
1313 selectedFeatures ?: string [ ] ,
14+ local ?: boolean ,
1415 ) : Promise < { success : boolean } > ;
15- abstract removeServer ( ) : Promise < { success : boolean } > ;
16+ abstract removeServer ( local ?: boolean ) : Promise < { success : boolean } > ;
1617 abstract isClientSupported ( ) : Promise < boolean > ;
1718}
1819
@@ -31,11 +32,12 @@ export abstract class DefaultMCPClient extends MCPClient {
3132 apiKey : string ,
3233 type : 'sse' | 'streamable-http' ,
3334 selectedFeatures ?: string [ ] ,
35+ local ?: boolean ,
3436 ) {
35- return getDefaultServerConfig ( apiKey , type , selectedFeatures ) ;
37+ return getDefaultServerConfig ( apiKey , type , selectedFeatures , local ) ;
3638 }
3739
38- async isServerInstalled ( ) : Promise < boolean > {
40+ async isServerInstalled ( local ?: boolean ) : Promise < boolean > {
3941 try {
4042 const configPath = await this . getConfigPath ( ) ;
4143
@@ -46,8 +48,10 @@ export abstract class DefaultMCPClient extends MCPClient {
4648 const configContent = await fs . promises . readFile ( configPath , 'utf8' ) ;
4749 const config = jsonc . parse ( configContent ) as Record < string , any > ;
4850 const serverPropertyName = this . getServerPropertyName ( ) ;
51+ const serverName = local ? 'posthog-local' : 'posthog' ;
52+
4953 return (
50- serverPropertyName in config && 'posthog' in config [ serverPropertyName ]
54+ serverPropertyName in config && serverName in config [ serverPropertyName ]
5155 ) ;
5256 } catch {
5357 return false ;
@@ -57,14 +61,16 @@ export abstract class DefaultMCPClient extends MCPClient {
5761 async addServer (
5862 apiKey : string ,
5963 selectedFeatures ?: string [ ] ,
64+ local ?: boolean ,
6065 ) : Promise < { success : boolean } > {
61- return this . _addServerType ( apiKey , 'sse' , selectedFeatures ) ;
66+ return this . _addServerType ( apiKey , 'sse' , selectedFeatures , local ) ;
6267 }
6368
6469 async _addServerType (
6570 apiKey : string ,
6671 type : 'sse' | 'streamable-http' ,
6772 selectedFeatures ?: string [ ] ,
73+ local ?: boolean ,
6874 ) : Promise < { success : boolean } > {
6975 try {
7076 const configPath = await this . getConfigPath ( ) ;
@@ -85,16 +91,18 @@ export abstract class DefaultMCPClient extends MCPClient {
8591 apiKey ,
8692 type ,
8793 selectedFeatures ,
94+ local ,
8895 ) ;
8996 const typedConfig = existingConfig as Record < string , any > ;
9097 if ( ! typedConfig [ serverPropertyName ] ) {
9198 typedConfig [ serverPropertyName ] = { } ;
9299 }
93- typedConfig [ serverPropertyName ] . posthog = newServerConfig ;
100+ const serverName = local ? 'posthog-local' : 'posthog' ;
101+ typedConfig [ serverPropertyName ] [ serverName ] = newServerConfig ;
94102
95103 const edits = jsonc . modify (
96104 configContent ,
97- [ serverPropertyName , 'posthog' ] ,
105+ [ serverPropertyName , serverName ] ,
98106 newServerConfig ,
99107 {
100108 formattingOptions : {
@@ -114,7 +122,7 @@ export abstract class DefaultMCPClient extends MCPClient {
114122 }
115123 }
116124
117- async removeServer ( ) : Promise < { success : boolean } > {
125+ async removeServer ( local ?: boolean ) : Promise < { success : boolean } > {
118126 try {
119127 const configPath = await this . getConfigPath ( ) ;
120128
@@ -126,13 +134,15 @@ export abstract class DefaultMCPClient extends MCPClient {
126134 const config = jsonc . parse ( configContent ) as Record < string , any > ;
127135 const serverPropertyName = this . getServerPropertyName ( ) ;
128136
137+ const serverName = local ? 'posthog-local' : 'posthog' ;
138+
129139 if (
130140 serverPropertyName in config &&
131- 'posthog' in config [ serverPropertyName ]
141+ serverName in config [ serverPropertyName ]
132142 ) {
133143 const edits = jsonc . modify (
134144 configContent ,
135- [ serverPropertyName , 'posthog' ] ,
145+ [ serverPropertyName , serverName ] ,
136146 undefined ,
137147 {
138148 formattingOptions : {
0 commit comments