imcp 0.0.15 → 0.0.17

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 (139) hide show
  1. package/dist/cli/commands/install.js +2 -2
  2. package/dist/cli/commands/list.js +2 -2
  3. package/dist/cli/commands/serve.js +1 -1
  4. package/dist/core/RequirementService.d.ts +0 -12
  5. package/dist/core/RequirementService.js +0 -24
  6. package/dist/core/installers/clients/BaseClientInstaller.d.ts +1 -1
  7. package/dist/core/installers/clients/ClientInstaller.d.ts +1 -2
  8. package/dist/core/installers/clients/ClientInstaller.js +2 -4
  9. package/dist/core/installers/clients/ClientInstallerFactory.d.ts +4 -3
  10. package/dist/core/installers/clients/ClientInstallerFactory.js +11 -15
  11. package/dist/core/installers/clients/ClineInstaller.d.ts +1 -1
  12. package/dist/core/installers/clients/ClineInstaller.js +1 -1
  13. package/dist/core/installers/clients/ExtensionInstaller.js +1 -1
  14. package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +1 -1
  15. package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -1
  16. package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +1 -1
  17. package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -1
  18. package/dist/core/installers/requirements/BaseInstaller.d.ts +1 -1
  19. package/dist/core/installers/requirements/BaseInstaller.js +1 -1
  20. package/dist/core/installers/requirements/CommandInstaller.d.ts +1 -1
  21. package/dist/core/installers/requirements/CommandInstaller.js +1 -1
  22. package/dist/core/installers/requirements/GeneralInstaller.d.ts +1 -1
  23. package/dist/core/installers/requirements/InstallerFactory.d.ts +1 -1
  24. package/dist/core/installers/requirements/NpmInstaller.d.ts +1 -1
  25. package/dist/core/installers/requirements/NpmInstaller.js +1 -1
  26. package/dist/core/installers/requirements/PipInstaller.d.ts +1 -1
  27. package/dist/core/installers/requirements/RequirementInstaller.d.ts +1 -1
  28. package/dist/core/loaders/ConfigurationLoader.d.ts +32 -0
  29. package/dist/core/loaders/ConfigurationLoader.js +236 -0
  30. package/dist/core/loaders/ConfigurationProvider.d.ts +35 -0
  31. package/dist/core/loaders/ConfigurationProvider.js +375 -0
  32. package/dist/core/loaders/ServerSchemaLoader.d.ts +11 -0
  33. package/{src/core/ServerSchemaLoader.ts → dist/core/loaders/ServerSchemaLoader.js} +43 -48
  34. package/dist/core/loaders/ServerSchemaProvider.d.ts +17 -0
  35. package/{src/core/ServerSchemaProvider.ts → dist/core/loaders/ServerSchemaProvider.js} +120 -137
  36. package/dist/core/metadatas/constants.d.ts +47 -0
  37. package/dist/core/metadatas/constants.js +94 -0
  38. package/dist/core/metadatas/types.d.ts +166 -0
  39. package/dist/core/metadatas/types.js +16 -0
  40. package/dist/core/onboard/FeedOnboardService.d.ts +1 -1
  41. package/dist/core/onboard/FeedOnboardService.js +1 -1
  42. package/dist/core/onboard/OnboardProcessor.d.ts +1 -1
  43. package/dist/core/onboard/OnboardProcessor.js +1 -1
  44. package/dist/core/onboard/OnboardStatus.d.ts +1 -1
  45. package/dist/core/onboard/OnboardStatusManager.d.ts +1 -1
  46. package/dist/core/onboard/OnboardStatusManager.js +1 -1
  47. package/dist/core/validators/FeedValidator.d.ts +1 -1
  48. package/dist/core/validators/IServerValidator.d.ts +1 -1
  49. package/dist/core/validators/SSEServerValidator.d.ts +1 -1
  50. package/dist/core/validators/ServerValidatorFactory.d.ts +1 -1
  51. package/dist/core/validators/StdioServerValidator.d.ts +1 -1
  52. package/dist/core/validators/StdioServerValidator.js +1 -1
  53. package/dist/index.d.ts +3 -3
  54. package/dist/index.js +3 -3
  55. package/dist/services/InstallationService.d.ts +50 -0
  56. package/dist/services/InstallationService.js +350 -0
  57. package/dist/services/MCPManager.d.ts +28 -0
  58. package/dist/services/MCPManager.js +188 -0
  59. package/dist/services/RequirementService.d.ts +40 -0
  60. package/dist/services/RequirementService.js +110 -0
  61. package/dist/services/ServerService.d.ts +2 -2
  62. package/dist/services/ServerService.js +5 -5
  63. package/dist/utils/adoUtils.d.ts +2 -2
  64. package/dist/utils/adoUtils.js +1 -1
  65. package/dist/utils/feedUtils.js +1 -1
  66. package/dist/utils/githubUtils.d.ts +1 -1
  67. package/dist/utils/githubUtils.js +1 -1
  68. package/dist/utils/logger.js +1 -1
  69. package/dist/utils/macroExpressionUtils.d.ts +1 -1
  70. package/dist/utils/osUtils.d.ts +1 -1
  71. package/dist/utils/osUtils.js +1 -1
  72. package/dist/web/contract/serverContract.d.ts +1 -1
  73. package/dist/web/public/index.html +1 -3
  74. package/dist/web/public/js/api.js +2 -80
  75. package/dist/web/public/js/flights/flights.js +2 -2
  76. package/dist/web/public/js/modal/installation.js +5 -5
  77. package/dist/web/server.js +2 -2
  78. package/package.json +1 -1
  79. package/src/cli/commands/install.ts +3 -3
  80. package/src/cli/commands/list.ts +2 -2
  81. package/src/cli/commands/serve.ts +3 -2
  82. package/src/cli/index.ts +1 -1
  83. package/src/core/installers/clients/BaseClientInstaller.ts +134 -3
  84. package/src/core/installers/clients/ClientInstaller.ts +4 -6
  85. package/src/core/installers/clients/ClientInstallerFactory.ts +12 -15
  86. package/src/core/installers/clients/ClineInstaller.ts +1 -101
  87. package/src/core/installers/clients/ExtensionInstaller.ts +1 -1
  88. package/src/core/installers/clients/GithubCopilotInstaller.ts +1 -101
  89. package/src/core/installers/clients/MSRooCodeInstaller.ts +1 -102
  90. package/src/core/installers/requirements/BaseInstaller.ts +2 -2
  91. package/src/core/installers/requirements/CommandInstaller.ts +1 -1
  92. package/src/core/installers/requirements/GeneralInstaller.ts +1 -1
  93. package/src/core/installers/requirements/InstallerFactory.ts +1 -1
  94. package/src/core/installers/requirements/NpmInstaller.ts +12 -12
  95. package/src/core/installers/requirements/PipInstaller.ts +1 -1
  96. package/src/core/installers/requirements/RequirementInstaller.ts +1 -1
  97. package/src/core/{ConfigurationLoader.ts → loaders/ConfigurationLoader.ts} +31 -7
  98. package/src/core/{ConfigurationProvider.ts → loaders/ConfigurationProvider.ts} +18 -10
  99. package/src/core/loaders/ServerSchemaLoader.ts +117 -0
  100. package/src/core/loaders/ServerSchemaProvider.ts +99 -0
  101. package/src/core/{types.ts → metadatas/types.ts} +3 -2
  102. package/src/core/onboard/FeedOnboardService.ts +270 -146
  103. package/src/core/onboard/OnboardProcessor.ts +60 -11
  104. package/src/core/onboard/OnboardStatus.ts +7 -2
  105. package/src/core/onboard/OnboardStatusManager.ts +270 -43
  106. package/src/core/validators/FeedValidator.ts +65 -9
  107. package/src/core/validators/IServerValidator.ts +1 -1
  108. package/src/core/validators/SSEServerValidator.ts +2 -2
  109. package/src/core/validators/ServerValidatorFactory.ts +1 -1
  110. package/src/core/validators/StdioServerValidator.ts +86 -34
  111. package/src/index.ts +3 -3
  112. package/src/{core → services}/InstallationService.ts +5 -5
  113. package/src/{core → services}/MCPManager.ts +10 -5
  114. package/src/{core → services}/RequirementService.ts +2 -31
  115. package/src/services/ServerService.ts +7 -7
  116. package/src/utils/adoUtils.ts +3 -3
  117. package/src/utils/feedUtils.ts +2 -2
  118. package/src/utils/githubUtils.ts +2 -2
  119. package/src/utils/logger.ts +13 -1
  120. package/src/utils/macroExpressionUtils.ts +1 -1
  121. package/src/utils/osUtils.ts +4 -4
  122. package/src/web/contract/serverContract.ts +2 -2
  123. package/src/web/public/index.html +1 -3
  124. package/src/web/public/js/api.js +2 -80
  125. package/src/web/public/js/flights/flights.js +2 -2
  126. package/src/web/public/js/modal/installation.js +6 -6
  127. package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
  128. package/src/web/public/js/onboard/formProcessor.js +200 -34
  129. package/src/web/public/js/onboard/index.js +2 -2
  130. package/src/web/public/js/onboard/publishHandler.js +30 -22
  131. package/src/web/public/js/onboard/templates.js +34 -40
  132. package/src/web/public/js/onboard/uiHandlers.js +175 -84
  133. package/src/web/public/js/onboard/validationHandlers.js +147 -64
  134. package/src/web/public/js/serverCategoryDetails.js +19 -4
  135. package/src/web/public/js/serverCategoryList.js +13 -1
  136. package/src/web/public/onboard.html +1 -1
  137. package/src/web/server.ts +30 -14
  138. package/src/services/InstallRequestValidator.ts +0 -112
  139. /package/src/core/{constants.ts → metadatas/constants.ts} +0 -0
