@@ -6,6 +6,7 @@ import { merge } from 'lodash';
66export abstract class MCPClient {
77 name : string ;
88 abstract getConfigPath ( ) : Promise < string > ;
9+ abstract getServerPropertyName ( ) : string ;
910 abstract isServerInstalled ( ) : Promise < boolean > ;
1011 abstract addServer ( apiKey : string ) : Promise < { success : boolean } > ;
1112 abstract removeServer ( ) : Promise < { success : boolean } > ;
@@ -18,6 +19,11 @@ export abstract class DefaultMCPClient extends MCPClient {
1819 constructor ( ) {
1920 super ( ) ;
2021 }
22+
23+ getServerPropertyName ( ) : string {
24+ return 'mcpServers' ;
25+ }
26+
2127 async isServerInstalled ( ) : Promise < boolean > {
2228 try {
2329 const configPath = await this . getConfigPath ( ) ;
@@ -28,8 +34,10 @@ export abstract class DefaultMCPClient extends MCPClient {
2834
2935 const configContent = await fs . promises . readFile ( configPath , 'utf8' ) ;
3036 const config = JSON . parse ( configContent ) ;
31-
32- return 'mcpServers' in config && 'posthog' in config . mcpServers ;
37+ const serverPropertyName = this . getServerPropertyName ( ) ;
38+ return (
39+ serverPropertyName in config && 'posthog' in config [ serverPropertyName ]
40+ ) ;
3341 } catch {
3442 return false ;
3543 }
@@ -49,8 +57,9 @@ export abstract class DefaultMCPClient extends MCPClient {
4957
5058 await fs . promises . mkdir ( configDir , { recursive : true } ) ;
5159
60+ const serverPropertyName = this . getServerPropertyName ( ) ;
5261 const newServerConfig = {
53- mcpServers : {
62+ [ serverPropertyName ] : {
5463 posthog : getDefaultServerConfig ( apiKey , type ) ,
5564 } ,
5665 } ;
@@ -87,9 +96,13 @@ export abstract class DefaultMCPClient extends MCPClient {
8796
8897 const configContent = await fs . promises . readFile ( configPath , 'utf8' ) ;
8998 const config = JSON . parse ( configContent ) ;
99+ const serverPropertyName = this . getServerPropertyName ( ) ;
90100
91- if ( 'mcpServers' in config && 'posthog' in config . mcpServers ) {
92- delete config . mcpServers . posthog ;
101+ if (
102+ serverPropertyName in config &&
103+ 'posthog' in config [ serverPropertyName ]
104+ ) {
105+ delete config [ serverPropertyName ] . posthog ;
93106
94107 await fs . promises . writeFile (
95108 configPath ,
0 commit comments