imcp 0.0.19 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/.roo/rules-code/rules.md +88 -0
  2. package/dist/cli/index.js +1 -45
  3. package/dist/core/installers/clients/BaseClientInstaller.d.ts +1 -5
  4. package/dist/core/installers/clients/BaseClientInstaller.js +40 -38
  5. package/dist/core/installers/clients/ClientInstaller.d.ts +9 -9
  6. package/dist/core/installers/clients/ClientInstaller.js +105 -99
  7. package/dist/core/installers/requirements/BaseInstaller.d.ts +9 -1
  8. package/dist/core/installers/requirements/CommandInstaller.d.ts +9 -1
  9. package/dist/core/installers/requirements/CommandInstaller.js +46 -12
  10. package/dist/core/installers/requirements/GeneralInstaller.d.ts +11 -1
  11. package/dist/core/installers/requirements/GeneralInstaller.js +46 -10
  12. package/dist/core/installers/requirements/InstallerFactory.d.ts +3 -1
  13. package/dist/core/installers/requirements/InstallerFactory.js +3 -2
  14. package/dist/core/installers/requirements/NpmInstaller.d.ts +4 -2
  15. package/dist/core/installers/requirements/NpmInstaller.js +38 -22
  16. package/dist/core/installers/requirements/PipInstaller.d.ts +3 -1
  17. package/dist/core/installers/requirements/PipInstaller.js +58 -36
  18. package/dist/core/installers/requirements/RequirementInstaller.d.ts +4 -1
  19. package/dist/core/loaders/InstallOperationManager.d.ts +115 -0
  20. package/dist/core/loaders/InstallOperationManager.js +311 -0
  21. package/dist/core/loaders/SystemSettingsManager.d.ts +54 -0
  22. package/dist/core/loaders/SystemSettingsManager.js +257 -0
  23. package/dist/core/metadatas/constants.d.ts +7 -0
  24. package/dist/core/metadatas/constants.js +7 -0
  25. package/dist/core/metadatas/recordingConstants.d.ts +44 -0
  26. package/dist/core/metadatas/recordingConstants.js +45 -0
  27. package/dist/core/metadatas/types.d.ts +21 -0
  28. package/dist/core/onboard/FeedOnboardService.d.ts +7 -3
  29. package/dist/core/onboard/FeedOnboardService.js +52 -5
  30. package/dist/core/onboard/InstallOperationManager.d.ts +23 -0
  31. package/dist/core/onboard/InstallOperationManager.js +144 -0
  32. package/dist/core/onboard/OnboardStatusManager.js +2 -1
  33. package/dist/core/validators/StdioServerValidator.js +4 -3
  34. package/dist/services/InstallationService.d.ts +2 -37
  35. package/dist/services/InstallationService.js +45 -313
  36. package/dist/services/MCPManager.d.ts +1 -1
  37. package/dist/services/MCPManager.js +53 -47
  38. package/dist/services/RequirementService.d.ts +85 -12
  39. package/dist/services/RequirementService.js +488 -49
  40. package/dist/services/ServerService.d.ts +0 -6
  41. package/dist/services/ServerService.js +0 -74
  42. package/dist/services/TelemetryService.d.ts +15 -0
  43. package/dist/services/TelemetryService.js +54 -0
  44. package/dist/utils/adoUtils.js +6 -3
  45. package/dist/utils/githubAuth.js +65 -0
  46. package/dist/utils/logger.d.ts +16 -0
  47. package/dist/utils/logger.js +78 -1
  48. package/dist/utils/macroExpressionUtils.js +3 -25
  49. package/dist/utils/osUtils.d.ts +22 -1
  50. package/dist/utils/osUtils.js +92 -1
  51. package/dist/utils/versionUtils.d.ts +20 -0
  52. package/dist/utils/versionUtils.js +76 -0
  53. package/dist/web/public/css/modal.css +292 -1
  54. package/dist/web/public/css/serverCategoryList.css +120 -0
  55. package/dist/web/public/css/serverDetails.css +14 -1
  56. package/dist/web/public/index.html +126 -21
  57. package/dist/web/public/js/flights/flights.js +1 -1
  58. package/dist/web/public/js/modal/index.js +8 -14
  59. package/dist/web/public/js/modal/installModal.js +3 -4
  60. package/dist/web/public/js/modal/installation.js +122 -137
  61. package/dist/web/public/js/modal/loadingModal.js +155 -25
  62. package/dist/web/public/js/modal/messageQueue.js +45 -101
  63. package/dist/web/public/js/modal/modalSetup.js +125 -43
  64. package/dist/web/public/js/modal/modalUtils.js +0 -12
  65. package/dist/web/public/js/modal.js +23 -10
  66. package/dist/web/public/js/onboard/formProcessor.js +18 -11
  67. package/dist/web/public/js/onboard/publishHandler.js +35 -3
  68. package/dist/web/public/js/onboard/templates.js +5 -1
  69. package/dist/web/public/js/onboard/uiHandlers.js +266 -39
  70. package/dist/web/public/js/onboard/validationHandlers.js +71 -39
  71. package/dist/web/public/js/serverCategoryDetails.js +60 -11
  72. package/dist/web/public/js/serverCategoryList.js +93 -9
  73. package/dist/web/public/js/settings.js +314 -0
  74. package/dist/web/public/onboard.html +2 -2
  75. package/dist/web/public/settings.html +135 -0
  76. package/dist/web/public/styles.css +32 -0
  77. package/dist/web/server.js +93 -1
  78. package/{src/web/public/js/onboard → docs}/ONBOARDING_PAGE_DESIGN.md +15 -125
  79. package/docs/Telemetry.md +136 -0
  80. package/memory-bank/activeContext.md +26 -0
  81. package/memory-bank/decisionLog.md +91 -0
  82. package/memory-bank/productContext.md +41 -0
  83. package/memory-bank/progress.md +35 -0
  84. package/memory-bank/systemPatterns.md +10 -0
  85. package/package.json +2 -1
  86. package/src/cli/index.ts +1 -48
  87. package/src/core/installers/clients/BaseClientInstaller.ts +64 -50
  88. package/src/core/installers/clients/ClientInstaller.ts +130 -130
  89. package/src/core/installers/requirements/BaseInstaller.ts +9 -1
  90. package/src/core/installers/requirements/CommandInstaller.ts +47 -13
  91. package/src/core/installers/requirements/GeneralInstaller.ts +48 -10
  92. package/src/core/installers/requirements/InstallerFactory.ts +4 -3
  93. package/src/core/installers/requirements/NpmInstaller.ts +90 -68
  94. package/src/core/installers/requirements/PipInstaller.ts +81 -55
  95. package/src/core/installers/requirements/RequirementInstaller.ts +4 -3
  96. package/src/core/loaders/InstallOperationManager.ts +367 -0
  97. package/src/core/loaders/SystemSettingsManager.ts +278 -0
  98. package/src/core/metadatas/constants.ts +9 -0
  99. package/src/core/metadatas/recordingConstants.ts +62 -0
  100. package/src/core/metadatas/types.ts +23 -0
  101. package/src/core/onboard/FeedOnboardService.ts +59 -5
  102. package/src/core/onboard/OnboardStatusManager.ts +2 -1
  103. package/src/core/validators/StdioServerValidator.ts +4 -3
  104. package/src/services/InstallationService.ts +54 -399
  105. package/src/services/MCPManager.ts +61 -64
  106. package/src/services/RequirementService.ts +564 -67
  107. package/src/services/ServerService.ts +0 -90
  108. package/src/services/TelemetryService.ts +59 -0
  109. package/src/utils/adoUtils.ts +6 -4
  110. package/src/utils/githubAuth.ts +84 -1
  111. package/src/utils/logger.ts +83 -1
  112. package/src/utils/macroExpressionUtils.ts +4 -21
  113. package/src/utils/osUtils.ts +92 -1
  114. package/src/utils/versionUtils.ts +98 -13
  115. package/src/web/public/css/modal.css +292 -1
  116. package/src/web/public/css/serverCategoryList.css +120 -0
  117. package/src/web/public/css/serverDetails.css +14 -1
  118. package/src/web/public/index.html +126 -21
  119. package/src/web/public/js/flights/flights.js +1 -1
  120. package/src/web/public/js/modal/index.js +8 -14
  121. package/src/web/public/js/modal/installModal.js +3 -4
  122. package/src/web/public/js/modal/installation.js +122 -137
  123. package/src/web/public/js/modal/loadingModal.js +155 -25
  124. package/src/web/public/js/modal/modalSetup.js +125 -43
  125. package/src/web/public/js/modal/modalUtils.js +0 -12
  126. package/src/web/public/js/modal.js +23 -10
  127. package/src/web/public/js/onboard/formProcessor.js +18 -11
  128. package/src/web/public/js/onboard/publishHandler.js +35 -3
  129. package/src/web/public/js/onboard/templates.js +5 -1
  130. package/src/web/public/js/onboard/uiHandlers.js +266 -39
  131. package/src/web/public/js/onboard/validationHandlers.js +71 -39
  132. package/src/web/public/js/serverCategoryDetails.js +60 -11
  133. package/src/web/public/js/serverCategoryList.js +93 -9
  134. package/src/web/public/js/settings.js +314 -0
  135. package/src/web/public/onboard.html +2 -2
  136. package/src/web/public/settings.html +135 -0
  137. package/src/web/public/styles.css +32 -0
  138. package/src/web/server.ts +96 -1
  139. package/dist/cli/commands/start.d.ts +0 -2
  140. package/dist/cli/commands/start.js +0 -32
  141. package/dist/cli/commands/sync.d.ts +0 -2
  142. package/dist/cli/commands/sync.js +0 -17
  143. package/dist/core/ConfigurationLoader.d.ts +0 -32
  144. package/dist/core/ConfigurationLoader.js +0 -236
  145. package/dist/core/ConfigurationProvider.d.ts +0 -35
  146. package/dist/core/ConfigurationProvider.js +0 -375
  147. package/dist/core/InstallationService.d.ts +0 -50
  148. package/dist/core/InstallationService.js +0 -350
  149. package/dist/core/MCPManager.d.ts +0 -28
  150. package/dist/core/MCPManager.js +0 -188
  151. package/dist/core/RequirementService.d.ts +0 -40
  152. package/dist/core/RequirementService.js +0 -110
  153. package/dist/core/ServerSchemaLoader.d.ts +0 -11
  154. package/dist/core/ServerSchemaLoader.js +0 -43
  155. package/dist/core/ServerSchemaProvider.d.ts +0 -17
  156. package/dist/core/ServerSchemaProvider.js +0 -120
  157. package/dist/core/constants.d.ts +0 -47
  158. package/dist/core/constants.js +0 -94
  159. package/dist/core/installers/BaseInstaller.d.ts +0 -74
  160. package/dist/core/installers/BaseInstaller.js +0 -253
  161. package/dist/core/installers/ClientInstaller.d.ts +0 -23
  162. package/dist/core/installers/ClientInstaller.js +0 -564
  163. package/dist/core/installers/CommandInstaller.d.ts +0 -37
  164. package/dist/core/installers/CommandInstaller.js +0 -173
  165. package/dist/core/installers/GeneralInstaller.d.ts +0 -33
  166. package/dist/core/installers/GeneralInstaller.js +0 -85
  167. package/dist/core/installers/InstallerFactory.d.ts +0 -54
  168. package/dist/core/installers/InstallerFactory.js +0 -97
  169. package/dist/core/installers/NpmInstaller.d.ts +0 -26
  170. package/dist/core/installers/NpmInstaller.js +0 -127
  171. package/dist/core/installers/PipInstaller.d.ts +0 -28
  172. package/dist/core/installers/PipInstaller.js +0 -127
  173. package/dist/core/installers/RequirementInstaller.d.ts +0 -33
  174. package/dist/core/installers/RequirementInstaller.js +0 -3
  175. package/dist/core/types.d.ts +0 -166
  176. package/dist/core/types.js +0 -16
  177. package/dist/services/InstallRequestValidator.d.ts +0 -21
  178. package/dist/services/InstallRequestValidator.js +0 -99
  179. package/dist/web/public/js/modal/installHandler.js +0 -227
  180. package/dist/web/public/js/modal/loadingUI.js +0 -74
  181. package/dist/web/public/js/modal/modalUI.js +0 -214
  182. package/dist/web/public/js/modal/version.js +0 -20
  183. package/src/web/public/js/modal/messageQueue.js +0 -112