@@ -2,8 +2,8 @@ import { Command } from 'commander';
2
2
  import { serverService } from '../../services/ServerService.js';
3
3
  import { Logger } from '../../utils/logger.js';
4
4
  import { hasLocalFeeds } from '../../utils/feedUtils.js';
5
- import { SUPPORTED_CLIENT_NAMES } from '../../core/constants.js';
6
- import { mcpManager } from '../../core/MCPManager.js';
5
+ import { SUPPORTED_CLIENT_NAMES } from '../../core/metadatas/constants.js';
6
+ import { mcpManager } from '../../services/MCPManager.js';
7
7
  export function createInstallCommand() {
8
8
  return new Command('install')
9
9
  .description('Install specific MCP servers')
@@ -1,8 +1,8 @@
1
1
  import { Command } from 'commander';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
- import { LOCAL_FEEDS_DIR } from '../../core/constants.js';
5
- import { mcpManager } from '../../core/MCPManager.js';
4
+ import { LOCAL_FEEDS_DIR } from '../../core/metadatas/constants.js';
5
+ import { mcpManager } from '../../services/MCPManager.js';
6
6
  import { Logger } from '../../utils/logger.js';
7
7
  export function createListCommand() {
8
8
  return new Command('list')
@@ -1,6 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { startWebServer } from '../../web/server.js';
3
- import { mcpManager } from '../../core/MCPManager.js';
3
+ import { mcpManager } from '../../services/MCPManager.js';
4
4
  export function createServeCommand() {
5
5
  return new Command('serve')
6
6
  .description('Serve local web interface')
@@ -11,12 +11,6 @@ export declare class RequirementService {
11
11
  * @returns The RequirementService instance
12
12
  */
13
13
  static getInstance(): RequirementService;
14
- /**
15
- * Install a requirement
16
- * @param requirement The requirement to install
17
- * @returns The installation status
18
- */
19
- installRequirement(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
20
14
  /**
21
15
  * Check the installation status of a requirement
22
16
  * @param requirement The requirement to check
@@ -36,12 +30,6 @@ export declare class RequirementService {
36
30
  * @returns The updated requirement status
37
31
  */
38
32
  updateRequirement(requirement: RequirementConfig, updateVersion: string, options?: ServerInstallOptions): Promise<RequirementStatus>;
39
- /**
40
- * Install multiple requirements
41
- * @param requirements The requirements to install
42
- * @returns A map of requirement names to their installation status
43
- */
44
- installRequirements(requirements: RequirementConfig[]): Promise<Record<string, RequirementStatus>>;
45
33
  /**
46
34
  * Validate a requirement configuration
47
35
  * @param requirement The requirement to validate
@@ -18,17 +18,6 @@ export class RequirementService {
18
18
  }
19
19
  return RequirementService.instance;
20
20
  }
21
- /**
22
- * Install a requirement
23
- * @param requirement The requirement to install
24
- * @returns The installation status
25
- */
26
- async installRequirement(requirement, options) {
27
- // Validate requirement
28
- this.validateRequirement(requirement);
29
- // Install the requirement
30
- return await this.installerFactory.install(requirement, options);
31
- }
32
21
  /**
33
22
  * Check the installation status of a requirement
34
23
  * @param requirement The requirement to check
@@ -78,19 +67,6 @@ export class RequirementService {
78
67
  // Install the updated version
79
68
  return await this.installerFactory.install(updatedRequirement, options);
80
69
  }
81
- /**
82
- * Install multiple requirements
83
- * @param requirements The requirements to install
84
- * @returns A map of requirement names to their installation status
85
- */
86
- async installRequirements(requirements) {
87
- const results = {};
88
- // Process each requirement sequentially to avoid conflicts
89
- for (const requirement of requirements) {
90
- results[requirement.name] = await this.installRequirement(requirement);
91
- }
92
- return results;
93
- }
94
70
  /**
95
71
  * Validate a requirement configuration
96
72
  * @param requirement The requirement to validate
@@ -1,4 +1,4 @@
1
- import { OperationStatus, McpConfig, ServerInstallOptions } from '../../types.js';
1
+ import { OperationStatus, McpConfig, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  /**
3
3
  * Base class for client installers with shared functionality
4
4
  */
@@ -1,4 +1,4 @@
1
- import { ServerOperationResult, ServerInstallOptions } from '../../types.js';
1
+ import { ServerOperationResult, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  /**
3
3
  * Main client installer class that orchestrates client installation process
4
4
  * Handles requirements checking and delegates to specific client installers
@@ -8,7 +8,6 @@ export declare class ClientInstaller {
8
8
  private serverName;
9
9
  private clients;
10
10
  private configProvider;
11
- private operationStatuses;
12
11
  constructor(categoryName: string, serverName: string, clients: string[]);
13
12
  /**
14
13
  * Generate a unique operation ID for tracking installations
@@ -1,4 +1,4 @@
1
- import { ConfigurationProvider } from '../../ConfigurationProvider.js';
1
+ import { ConfigurationProvider } from '../../loaders/ConfigurationProvider.js';
2
2
  import { ClientInstallerFactory } from './ClientInstallerFactory.js';
3
3
  /**
4
4
  * Main client installer class that orchestrates client installation process
@@ -9,13 +9,11 @@ export class ClientInstaller {
9
9
  serverName;
10
10
  clients;
11
11
  configProvider;
12
- operationStatuses;
13
12
  constructor(categoryName, serverName, clients) {
14
13
  this.categoryName = categoryName;
15
14
  this.serverName = serverName;
16
15
  this.clients = clients;
17
16
  this.configProvider = ConfigurationProvider.getInstance();
18
- this.operationStatuses = new Map();
19
17
  }
20
18
  /**
21
19
  * Generate a unique operation ID for tracking installations
@@ -100,7 +98,7 @@ export class ClientInstaller {
100
98
  return;
101
99
  }
102
100
  // Create client-specific installer
103
- const installer = ClientInstallerFactory.createInstaller(clientName);
101
+ const installer = ClientInstallerFactory.getInstaller(clientName);
104
102
  if (!installer) {
105
103
  throw new Error(`Failed to create installer for client: ${clientName}`);
106
104
  }
@@ -4,12 +4,13 @@ import { BaseClientInstaller } from './BaseClientInstaller.js';
4
4
  * Handles creation of appropriate installer based on client type
5
5
  */
6
6
  export declare class ClientInstallerFactory {
7
+ private static readonly installerMap;
7
8
  /**
8
- * Create a client installer instance based on client type
9
- * @param clientName Name of the client to create installer for
9
+ * Get a client installer instance based on client type
10
+ * @param clientName Name of the client to get installer for
10
11
  * @returns Client-specific installer instance or undefined if client not supported
11
12
  */
12
- static createInstaller(clientName: string): BaseClientInstaller | undefined;
13
+ static getInstaller(clientName: string): BaseClientInstaller | undefined;
13
14
  /**
14
15
  * Check if a client is supported
15
16
  * @param clientName Name of the client to check
@@ -1,33 +1,29 @@
1
1
  import { MSRooCodeInstaller } from './MSRooCodeInstaller.js';
2
2
  import { ClineInstaller } from './ClineInstaller.js';
3
3
  import { GithubCopilotInstaller } from './GithubCopilotInstaller.js';
4
- import { SUPPORTED_CLIENTS } from '../../constants.js';
4
+ import { SUPPORTED_CLIENTS } from '../../metadatas/constants.js';
5
5
  /**
6
6
  * Factory for creating client-specific installers
7
7
  * Handles creation of appropriate installer based on client type
8
8
  */
9
9
  export class ClientInstallerFactory {
10
+ static installerMap = {
11
+ [Object.keys(SUPPORTED_CLIENTS)[0]]: MSRooCodeInstaller,
12
+ [Object.keys(SUPPORTED_CLIENTS)[1]]: ClineInstaller,
13
+ [Object.keys(SUPPORTED_CLIENTS)[2]]: GithubCopilotInstaller
14
+ };
10
15
  /**
11
- * Create a client installer instance based on client type
12
- * @param clientName Name of the client to create installer for
16
+ * Get a client installer instance based on client type
17
+ * @param clientName Name of the client to get installer for
13
18
  * @returns Client-specific installer instance or undefined if client not supported
14
19
  */
15
- static createInstaller(clientName) {
20
+ static getInstaller(clientName) {
16
21
  // Check if client is supported
17
22
  if (!SUPPORTED_CLIENTS[clientName]) {
18
23
  return undefined;
19
24
  }
20
- // Create appropriate installer based on client type
21
- switch (clientName) {
22
- case 'MSRooCode':
23
- return new MSRooCodeInstaller();
24
- case 'Cline':
25
- return new ClineInstaller();
26
- case 'GithubCopilot':
27
- return new GithubCopilotInstaller();
28
- default:
29
- return undefined;
30
- }
25
+ const InstallerClass = this.installerMap[clientName];
26
+ return InstallerClass ? new InstallerClass() : undefined;
31
27
  }
32
28
  /**
33
29
  * Check if a client is supported
@@ -1,5 +1,5 @@
1
1
  import { BaseClientInstaller } from './BaseClientInstaller.js';
2
- import { ServerInstallOptions, OperationStatus, McpConfig } from '../../types.js';
2
+ import { ServerInstallOptions, OperationStatus, McpConfig } from '../../metadatas/types.js';
3
3
  /**
4
4
  * Cline client installer implementation
5
5
  * Handles installation of Cline client including extension installation and settings configuration
@@ -2,7 +2,7 @@ import { BaseClientInstaller } from './BaseClientInstaller.js';
2
2
  import { Logger } from '../../../utils/logger.js';
3
3
  import { readJsonFile, writeJsonFile } from '../../../utils/clientUtils.js';
4
4
  import { ExtensionInstaller } from './ExtensionInstaller.js';
5
- import { SUPPORTED_CLIENTS } from '../../constants.js';
5
+ import { SUPPORTED_CLIENTS } from '../../metadatas/constants.js';
6
6
  import { isCommandAvailable } from '../../../utils/osUtils.js';
7
7
  /**
8
8
  * Cline client installer implementation
@@ -1,6 +1,6 @@
1
1
  import { exec } from 'child_process';
2
2
  import { promisify } from 'util';
3
- import { SUPPORTED_CLIENTS } from '../../constants.js';
3
+ import { SUPPORTED_CLIENTS } from '../../metadatas/constants.js';
4
4
  import { Logger } from '../../../utils/logger.js';
5
5
  import { handleGitHubRelease } from '../../../utils/githubUtils.js';
6
6
  import { compareVersions } from '../../../utils/versionUtils.js';
@@ -1,5 +1,5 @@
1
1
  import { BaseClientInstaller } from './BaseClientInstaller.js';
2
- import { ServerInstallOptions, OperationStatus, McpConfig } from '../../types.js';
2
+ import { ServerInstallOptions, OperationStatus, McpConfig } from '../../metadatas/types.js';
3
3
  /**
4
4
  * Github Copilot client installer implementation
5
5
  * Handles installation of Github Copilot client including extension installation and settings configuration
@@ -2,7 +2,7 @@ import { BaseClientInstaller } from './BaseClientInstaller.js';
2
2
  import { Logger } from '../../../utils/logger.js';
3
3
  import { readJsonFile, writeJsonFile } from '../../../utils/clientUtils.js';
4
4
  import { ExtensionInstaller } from './ExtensionInstaller.js';
5
- import { SUPPORTED_CLIENTS } from '../../constants.js';
5
+ import { SUPPORTED_CLIENTS } from '../../metadatas/constants.js';
6
6
  import { isCommandAvailable } from '../../../utils/osUtils.js';
7
7
  /**
8
8
  * Github Copilot client installer implementation
@@ -1,5 +1,5 @@
1
1
  import { BaseClientInstaller } from './BaseClientInstaller.js';
2
- import { ServerInstallOptions, OperationStatus, McpConfig } from '../../types.js';
2
+ import { ServerInstallOptions, OperationStatus, McpConfig } from '../../metadatas/types.js';
3
3
  /**
4
4
  * MSRooCode client installer implementation
5
5
  */
@@ -2,7 +2,7 @@ import { BaseClientInstaller } from './BaseClientInstaller.js';
2
2
  import { Logger } from '../../../utils/logger.js';
3
3
  import { readJsonFile, writeJsonFile } from '../../../utils/clientUtils.js';
4
4
  import { ExtensionInstaller } from './ExtensionInstaller.js';
5
- import { SUPPORTED_CLIENTS } from '../../constants.js';
5
+ import { SUPPORTED_CLIENTS } from '../../metadatas/constants.js';
6
6
  import { isCommandAvailable } from '../../../utils/osUtils.js';
7
7
  /**
8
8
  * MSRooCode client installer implementation
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { RequirementInstaller } from './RequirementInstaller.js';
3
3
  /**
4
4
  * Abstract base class with common functionality for all requirement installers
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { SETTINGS_DIR } from '../../constants.js';
2
+ import { SETTINGS_DIR } from '../../metadatas/constants.js';
3
3
  import { Logger } from '../../../utils/logger.js';
4
4
  /**
5
5
  * Abstract base class with common functionality for all requirement installers
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { BaseInstaller } from './BaseInstaller.js';
3
3
  /**
4
4
  * Installer implementation for command-line tools
@@ -1,4 +1,4 @@
1
- import { OSType } from '../../types.js';
1
+ import { OSType } from '../../metadatas/types.js';
2
2
  import { BaseInstaller } from './BaseInstaller.js';
3
3
  import { getOSType, refreshPathEnv } from '../../../utils/osUtils.js';
4
4
  import { Logger } from '../../../utils/logger.js';
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { BaseInstaller } from './BaseInstaller.js';
3
3
  /**
4
4
  * Installer implementation for general requirements (type 'other')
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { RequirementInstaller } from './RequirementInstaller.js';
3
3
  import { exec } from 'child_process';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { BaseInstaller } from './BaseInstaller.js';
3
3
  /**
4
4
  * Installer implementation for NPM packages
@@ -5,7 +5,7 @@ import { handleGitHubRelease, getGitHubLatestVersion } from '../../../utils/gith
5
5
  import { handleArtifact as handleAdoArtifact, getArtifactLatestVersion } from '../../../utils/adoUtils.js';
6
6
  import path from 'path';
7
7
  import fs from 'fs/promises';
8
- import { SETTINGS_DIR } from '../../constants.js'; // Corrected path
8
+ import { SETTINGS_DIR } from '../../metadatas/constants.js'; // Corrected path
9
9
  import { Logger } from '../../../utils/logger.js';
10
10
  /**
11
11
  * Installer implementation for NPM packages
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  import { BaseInstaller } from './BaseInstaller.js';
3
3
  /**
4
4
  * Installer implementation for Python packages using pip
@@ -1,4 +1,4 @@
1
- import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../types.js';
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../../metadatas/types.js';
2
2
  /**
3
3
  * Interface for requirement installers.
4
4
  * Implementations should handle specific requirement types.
@@ -0,0 +1,32 @@
1
+ import { MCPConfiguration } from '../metadatas/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
+ }
@@ -0,0 +1,236 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { LOCAL_FEEDS_DIR, SUPPORTED_CLIENTS } from '../metadatas/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