@@ -289,4 +289,104 @@ export class MCPConfigService {
289289 lastUpdated : config . last_updated
290290 } ;
291291 }
292+
293+ /**
294+ * Convert gateway configuration to team configuration for local storage
295+ * @param teamId Team ID
296+ * @param teamName Team name
297+ * @param gatewayConfig Gateway configuration from new API
298+ * @returns Team MCP configuration for storage
299+ */
300+ convertGatewayConfigToTeamConfig (
301+ teamId : string ,
302+ teamName : string ,
303+ gatewayConfig : {
304+ servers : Array < {
305+ id : string ;
306+ name : string ;
307+ command : string ;
308+ args : string [ ] ;
309+ env : Record < string , string > ;
310+ status : 'ready' | 'invalid' ;
311+ } > ;
312+ deviceId : string ;
313+ lastUpdated : string ;
314+ }
315+ ) : TeamMCPConfig {
316+ // Convert gateway servers to TeamMCPConfig format
317+ const servers = gatewayConfig . servers . map ( server => ( {
318+ id : server . id ,
319+ name : server . name ,
320+ installation_name : server . name ,
321+ command : server . command ,
322+ args : server . args ,
323+ env : server . env ,
324+ runtime : this . detectRuntime ( server . command , server . args ) ,
325+ installation_type : 'local' as const ,
326+ transport_type : 'stdio' as const ,
327+ status : server . status
328+ } ) ) ;
329+
330+ // Create mock installations for compatibility (since gateway endpoint doesn't return installations)
331+ const installations = gatewayConfig . servers . map ( server => ( {
332+ id : server . id ,
333+ team_id : teamId ,
334+ server_id : server . id ,
335+ created_by : 'gateway-endpoint' ,
336+ installation_name : server . name ,
337+ installation_type : 'local' as const ,
338+ team_args : server . args ,
339+ team_env : server . env ,
340+ created_at : gatewayConfig . lastUpdated ,
341+ updated_at : gatewayConfig . lastUpdated ,
342+ last_used_at : null ,
343+ server : {
344+ id : server . id ,
345+ name : server . name ,
346+ description : `MCP server: ${ server . name } ` ,
347+ github_url : null ,
348+ runtime : this . detectRuntime ( server . command , server . args ) ,
349+ installation_methods : [ {
350+ type : 'command' as const ,
351+ command : server . command ,
352+ args : server . args
353+ } ] ,
354+ environment_variables : [ ] ,
355+ transport_type : 'stdio' as const
356+ }
357+ } ) ) ;
358+
359+ return {
360+ team_id : teamId ,
361+ team_name : teamName ,
362+ installations,
363+ user_configurations : [ ] , // Empty since gateway endpoint handles user configs internally
364+ servers,
365+ last_updated : gatewayConfig . lastUpdated
366+ } ;
367+ }
368+
369+ /**
370+ * Store MCP configuration (wrapper around storage)
371+ * @param config Team MCP configuration to store
372+ */
373+ async storeMCPConfig ( config : TeamMCPConfig ) : Promise < void > {
374+ await this . storage . storeMCPConfig ( config ) ;
375+ }
376+
377+ /**
378+ * Detect runtime from command and args
379+ * @param command Command string
380+ * @param _args Command arguments
381+ * @returns Detected runtime
382+ */
383+ private detectRuntime ( command : string , _args : string [ ] ) : 'nodejs' | 'python' | 'binary' {
384+ if ( command === 'npx' || command === 'node' ) {
385+ return 'nodejs' ;
386+ }
387+ if ( command === 'python' || command === 'python3' || command === 'pip' ) {
388+ return 'python' ;
389+ }
390+ return 'binary' ;
391+ }
292392}
0 commit comments