package/src/web/server.ts CHANGED
@@ -25,9 +25,13 @@ import { SUPPORTED_CLIENT_NAMES } from '../core/metadatas/constants.js';
25
25
  import { serverService } from '../services/ServerService.js';
26
26
  import { feedOnboardService } from '../core/onboard/FeedOnboardService.js';
27
27
  import { openBrowser } from '../utils/osUtils.js';
28
- import { Logger } from '../utils/logger.js';
28
+ import { Logger, EventType, EventStatus } from '../utils/logger.js';
29
29
  import { configProvider } from '../core/loaders/ConfigurationProvider.js';
30
30
  import { onboardStatusManager } from '../core/onboard/OnboardStatusManager.js';
31
+ import { InstallOperationManager } from '../core/loaders/InstallOperationManager.js';
32
+ import { systemSettingsManager } from '../core/loaders/SystemSettingsManager.js';
33
+ import { SystemSettings } from '../core/metadatas/types.js';
34
+ import { getAppVersion } from '../utils/versionUtils.js';
31
35
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
32
36
  const app = express();
33
37
 
@@ -308,6 +312,34 @@ app.get('/api/categories/:categoryName/onboard/status', async (req: Request<{ ca
308
312
  });
309
313
  }
310
314
  });
315
+
316
+ // Get installation operation status
317
+ app.get('/api/categories/:categoryName/servers/:serverName/installation/status', async (req: Request<{ categoryName: string; serverName: string }>, res: Response) => {
318
+ try {
319
+ const { categoryName, serverName } = req.params;
320
+ const details = await InstallOperationManager.getInstance(categoryName, serverName).getDetails();
321
+
322
+ if (!details) {
323
+ return res.status(404).json({
324
+ success: false,
325
+ error: `No installation operation found for server ${serverName} in category ${categoryName}`
326
+ });
327
+ }
328
+
329
+ const response: ApiResponse<typeof details> = {
330
+ success: true,
331
+ data: details
332
+ };
333
+ res.json(response);
334
+ } catch (error) {
335
+ const message = error instanceof Error ? error.message : 'Unknown error';
336
+ res.status(500).json({
337
+ success: false,
338
+ error: `Failed to get installation operation status for server ${req.params.serverName} in category ${req.params.categoryName}: ${message}`
339
+ });
340
+ }
341
+ });
342
+
311
343
  // Uninstall tools from a server
