imcp 0.0.16 → 0.0.18
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.
- package/dist/cli/commands/install.js +2 -2
- package/dist/cli/commands/list.js +2 -2
- package/dist/cli/commands/serve.js +3 -2
- package/dist/core/RequirementService.d.ts +0 -12
- package/dist/core/RequirementService.js +0 -24
- package/dist/core/installers/clients/BaseClientInstaller.d.ts +26 -3
- package/dist/core/installers/clients/BaseClientInstaller.js +121 -0
- package/dist/core/installers/clients/ClientInstaller.d.ts +1 -1
- package/dist/core/installers/clients/ClientInstaller.js +1 -1
- package/dist/core/installers/clients/ClientInstallerFactory.js +1 -1
- package/dist/core/installers/clients/ClineInstaller.d.ts +1 -6
- package/dist/core/installers/clients/ClineInstaller.js +1 -94
- package/dist/core/installers/clients/ExtensionInstaller.js +1 -1
- package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +1 -6
- package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -94
- package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +1 -5
- package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -94
- package/dist/core/installers/requirements/BaseInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/BaseInstaller.js +1 -1
- package/dist/core/installers/requirements/CommandInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/CommandInstaller.js +1 -1
- package/dist/core/installers/requirements/GeneralInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/InstallerFactory.d.ts +1 -1
- package/dist/core/installers/requirements/NpmInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/NpmInstaller.js +1 -1
- package/dist/core/installers/requirements/PipInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/RequirementInstaller.d.ts +1 -1
- package/dist/core/loaders/ConfigurationLoader.d.ts +35 -0
- package/dist/core/loaders/ConfigurationLoader.js +257 -0
- package/dist/core/loaders/ConfigurationProvider.d.ts +38 -0
- package/dist/core/loaders/ConfigurationProvider.js +384 -0
- package/dist/core/loaders/ServerSchemaLoader.d.ts +22 -0
- package/dist/core/loaders/ServerSchemaLoader.js +109 -0
- package/dist/core/loaders/ServerSchemaProvider.d.ts +14 -0
- package/dist/core/loaders/ServerSchemaProvider.js +90 -0
- package/dist/core/metadatas/constants.d.ts +47 -0
- package/dist/core/metadatas/constants.js +94 -0
- package/dist/core/metadatas/types.d.ts +167 -0
- package/dist/core/metadatas/types.js +16 -0
- package/dist/core/onboard/FeedOnboardService.d.ts +15 -8
- package/dist/core/onboard/FeedOnboardService.js +215 -130
- package/dist/core/onboard/OnboardProcessor.d.ts +8 -2
- package/dist/core/onboard/OnboardProcessor.js +53 -9
- package/dist/core/onboard/OnboardStatus.d.ts +7 -2
- package/dist/core/onboard/OnboardStatusManager.d.ts +71 -25
- package/dist/core/onboard/OnboardStatusManager.js +231 -47
- package/dist/core/validators/FeedValidator.d.ts +8 -3
- package/dist/core/validators/FeedValidator.js +61 -7
- package/dist/core/validators/IServerValidator.d.ts +1 -1
- package/dist/core/validators/SSEServerValidator.d.ts +1 -1
- package/dist/core/validators/ServerValidatorFactory.d.ts +1 -1
- package/dist/core/validators/StdioServerValidator.d.ts +1 -1
- package/dist/core/validators/StdioServerValidator.js +85 -33
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/services/InstallationService.d.ts +50 -0
- package/dist/services/InstallationService.js +350 -0
- package/dist/services/MCPManager.d.ts +29 -0
- package/dist/services/MCPManager.js +192 -0
- package/dist/services/RequirementService.d.ts +40 -0
- package/dist/services/RequirementService.js +110 -0
- package/dist/services/ServerService.d.ts +2 -2
- package/dist/services/ServerService.js +6 -6
- package/dist/utils/adoUtils.d.ts +2 -2
- package/dist/utils/adoUtils.js +1 -1
- package/dist/utils/feedUtils.js +1 -1
- package/dist/utils/githubUtils.d.ts +1 -1
- package/dist/utils/githubUtils.js +1 -1
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +11 -1
- package/dist/utils/macroExpressionUtils.d.ts +1 -1
- package/dist/utils/osUtils.d.ts +1 -1
- package/dist/utils/osUtils.js +1 -1
- package/dist/web/contract/serverContract.d.ts +1 -1
- package/dist/web/public/index.html +1 -3
- package/dist/web/public/js/api.js +2 -80
- package/dist/web/public/js/modal/installation.js +1 -1
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
- package/dist/web/public/js/onboard/formProcessor.js +200 -34
- package/dist/web/public/js/onboard/index.js +2 -2
- package/dist/web/public/js/onboard/publishHandler.js +30 -22
- package/dist/web/public/js/onboard/templates.js +34 -40
- package/dist/web/public/js/onboard/uiHandlers.js +175 -84
- package/dist/web/public/js/onboard/validationHandlers.js +147 -64
- package/dist/web/public/js/serverCategoryDetails.js +19 -4
- package/dist/web/public/js/serverCategoryList.js +13 -1
- package/dist/web/public/onboard.html +1 -1
- package/dist/web/server.js +21 -8
- package/package.json +1 -1
- package/src/cli/commands/install.ts +3 -3
- package/src/cli/commands/list.ts +2 -2
- package/src/cli/commands/serve.ts +3 -2
- package/src/cli/index.ts +1 -1
- package/src/core/installers/clients/BaseClientInstaller.ts +134 -3
- package/src/core/installers/clients/ClientInstaller.ts +3 -3
- package/src/core/installers/clients/ClientInstallerFactory.ts +1 -1
- package/src/core/installers/clients/ClineInstaller.ts +1 -101
- package/src/core/installers/clients/ExtensionInstaller.ts +1 -1
- package/src/core/installers/clients/GithubCopilotInstaller.ts +1 -101
- package/src/core/installers/clients/MSRooCodeInstaller.ts +1 -102
- package/src/core/installers/requirements/BaseInstaller.ts +2 -2
- package/src/core/installers/requirements/CommandInstaller.ts +1 -1
- package/src/core/installers/requirements/GeneralInstaller.ts +1 -1
- package/src/core/installers/requirements/InstallerFactory.ts +1 -1
- package/src/core/installers/requirements/NpmInstaller.ts +12 -12
- package/src/core/installers/requirements/PipInstaller.ts +1 -1
- package/src/core/installers/requirements/RequirementInstaller.ts +1 -1
- package/src/core/{ConfigurationLoader.ts → loaders/ConfigurationLoader.ts} +31 -7
- package/src/core/{ConfigurationProvider.ts → loaders/ConfigurationProvider.ts} +18 -10
- package/src/core/loaders/ServerSchemaLoader.ts +117 -0
- package/src/core/loaders/ServerSchemaProvider.ts +99 -0
- package/src/core/{types.ts → metadatas/types.ts} +3 -2
- package/src/core/onboard/FeedOnboardService.ts +270 -146
- package/src/core/onboard/OnboardProcessor.ts +60 -11
- package/src/core/onboard/OnboardStatus.ts +7 -2
- package/src/core/onboard/OnboardStatusManager.ts +270 -43
- package/src/core/validators/FeedValidator.ts +65 -9
- package/src/core/validators/IServerValidator.ts +1 -1
- package/src/core/validators/SSEServerValidator.ts +2 -2
- package/src/core/validators/ServerValidatorFactory.ts +1 -1
- package/src/core/validators/StdioServerValidator.ts +86 -34
- package/src/index.ts +3 -3
- package/src/{core → services}/InstallationService.ts +5 -5
- package/src/{core → services}/MCPManager.ts +10 -5
- package/src/{core → services}/RequirementService.ts +2 -31
- package/src/services/ServerService.ts +7 -7
- package/src/utils/adoUtils.ts +3 -3
- package/src/utils/feedUtils.ts +2 -2
- package/src/utils/githubUtils.ts +2 -2
- package/src/utils/logger.ts +13 -1
- package/src/utils/macroExpressionUtils.ts +1 -1
- package/src/utils/osUtils.ts +4 -4
- package/src/web/contract/serverContract.ts +2 -2
- package/src/web/public/index.html +1 -3
- package/src/web/public/js/api.js +2 -80
- package/src/web/public/js/modal/installation.js +1 -1
- package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
- package/src/web/public/js/onboard/formProcessor.js +200 -34
- package/src/web/public/js/onboard/index.js +2 -2
- package/src/web/public/js/onboard/publishHandler.js +30 -22
- package/src/web/public/js/onboard/templates.js +34 -40
- package/src/web/public/js/onboard/uiHandlers.js +175 -84
- package/src/web/public/js/onboard/validationHandlers.js +147 -64
- package/src/web/public/js/serverCategoryDetails.js +19 -4
- package/src/web/public/js/serverCategoryList.js +13 -1
- package/src/web/public/onboard.html +1 -1
- package/src/web/server.ts +30 -14
- package/src/core/ServerSchemaLoader.ts +0 -48
- package/src/core/ServerSchemaProvider.ts +0 -137
- package/src/services/InstallRequestValidator.ts +0 -112
- /package/src/core/{constants.ts → metadatas/constants.ts} +0 -0
|
@@ -1,103 +1,10 @@
|
|
|
1
1
|
import { BaseClientInstaller } from './BaseClientInstaller.js';
|
|
2
|
-
import { Logger } from '../../../utils/logger.js';
|
|
3
2
|
import { readJsonFile, writeJsonFile } from '../../../utils/clientUtils.js';
|
|
4
|
-
import { ExtensionInstaller } from './ExtensionInstaller.js';
|
|
5
|
-
import { SUPPORTED_CLIENTS } from '../../constants.js';
|
|
6
|
-
import { isCommandAvailable } from '../../../utils/osUtils.js';
|
|
7
3
|
/**
|
|
8
4
|
* MSRooCode client installer implementation
|
|
9
5
|
*/
|
|
10
6
|
export class MSRooCodeInstaller extends BaseClientInstaller {
|
|
11
|
-
|
|
12
|
-
* Install MSRooCode client
|
|
13
|
-
*/
|
|
14
|
-
async install(serverConfig, options) {
|
|
15
|
-
const operationId = this.generateOperationId();
|
|
16
|
-
try {
|
|
17
|
-
// Check if VS Code or VS Code Insiders is installed
|
|
18
|
-
const isVSCodeInstalled = await isCommandAvailable('code');
|
|
19
|
-
const isVSCodeInsidersInstalled = await isCommandAvailable('code-insiders');
|
|
20
|
-
if (!isVSCodeInstalled && !isVSCodeInsidersInstalled) {
|
|
21
|
-
return {
|
|
22
|
-
status: 'failed',
|
|
23
|
-
type: 'install',
|
|
24
|
-
target: 'server',
|
|
25
|
-
message: 'Neither VS Code nor VS Code Insiders are installed on this system',
|
|
26
|
-
operationId
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
// Install extension
|
|
30
|
-
const extensionResult = await ExtensionInstaller.installExtension('MSRooCode');
|
|
31
|
-
if (!extensionResult) {
|
|
32
|
-
Logger.debug('Failed to install MSRooCode extension');
|
|
33
|
-
return {
|
|
34
|
-
status: 'failed',
|
|
35
|
-
type: 'install',
|
|
36
|
-
target: 'server',
|
|
37
|
-
message: 'Failed to install MSRooCode extension',
|
|
38
|
-
operationId
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const installConfig = await this.setupInstallConfig(serverConfig, options);
|
|
42
|
-
installConfig.mode = serverConfig.mode;
|
|
43
|
-
// Track success for both VS Code variants
|
|
44
|
-
const results = [];
|
|
45
|
-
// Update settings for VS Code if installed
|
|
46
|
-
if (isVSCodeInstalled) {
|
|
47
|
-
try {
|
|
48
|
-
const settingPath = SUPPORTED_CLIENTS['MSRooCode'].codeSettingPath;
|
|
49
|
-
await this.setupClientSettings(settingPath, serverConfig.name, installConfig);
|
|
50
|
-
results.push({ success: true, path: settingPath });
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
results.push({
|
|
54
|
-
success: false,
|
|
55
|
-
path: SUPPORTED_CLIENTS['MSRooCode'].codeSettingPath,
|
|
56
|
-
error: error instanceof Error ? error.message : String(error)
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Update settings for VS Code Insiders if installed
|
|
61
|
-
if (isVSCodeInsidersInstalled) {
|
|
62
|
-
try {
|
|
63
|
-
const settingPath = SUPPORTED_CLIENTS['MSRooCode'].codeInsiderSettingPath;
|
|
64
|
-
await this.setupClientSettings(settingPath, serverConfig.name, installConfig);
|
|
65
|
-
results.push({ success: true, path: settingPath });
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
results.push({
|
|
69
|
-
success: false,
|
|
70
|
-
path: SUPPORTED_CLIENTS['MSRooCode'].codeInsiderSettingPath,
|
|
71
|
-
error: error instanceof Error ? error.message : String(error)
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// Determine overall success
|
|
76
|
-
const anySuccess = results.some(r => r.success);
|
|
77
|
-
const successPaths = results.filter(r => r.success).map(r => r.path);
|
|
78
|
-
const errors = results.filter(r => !r.success).map(r => r.error);
|
|
79
|
-
return {
|
|
80
|
-
status: anySuccess ? 'completed' : 'failed',
|
|
81
|
-
type: 'install',
|
|
82
|
-
target: 'server',
|
|
83
|
-
message: anySuccess
|
|
84
|
-
? `Successfully installed MSRooCode client. Updated settings in: ${successPaths.join(', ')}`
|
|
85
|
-
: `Failed to install MSRooCode client. Errors: ${errors.join('; ')}`,
|
|
86
|
-
operationId,
|
|
87
|
-
error: anySuccess ? undefined : errors.join('; ')
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
return {
|
|
92
|
-
status: 'failed',
|
|
93
|
-
type: 'install',
|
|
94
|
-
target: 'server',
|
|
95
|
-
message: `Unexpected error installing MSRooCode client: ${error instanceof Error ? error.message : String(error)}`,
|
|
96
|
-
operationId,
|
|
97
|
-
error: error instanceof Error ? error.message : String(error)
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
7
|
+
clientName = 'MSRooCode';
|
|
101
8
|
/**
|
|
102
9
|
* Set up MSRooCode client settings
|
|
103
10
|
*/
|
|
@@ -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,35 @@
|
|
|
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, settings?: {
|
|
28
|
+
prLink?: string;
|
|
29
|
+
adhocServers?: string[];
|
|
30
|
+
}): Promise<MCPConfiguration>;
|
|
31
|
+
/**
|
|
32
|
+
* Loads MCP client settings into the configuration
|
|
33
|
+
*/
|
|
34
|
+
static loadClientMCPSettings(configuration: MCPConfiguration): Promise<MCPConfiguration>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
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, settings) {
|
|
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
|
+
let config = JSON.parse(content);
|
|
152
|
+
if (config && config.name) {
|
|
153
|
+
// Update systemTags if feedFile is provided
|
|
154
|
+
if (!config.systemTags) {
|
|
155
|
+
config.systemTags = {};
|
|
156
|
+
}
|
|
157
|
+
config.systemTags['adhoc'] = 'true';
|
|
158
|
+
// Update PullRequest if prLink is provided in settings
|
|
159
|
+
if (settings?.prLink) {
|
|
160
|
+
config.PullRequest = settings.prLink;
|
|
161
|
+
}
|
|
162
|
+
// Update mcpServers systemTags if adhocServers are provided in settings
|
|
163
|
+
if (settings?.adhocServers && settings.adhocServers.length > 0 && config.mcpServers) {
|
|
164
|
+
config.mcpServers = config.mcpServers.map(server => {
|
|
165
|
+
if (settings.adhocServers.includes(server.name)) {
|
|
166
|
+
if (!server.systemTags) {
|
|
167
|
+
server.systemTags = {};
|
|
168
|
+
}
|
|
169
|
+
server.systemTags['adhoc'] = 'true';
|
|
170
|
+
}
|
|
171
|
+
return server;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
feeds[config.name] = config;
|
|
175
|
+
console.log(`Loaded and processed feed configuration from provided file: ${feedFile}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
console.log(`Error loading feed configuration from provided file ${feedFile}:`, error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Load feeds from LOCAL_FEEDS_DIR
|
|
183
|
+
const files = await fs.readdir(LOCAL_FEEDS_DIR);
|
|
184
|
+
const jsonFiles = files.filter(file => file.endsWith('.json'));
|
|
185
|
+
if (jsonFiles.length === 0 && !feedFile) {
|
|
186
|
+
console.log(`No feed configuration files found in ${LOCAL_FEEDS_DIR}`);
|
|
187
|
+
return configuration;
|
|
188
|
+
}
|
|
189
|
+
for (const file of jsonFiles) {
|
|
190
|
+
try {
|
|
191
|
+
const filePath = path.join(LOCAL_FEEDS_DIR, file);
|
|
192
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
193
|
+
const config = JSON.parse(content);
|
|
194
|
+
if (config && config.name) {
|
|
195
|
+
// If feed exists from provided file, skip the local one
|
|
196
|
+
if (!feeds[config.name]) {
|
|
197
|
+
feeds[config.name] = config;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
console.log(`Skipping local feed ${config.name} as it was provided via --feed-file`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
console.warn(`Error loading feed configuration from ${file}:`, error);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
configuration.feeds = feeds;
|
|
209
|
+
return await ConfigurationLoader.syncServerCategoriesWithFeeds(configuration);
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
console.error("Error loading feed configurations:", error);
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Loads MCP client settings into the configuration
|
|
218
|
+
*/
|
|
219
|
+
static async loadClientMCPSettings(configuration) {
|
|
220
|
+
try {
|
|
221
|
+
Logger.debug('Starting to load MCP client settings...');
|
|
222
|
+
const settings = {};
|
|
223
|
+
for (const [clientName, clientSettings] of Object.entries(SUPPORTED_CLIENTS)) {
|
|
224
|
+
const settingPath = process.env.CODE_INSIDERS
|
|
225
|
+
? clientSettings.codeInsiderSettingPath
|
|
226
|
+
: clientSettings.codeSettingPath;
|
|
227
|
+
try {
|
|
228
|
+
let content = await readJsonFile(settingPath, true);
|
|
229
|
+
if (clientName === 'GithubCopilot') {
|
|
230
|
+
if (!content.mcp) {
|
|
231
|
+
content = {
|
|
232
|
+
servers: {},
|
|
233
|
+
inputs: []
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
content = content.mcp;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
settings[clientName] = content;
|
|
241
|
+
Logger.debug(`Successfully loaded MCP settings for ${clientName}`);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
Logger.debug(`Warning: Could not load MCP settings for client ${clientName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
245
|
+
settings[clientName] = {};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
configuration.clientMCPSettings = settings;
|
|
249
|
+
return ConfigurationLoader.syncServerCategoriesWithClientSettings(configuration);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
Logger.error('Error loading client MCP settings:', error);
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=ConfigurationLoader.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MCPServerCategory, FeedConfiguration, InstallationStatus, RequirementStatus, MCPServerStatus, OperationStatus, McpConfig } from '../metadatas/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, settings?: {
|
|
12
|
+
prLink?: string;
|
|
13
|
+
adhocServers?: string[];
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
private saveConfiguration;
|
|
16
|
+
getServerCategories(): Promise<MCPServerCategory[]>;
|
|
17
|
+
getServerCategory(categoryName: string): Promise<MCPServerCategory | undefined>;
|
|
18
|
+
getClientMcpSettings(): Promise<Record<string, Record<string, any>> | undefined>;
|
|
19
|
+
getFeedConfiguration(categoryName: string): Promise<FeedConfiguration | undefined>;
|
|
20
|
+
getServerMcpConfig(categoryName: string, serverName: string): Promise<McpConfig | undefined>;
|
|
21
|
+
getInstallationStatus(categoryName: string): Promise<InstallationStatus | undefined>;
|
|
22
|
+
getServerStatus(categoryName: string, serverName: string): Promise<MCPServerStatus | undefined>;
|
|
23
|
+
getRequirementStatus(categoryName: string, requirementName: string): Promise<RequirementStatus | undefined>;
|
|
24
|
+
updateInstallationStatus(categoryName: string, requirementStatus: Record<string, RequirementStatus>, serverStatus: Record<string, MCPServerStatus>): Promise<boolean>;
|
|
25
|
+
updateRequirementStatus(categoryName: string, requirementName: string, status: RequirementStatus): Promise<boolean>;
|
|
26
|
+
updateRequirementOperationStatus(categoryName: string, requirementName: string, operationStatus: OperationStatus): Promise<boolean>;
|
|
27
|
+
updateServerStatus(categoryName: string, serverName: string, status: MCPServerStatus): Promise<boolean>;
|
|
28
|
+
updateServerOperationStatus(categoryName: string, serverName: string, clientName: string, operationStatus: OperationStatus): Promise<boolean>;
|
|
29
|
+
isRequirementsReady(categoryName: string, serverName: string): Promise<boolean>;
|
|
30
|
+
GetServerRequirementStatus(categoryName: string, serverName: string): Promise<RequirementStatus[]>;
|
|
31
|
+
isServerReady(categoryName: string, serverName: string, clients: string[]): Promise<boolean>;
|
|
32
|
+
syncFeeds(): Promise<void>;
|
|
33
|
+
private loadFeedsIntoConfiguration;
|
|
34
|
+
private loadClientMCPSettings;
|
|
35
|
+
reloadClientMCPSettings(): Promise<void>;
|
|
36
|
+
removeServerFromClientMCPSettings(serverName: string, target?: string): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare const configProvider: ConfigurationProvider;
|