312
344
  app.post('/api/categories/:categoryName/uninstall', async (req: Request<{ categoryName: string }, {}, UninstallServersRequestBody>, res: Response) => {
313
345
  try {
@@ -356,6 +388,59 @@ app.post('/api/categories/:categoryName/uninstall', async (req: Request<{ catego
356
388
  }
357
389
  });
358
390
 
391
+ // System Settings API
392
+ app.get('/api/settings', async (req: Request, res: Response) => {
393
+ try {
394
+ const settings = await systemSettingsManager.getSystemSettings();
395
+ const response: ApiResponse<SystemSettings> = {
396
+ success: true,
397
+ data: settings
398
+ };
399
+ res.json(response);
400
+ } catch (error) {
401
+ const message = error instanceof Error ? error.message : 'Unknown error';
402
+ res.status(500).json({
403
+ success: false,
404
+ error: `Failed to get system settings: ${message}`
405
+ });
406
+ }
407
+ });
408
+
409
+ app.post('/api/settings', async (req: Request<{}, {}, Partial<SystemSettings>>, res: Response) => {
410
+ try {
411
+ const newSettings = req.body;
412
+ const updatedSettings = await systemSettingsManager.createOrUpdateSystemSettings(newSettings);
413
+ const response: ApiResponse<SystemSettings> = {
414
+ success: true,
415
+ data: updatedSettings
416
+ };
417
+ res.json(response);
418
+ } catch (error) {
419
+ const message = error instanceof Error ? error.message : 'Unknown error';
420
+ res.status(500).json({
421
+ success: false,
422
+ error: `Failed to update system settings: ${message}`
423
+ });
424
+ }
425
+ });
426
+
427
+ // API to get package version
428
+ app.get('/api/version', async (req: Request, res: Response) => {
429
+ try {
430
+ const appVersionData = await getAppVersion();
431
+ const response: ApiResponse<typeof appVersionData> = {
432
+ success: true,
433
+ data: appVersionData
434
+ };
435
+ res.json(response);
436
+ } catch (error) {
437
+ const message = error instanceof Error ? error.message : 'Unknown error';
438
+ res.status(500).json({
439
+ success: false,
440
+ error: `Failed to get package version: ${message}`
441
+ });
442
+ }
443
+ });
359
444
 
360
445
  export async function startWebServer(port = 3000): Promise<void> {
361
446
  return new Promise((resolve, reject) => {
@@ -368,10 +453,20 @@ export async function startWebServer(port = 3000): Promise<void> {
368
453
  console.warn(`Failed to open browser: ${err.message}`);
369
454
  });
370
455
 
456
+ // Track IMCP serve event
457
+ Logger.trackEvent(EventType.IMCP_SERVE, {
458
+ status: EventStatus.SUCCESS,
459
+ port: port,
460
+ });
371
461
  resolve();
372
462
  });
373
463
 
374
464
  server.on('error', (error) => {
465
+ Logger.trackEvent(EventType.IMCP_SERVE, {
466
+ status: EventStatus.FAILED,
467
+ errorMessage: error instanceof Error ? error.message : String(error),
468
+ port: port
469
+ });
375
470
  reject(error);
376
471
  });
377
472
  });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function createStartCommand(): Command;
@@ -1,32 +0,0 @@
1
- import { Command } from 'commander';
2
- import { startWebServer } from '../../web/server.js';
3
- import { mcpManager } from '../../core/MCPManager.js';
4
- export function createStartCommand() {
5
- return new Command('start')
6
- .description('Start local web interface')
7
- .option('-p, --port <port>', 'Port to run the server on', '3000')
8
- .action(async (options) => {
9
- try {
10
- // Sync feeds before start the local UI
11
- await mcpManager.syncFeeds();
12
- // Ensure MCP manager is initialized before starting the web server
13
- await mcpManager.initialize();
14
- const port = parseInt(options.port, 10);
15
- if (isNaN(port) || port < 1 || port > 65535) {
16
- throw new Error('Invalid port number');
17
- }
18
- await startWebServer(port);
19
- // The server is running, keep the process alive
20
- process.on('SIGINT', () => {
21
- console.log('\nShutting down server...');
22
- process.exit(0);
23
- });
24
- }
25
- catch (error) {
26
- const message = error instanceof Error ? error.message : 'Unknown error';
27
- console.error('Failed to start web server:', message);
28
- process.exit(1);
29
- }
30
- });
31
- }
32
- //# sourceMappingURL=start.js.map
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function createSyncCommand(): Command;
@@ -1,17 +0,0 @@
1
- import { Command } from 'commander';
2
- import { serverService } from '../../services/ServerService.js';
3
- export function createSyncCommand() {
4
- return new Command('sync')
5
- .description('Sync MCP server configurations from remote feed source')
6
- .action(async () => {
7
- try {
8
- await serverService.syncFeeds();
9
- }
10
- catch (error) {
11
- const message = error instanceof Error ? error.message : 'Unknown error';
12
- console.error('Error syncing configurations:', message);
13
- process.exit(1);
14
- }
15
- });
16
- }
17
- //# sourceMappingURL=sync.js.map
@@ -1,32 +0,0 @@
1
- import { MCPConfiguration } from './types.js';
2
- export declare class ConfigurationLoader {
3
- /**
4
- * Updates the installed status for a server and client combination
5
- */
6
- private static updateServerInstalledStatus;
7
- /**
8
- * Removes a client's status from a server
9
- */
10
- private static removeClientStatus;
11
- /**
12
- * Synchronizes server categories with client MCP settings.
13
- * Uses clientMCPSettings as source of truth for installation status.
14
- */
15
- static syncServerCategoriesWithClientSettings(configuration: MCPConfiguration): MCPConfiguration;
16
- /**
17
- * Initializes installation status for a feed configuration
18
- */
19
- private static initializeInstallationStatus;
20
- /**
21
- * Synchronizes server categories with feeds
22
- */
23
- private static syncServerCategoriesWithFeeds;
24
- /**
25
- * Loads feed configurations into the MCP configuration
26
- */
27
- static loadFeedsIntoConfiguration(configuration: MCPConfiguration, feedFile?: string): Promise<MCPConfiguration>;
28
- /**
29
- * Loads MCP client settings into the configuration
30
- */
31
- static loadClientMCPSettings(configuration: MCPConfiguration): Promise<MCPConfiguration>;
32
- }
@@ -1,236 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { LOCAL_FEEDS_DIR, SUPPORTED_CLIENTS } from './constants.js';
4
- import { Logger } from '../utils/logger.js';
5
- import { readJsonFile } from '../utils/clientUtils.js';
6
- export class ConfigurationLoader {
7
- /**
8
- * Updates the installed status for a server and client combination
9
- */
10
- static updateServerInstalledStatus(serverStatus, clientName, operationStatus) {
11
- if (!serverStatus.installedStatus) {
12
- serverStatus.installedStatus = {};
13
- }
14
- serverStatus.installedStatus[clientName] = operationStatus;
15
- }
16
- /**
17
- * Removes a client's status from a server
18
- */
19
- static removeClientStatus(serverStatus, clientName) {
20
- if (serverStatus.installedStatus && serverStatus.installedStatus[clientName]) {
21
- delete serverStatus.installedStatus[clientName];
22
- }
23
- }
24
- /**
25
- * Synchronizes server categories with client MCP settings.
26
- * Uses clientMCPSettings as source of truth for installation status.
27
- */
28
- static syncServerCategoriesWithClientSettings(configuration) {
29
- if (!configuration.clientMCPSettings) {
30
- return configuration;
31
- }
32
- configuration.localServerCategories = configuration.localServerCategories.map(category => {
33
- if (!category.installationStatus?.serversStatus) {
34
- return category;
35
- }
36
- const updatedServerStatus = { ...category.installationStatus.serversStatus };
37
- const clientSettings = configuration.clientMCPSettings;
38
- for (const [clientName, settings] of Object.entries(clientSettings)) {
39
- const clientServers = clientName === 'GithubCopilot'
40
- ? settings.servers || {}
41
- : settings.mcpServers || {};
42
- Object.keys(updatedServerStatus).forEach(serverName => {
43
- if (clientServers[serverName]) {
44
- if (!updatedServerStatus[serverName].installedStatus[clientName]) {
45
- const operationStatus = {
46
- status: 'completed',
47
- type: 'install',
48
- target: 'server',
49
- message: `Server ${serverName} is configured for client ${clientName}`
50
- };
51
- ConfigurationLoader.updateServerInstalledStatus(updatedServerStatus[serverName], clientName, operationStatus);
52
- }
53
- }
54
- else {
55
- ConfigurationLoader.removeClientStatus(updatedServerStatus[serverName], clientName);
56
- }
57
- });
58
- }
59
- return {
60
- ...category,
61
- installationStatus: {
62
- ...category.installationStatus,
63
- serversStatus: updatedServerStatus,
64
- lastUpdated: new Date().toISOString()
65
- }
66
- };
67
- });
68
- return configuration;
69
- }
70
- /**
71
- * Initializes installation status for a feed configuration
72
- */
73
- static initializeInstallationStatus(feedConfig) {
74
- const requirementsStatus = {};
75
- const serversStatus = {};
76
- if (feedConfig) {
77
- if (feedConfig.requirements) {
78
- for (const req of feedConfig.requirements) {
79
- requirementsStatus[req.name] = {
80
- name: req.name,
81
- type: req.type,
82
- installed: false,
83
- version: req.version,
84
- error: undefined
85
- };
86
- }
87
- }
88
- if (feedConfig.mcpServers) {
89
- for (const mcp of feedConfig.mcpServers) {
90
- serversStatus[mcp.name] = {
91
- name: mcp.name,
92
- error: undefined,
93
- installedStatus: {}
94
- };
95
- }
96
- }
97
- }
98
- return {
99
- requirementsStatus,
100
- serversStatus,
101
- lastUpdated: new Date().toISOString()
102
- };
103
- }
104
- /**
105
- * Synchronizes server categories with feeds
106
- */
107
- static async syncServerCategoriesWithFeeds(configuration) {
108
- // Filter out categories that don't have corresponding feeds and update existing ones
109
- configuration.localServerCategories = configuration.localServerCategories
110
- .filter(server => configuration.feeds[server.name])
111
- .map(server => {
112
- server.feedConfiguration = configuration.feeds[server.name];
113
- if (!server.installationStatus ||
114
- !server.installationStatus.requirementsStatus ||
115
- Object.keys(server.installationStatus.requirementsStatus).length === 0 ||
116
- !server.installationStatus.serversStatus ||
117
- Object.keys(server.installationStatus.serversStatus).length < Object.keys(server.feedConfiguration?.mcpServers || []).length) {
118
- server.installationStatus = ConfigurationLoader.initializeInstallationStatus(server.feedConfiguration);
119
- }
120
- return server;
121
- });
122
- // Add new categories for feeds that don't have a corresponding category
123
- const existingServerNames = new Set(configuration.localServerCategories.map(category => category.name));
124
- for (const [feedName, feedConfig] of Object.entries(configuration.feeds)) {
125
- if (!existingServerNames.has(feedName)) {
126
- const newServerCategory = {
127
- name: feedName,
128
- displayName: feedConfig.displayName || feedName,
129
- type: 'local',
130
- description: feedConfig.description || `Local MCP server category: ${feedName}`,
131
- installationStatus: ConfigurationLoader.initializeInstallationStatus(feedConfig),
132
- feedConfiguration: feedConfig
133
- };
134
- configuration.localServerCategories.push(newServerCategory);
135
- console.log(`Created new local server entry for feed: ${feedName}`);
136
- }
137
- }
138
- return configuration;
139
- }
140
- /**
141
- * Loads feed configurations into the MCP configuration
142
- */
143
- static async loadFeedsIntoConfiguration(configuration, feedFile) {
144
- try {
145
- await fs.mkdir(LOCAL_FEEDS_DIR, { recursive: true });
146
- const feeds = {};
147
- // Load provided feed file if specified
148
- if (feedFile) {
149
- try {
150
- const content = await fs.readFile(feedFile, 'utf8');
151
- const config = JSON.parse(content);
152
- if (config && config.name) {
153
- feeds[config.name] = config;
154
- console.log(`Loaded feed configuration from provided file: ${feedFile}`);
155
- }
156
- }
157
- catch (error) {
158
- console.log(`Error loading feed configuration from provided file ${feedFile}:`, error);
159
- }
160
- }
161
- // Load feeds from LOCAL_FEEDS_DIR
162
- const files = await fs.readdir(LOCAL_FEEDS_DIR);
163
- const jsonFiles = files.filter(file => file.endsWith('.json'));
164
- if (jsonFiles.length === 0 && !feedFile) {
165
- console.log(`No feed configuration files found in ${LOCAL_FEEDS_DIR}`);
166
- return configuration;
167
- }
168
- for (const file of jsonFiles) {
169
- try {
170
- const filePath = path.join(LOCAL_FEEDS_DIR, file);
171
- const content = await fs.readFile(filePath, 'utf8');
172
- const config = JSON.parse(content);
173
- if (config && config.name) {
174
- // If feed exists from provided file, skip the local one
175
- if (!feeds[config.name]) {
176
- feeds[config.name] = config;
177
- }
178
- else {
179
- console.log(`Skipping local feed ${config.name} as it was provided via --feed-file`);
180
- }
181
- }
182
- }
183
- catch (error) {
184
- console.warn(`Error loading feed configuration from ${file}:`, error);
185
- }
186
- }
187
- configuration.feeds = feeds;
188
- return await ConfigurationLoader.syncServerCategoriesWithFeeds(configuration);
189
- }
190
- catch (error) {
191
- console.error("Error loading feed configurations:", error);
192
- throw error;
193
- }
194
- }
195
- /**
196
- * Loads MCP client settings into the configuration
197
- */
198
- static async loadClientMCPSettings(configuration) {
199
- try {
200
- Logger.debug('Starting to load MCP client settings...');
201
- const settings = {};
202
- for (const [clientName, clientSettings] of Object.entries(SUPPORTED_CLIENTS)) {
203
- const settingPath = process.env.CODE_INSIDERS
204
- ? clientSettings.codeInsiderSettingPath
205
- : clientSettings.codeSettingPath;
206
- try {
207
- let content = await readJsonFile(settingPath, true);
208
- if (clientName === 'GithubCopilot') {
209
- if (!content.mcp) {
210
- content = {
211
- servers: {},
212
- inputs: []
213
- };
214
- }
215
- else {
216
- content = content.mcp;
217
- }
218
- }
219
- settings[clientName] = content;
220
- Logger.debug(`Successfully loaded MCP settings for ${clientName}`);
221
- }
222
- catch (error) {
223
- Logger.debug(`Warning: Could not load MCP settings for client ${clientName}: ${error instanceof Error ? error.message : String(error)}`);
224
- settings[clientName] = {};
225
- }
226
- }
227
- configuration.clientMCPSettings = settings;
228
- return ConfigurationLoader.syncServerCategoriesWithClientSettings(configuration);
229
- }
230
- catch (error) {
231
- Logger.error('Error loading client MCP settings:', error);
232
- throw error;
233
- }
234
- }
235
- }
236
- //# sourceMappingURL=ConfigurationLoader.js.map
@@ -1,35 +0,0 @@
1
- import { MCPServerCategory, FeedConfiguration, InstallationStatus, RequirementStatus, MCPServerStatus, OperationStatus, McpConfig } from './types.js';
2
- export declare class ConfigurationProvider {
3
- private static instance;
4
- private configPath;
5
- private configuration;
6
- private configLock;
7
- private tempDir;
8
- private constructor();
9
- static getInstance(): ConfigurationProvider;
10
- private withLock;
11
- initialize(feedFile?: string): Promise<void>;
12
- private saveConfiguration;
13
- getServerCategories(): Promise<MCPServerCategory[]>;
14
- getServerCategory(categoryName: string): Promise<MCPServerCategory | undefined>;
15
- getClientMcpSettings(): Promise<Record<string, Record<string, any>> | undefined>;
16
- getFeedConfiguration(categoryName: string): Promise<FeedConfiguration | undefined>;
17
- getServerMcpConfig(categoryName: string, serverName: string): Promise<McpConfig | undefined>;
18
- getInstallationStatus(categoryName: string): Promise<InstallationStatus | undefined>;
19
- getServerStatus(categoryName: string, serverName: string): Promise<MCPServerStatus | undefined>;
20
- getRequirementStatus(categoryName: string, requirementName: string): Promise<RequirementStatus | undefined>;
21
- updateInstallationStatus(categoryName: string, requirementStatus: Record<string, RequirementStatus>, serverStatus: Record<string, MCPServerStatus>): Promise<boolean>;
22
- updateRequirementStatus(categoryName: string, requirementName: string, status: RequirementStatus): Promise<boolean>;
23
- updateRequirementOperationStatus(categoryName: string, requirementName: string, operationStatus: OperationStatus): Promise<boolean>;
24
- updateServerStatus(categoryName: string, serverName: string, status: MCPServerStatus): Promise<boolean>;
25
- updateServerOperationStatus(categoryName: string, serverName: string, clientName: string, operationStatus: OperationStatus): Promise<boolean>;
26
- isRequirementsReady(categoryName: string, serverName: string): Promise<boolean>;
27
- GetServerRequirementStatus(categoryName: string, serverName: string): Promise<RequirementStatus[]>;
28
- isServerReady(categoryName: string, serverName: string, clients: string[]): Promise<boolean>;
29
- syncFeeds(): Promise<void>;
30
- private loadFeedsIntoConfiguration;
31
- private loadClientMCPSettings;
32
- reloadClientMCPSettings(): Promise<void>;
33
- removeServerFromClientMCPSettings(serverName: string, target?: string): Promise<void>;
34
- }
35
- export declare const configProvider: ConfigurationProvider;