imcp 0.1.4 → 0.1.6

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 (57) hide show
  1. package/.github/workflows/build.yml +28 -0
  2. package/README.md +21 -4
  3. package/dist/cli/commands/start.d.ts +2 -0
  4. package/dist/cli/commands/start.js +32 -0
  5. package/dist/cli/commands/sync.d.ts +2 -0
  6. package/dist/cli/commands/sync.js +17 -0
  7. package/dist/cli/index.js +0 -0
  8. package/dist/core/ConfigurationLoader.d.ts +32 -0
  9. package/dist/core/ConfigurationLoader.js +236 -0
  10. package/dist/core/ConfigurationProvider.d.ts +35 -0
  11. package/dist/core/ConfigurationProvider.js +375 -0
  12. package/dist/core/InstallationService.d.ts +50 -0
  13. package/dist/core/InstallationService.js +350 -0
  14. package/dist/core/MCPManager.d.ts +28 -0
  15. package/dist/core/MCPManager.js +188 -0
  16. package/dist/core/RequirementService.d.ts +40 -0
  17. package/dist/core/RequirementService.js +110 -0
  18. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  19. package/dist/core/ServerSchemaLoader.js +43 -0
  20. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  21. package/dist/core/ServerSchemaProvider.js +120 -0
  22. package/dist/core/constants.d.ts +47 -0
  23. package/dist/core/constants.js +94 -0
  24. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  25. package/dist/core/installers/BaseInstaller.js +253 -0
  26. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  27. package/dist/core/installers/ClientInstaller.js +564 -0
  28. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  29. package/dist/core/installers/CommandInstaller.js +173 -0
  30. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  31. package/dist/core/installers/GeneralInstaller.js +85 -0
  32. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  33. package/dist/core/installers/InstallerFactory.js +97 -0
  34. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  35. package/dist/core/installers/NpmInstaller.js +127 -0
  36. package/dist/core/installers/PipInstaller.d.ts +28 -0
  37. package/dist/core/installers/PipInstaller.js +127 -0
  38. package/dist/core/installers/RequirementInstaller.d.ts +33 -0
  39. package/dist/core/installers/RequirementInstaller.js +3 -0
  40. package/dist/core/types.d.ts +166 -0
  41. package/dist/core/types.js +16 -0
  42. package/dist/services/InstallRequestValidator.d.ts +21 -0
  43. package/dist/services/InstallRequestValidator.js +99 -0
  44. package/dist/web/public/index.html +1 -1
  45. package/dist/web/public/js/modal/installHandler.js +227 -0
  46. package/dist/web/public/js/modal/loadingUI.js +74 -0
  47. package/dist/web/public/js/modal/messageQueue.js +101 -45
  48. package/dist/web/public/js/modal/modalUI.js +214 -0
  49. package/dist/web/public/js/modal/version.js +20 -0
  50. package/dist/web/public/onboard.html +4 -4
  51. package/package.json +1 -1
  52. package/src/web/public/index.html +1 -1
  53. package/src/web/public/onboard.html +4 -4
  54. package/wiki/Installation.md +3 -0
  55. package/wiki/Publish.md +3 -0
  56. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  57. package/dist/core/onboard/InstallOperationManager.js +0 -144
@@ -0,0 +1,127 @@
1
+ import { BaseInstaller } from './BaseInstaller.js';
2
+ /**
3
+ * Installer implementation for Python packages using pip
4
+ */
5
+ export class PipInstaller extends BaseInstaller {
6
+ getPythonCommand(options) {
7
+ return options?.settings?.pythonEnv || 'python';
8
+ }
9
+ getPipCommand(options) {
10
+ const pythonCmd = this.getPythonCommand(options);
11
+ return `${pythonCmd} -m pip`;
12
+ }
13
+ /**
14
+ * Check if this installer can handle the given requirement type
15
+ * @param requirement The requirement to check
16
+ * @returns True if this installer can handle the requirement
17
+ */
18
+ canHandle(requirement) {
19
+ return requirement.type === 'pip';
20
+ }
21
+ supportCheckUpdates() {
22
+ /// temporarily disabling update check for pip as not able to get which pip of python is being used
23
+ return false;
24
+ }
25
+ /**
26
+ * Check if the Python package is already installed
27
+ * @param requirement The requirement to check
28
+ * @returns The status of the requirement
29
+ */
30
+ async checkInstallation(requirement, options) {
31
+ try {
32
+ const pipCmd = this.getPipCommand(options);
33
+ const { stdout, stderr } = await this.execPromise(`${pipCmd} show ${requirement.name}`);
34
+ // If we get an output and no error, the package is installed
35
+ const installed = stdout.includes(requirement.name);
36
+ const versionMatch = stdout.match(/Version: (.+)/);
37
+ const installedVersion = versionMatch ? versionMatch[1] : undefined;
38
+ return {
39
+ name: requirement.name,
40
+ type: 'pip',
41
+ installed,
42
+ version: installedVersion,
43
+ inProgress: false
44
+ };
45
+ }
46
+ catch (error) {
47
+ return {
48
+ name: requirement.name,
49
+ type: 'pip',
50
+ installed: false,
51
+ error: error instanceof Error ? error.message : String(error),
52
+ inProgress: false
53
+ };
54
+ }
55
+ }
56
+ /**
57
+ * Install the Python package
58
+ * @param requirement The requirement to install
59
+ * @returns The status of the installation
60
+ */
61
+ async install(requirement, options) {
62
+ try {
63
+ const status = await this.checkInstallation(requirement, options);
64
+ if (status.installed) {
65
+ return status;
66
+ }
67
+ const pipCmd = this.getPipCommand(options);
68
+ // If no registry is specified, use standard pip installation
69
+ if (!requirement.registry) {
70
+ // Standard pip installation
71
+ const { stderr } = await this.execPromise(`${pipCmd} install ${requirement.name}==${requirement.version}`);
72
+ if (stderr && stderr.toLowerCase().includes('error')) {
73
+ throw new Error(stderr);
74
+ }
75
+ }
76
+ else {
77
+ // Handle different registry types
78
+ let packageSource;
79
+ if (requirement.registry.githubRelease) {
80
+ const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
81
+ packageSource = result.resolvedPath;
82
+ // Install from the downloaded wheel or tar.gz file
83
+ const { stderr } = await this.execPromise(`${pipCmd} install "${packageSource}"`);
84
+ if (stderr && stderr.toLowerCase().includes('error')) {
85
+ throw new Error(stderr);
86
+ }
87
+ }
88
+ else if (requirement.registry.artifacts) {
89
+ const registryUrl = requirement.registry.artifacts.registryUrl;
90
+ // Install using the custom index URL
91
+ const { stderr } = await this.execPromise(`${pipCmd} install ${requirement.name}==${requirement.version} --index-url ${registryUrl}`);
92
+ if (stderr && stderr.toLowerCase().includes('error')) {
93
+ throw new Error(stderr);
94
+ }
95
+ }
96
+ else if (requirement.registry.local) {
97
+ packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
98
+ // Install from the local path
99
+ const { stderr } = await this.execPromise(`${pipCmd} install "${packageSource}"`);
100
+ if (stderr && stderr.toLowerCase().includes('error')) {
101
+ throw new Error(stderr);
102
+ }
103
+ }
104
+ else {
105
+ throw new Error('Invalid registry configuration');
106
+ }
107
+ }
108
+ return {
109
+ name: requirement.name,
110
+ type: 'pip',
111
+ installed: true,
112
+ version: requirement.version,
113
+ inProgress: false
114
+ };
115
+ }
116
+ catch (error) {
117
+ return {
118
+ name: requirement.name,
119
+ type: 'pip',
120
+ installed: false,
121
+ error: error instanceof Error ? error.message : String(error),
122
+ inProgress: false
123
+ };
124
+ }
125
+ }
126
+ }
127
+ //# sourceMappingURL=PipInstaller.js.map
@@ -0,0 +1,33 @@
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../types.js';
2
+ /**
3
+ * Interface for requirement installers.
4
+ * Implementations should handle specific requirement types.
5
+ */
6
+ export interface RequirementInstaller {
7
+ /**
8
+ * Check if this installer can handle the given requirement type
9
+ * @param requirement The requirement to check
10
+ * @returns True if this installer can handle the requirement
11
+ */
12
+ canHandle(requirement: RequirementConfig): boolean;
13
+ supportCheckUpdates(): boolean;
14
+ /**
15
+ * Install the requirement
16
+ * @param requirement The requirement to install
17
+ * @returns The status of the installation
18
+ */
19
+ install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
20
+ /**
21
+ * Check if the requirement is already installed
22
+ * @param requirement The requirement to check
23
+ * @returns The status of the requirement
24
+ */
25
+ checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
26
+ /**
27
+ * Check if updates are available for the requirement
28
+ * @param requirement The requirement to check
29
+ * @param currentStatus The current status of the requirement
30
+ * @returns The status of the requirement with update information
31
+ */
32
+ checkForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus): Promise<RequirementStatus>;
33
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+ // Note: Do not re-export implementations from here to avoid circular dependencies
3
+ //# sourceMappingURL=RequirementInstaller.js.map
@@ -0,0 +1,166 @@
1
+ export declare enum OSType {
2
+ Windows = "windows",
3
+ MacOS = "macos",
4
+ Linux = "linux"
5
+ }
6
+ export interface RequirementStatus {
7
+ name: string;
8
+ type: string;
9
+ installed: boolean;
10
+ inProgress?: boolean;
11
+ version?: string;
12
+ error?: string;
13
+ availableUpdate?: {
14
+ version: string;
15
+ message: string;
16
+ };
17
+ lastCheckTime?: string;
18
+ operationStatus?: OperationStatus;
19
+ pythonEnv?: string;
20
+ npmPath?: string;
21
+ }
22
+ export interface MCPServerStatus {
23
+ installedStatus: Record<string, OperationStatus>;
24
+ name: string;
25
+ tags?: string[];
26
+ error?: string;
27
+ }
28
+ export interface OperationStatus {
29
+ status: 'pending' | 'in-progress' | 'completed' | 'failed';
30
+ type: 'install' | 'uninstall' | 'update' | 'check';
31
+ target: 'requirement' | 'server';
32
+ message?: string;
33
+ error?: string;
34
+ operationId?: string;
35
+ }
36
+ export interface InstallationStatus {
37
+ requirementsStatus: Record<string, RequirementStatus>;
38
+ serversStatus: Record<string, MCPServerStatus>;
39
+ lastUpdated: string;
40
+ }
41
+ export interface MCPServerCategory {
42
+ name: string;
43
+ displayName: string;
44
+ description?: string;
45
+ type: 'local';
46
+ tags?: string[];
47
+ path?: string;
48
+ installationStatus?: InstallationStatus;
49
+ feedConfiguration?: FeedConfiguration;
50
+ }
51
+ export interface ServerCategoryListOptions {
52
+ local?: boolean;
53
+ }
54
+ export interface ServerOperationResult {
55
+ success: boolean;
56
+ message?: string;
57
+ error?: Error;
58
+ output?: string;
59
+ status?: OperationStatus[];
60
+ }
61
+ export interface MCPConfiguration {
62
+ localServerCategories: MCPServerCategory[];
63
+ feeds: Record<string, FeedConfiguration>;
64
+ clientMCPSettings?: Record<string, Record<string, any>>;
65
+ }
66
+ export interface ServerInstallOptions {
67
+ force?: boolean;
68
+ env?: Record<string, string>;
69
+ targetClients?: string[];
70
+ requirements?: RequirementConfig[];
71
+ args?: string[];
72
+ settings?: Record<string, any>;
73
+ }
74
+ export interface UpdateRequirementOptions {
75
+ requirementName: string;
76
+ updateVersion: string;
77
+ }
78
+ export interface ServerUninstallOptions {
79
+ removeData?: boolean;
80
+ targets?: string[];
81
+ }
82
+ export interface EnvVariableConfig {
83
+ Required: boolean;
84
+ Description: string;
85
+ Default?: string;
86
+ }
87
+ export interface InstallationConfig {
88
+ command: string;
89
+ args: string[];
90
+ env?: Record<string, EnvVariableConfig>;
91
+ url?: string;
92
+ }
93
+ export interface DependencyConfig {
94
+ requirements?: Array<{
95
+ name: string;
96
+ version: string;
97
+ order?: number;
98
+ }>;
99
+ mcpServers?: Array<{
100
+ name: string;
101
+ }>;
102
+ }
103
+ export interface McpConfig {
104
+ name: string;
105
+ description: string;
106
+ mode: 'stdio' | 'sse';
107
+ dependencies?: DependencyConfig;
108
+ schemas?: string;
109
+ repository?: string;
110
+ installation: InstallationConfig;
111
+ }
112
+ export interface RegistryConfig {
113
+ githubRelease?: {
114
+ repository: string;
115
+ assetsName?: string;
116
+ assetName: string;
117
+ };
118
+ artifacts?: {
119
+ registryUrl: string;
120
+ registryName: string;
121
+ };
122
+ }
123
+ export interface RequirementConfig {
124
+ name: string;
125
+ type: 'npm' | 'pip' | 'command' | 'extension' | 'other';
126
+ alias?: string;
127
+ version: string;
128
+ registry?: RegistryConfig;
129
+ }
130
+ export interface FeedConfiguration {
131
+ name: string;
132
+ displayName: string;
133
+ description: string;
134
+ repository?: string;
135
+ requirements: RequirementConfig[];
136
+ mcpServers: McpConfig[];
137
+ }
138
+ export interface ClientSettings {
139
+ codeSettingPath: string;
140
+ codeInsiderSettingPath: string;
141
+ }
142
+ export declare enum MCPEvent {
143
+ SERVER_INSTALLED = "server:installed",
144
+ SERVER_UNINSTALLED = "server:uninstalled",
145
+ SERVER_STARTED = "server:started",
146
+ SERVER_STOPPED = "server:stopped",
147
+ CONFIG_CHANGED = "config:changed"
148
+ }
149
+ export interface MCPEventData {
150
+ [MCPEvent.SERVER_INSTALLED]: {
151
+ server: MCPServerCategory;
152
+ };
153
+ [MCPEvent.SERVER_UNINSTALLED]: {
154
+ serverName: string;
155
+ targets?: string[];
156
+ };
157
+ [MCPEvent.SERVER_STARTED]: {
158
+ server: MCPServerCategory;
159
+ };
160
+ [MCPEvent.SERVER_STOPPED]: {
161
+ serverName: string;
162
+ };
163
+ [MCPEvent.CONFIG_CHANGED]: {
164
+ configuration: MCPConfiguration;
165
+ };
166
+ }
@@ -0,0 +1,16 @@
1
+ export var OSType;
2
+ (function (OSType) {
3
+ OSType["Windows"] = "windows";
4
+ OSType["MacOS"] = "macos";
5
+ OSType["Linux"] = "linux";
6
+ })(OSType || (OSType = {}));
7
+ // Events that can be emitted by the SDK
8
+ export var MCPEvent;
9
+ (function (MCPEvent) {
10
+ MCPEvent["SERVER_INSTALLED"] = "server:installed";
11
+ MCPEvent["SERVER_UNINSTALLED"] = "server:uninstalled";
12
+ MCPEvent["SERVER_STARTED"] = "server:started";
13
+ MCPEvent["SERVER_STOPPED"] = "server:stopped";
14
+ MCPEvent["CONFIG_CHANGED"] = "config:changed";
15
+ })(MCPEvent || (MCPEvent = {}));
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,21 @@
1
+ import { ServerInstallOptions } from '../core/types.js';
2
+ import { InstallServersRequestBody } from '../web/contract/serverContract.js';
3
+ export declare class InstallRequestValidator {
4
+ private serverFeedConfigs;
5
+ private feedDirectory;
6
+ constructor(feedDirectory?: string);
7
+ private loadServerFeedConfiguration;
8
+ /**
9
+ * Validates the install request body for a specific server.
10
+ * @param serverName The name of the server to validate against.
11
+ * @param requestBody The installation request body.
12
+ * @returns An array of error messages, or an empty array if validation passes.
13
+ */
14
+ validate(serverName: string, requestBody: ServerInstallOptions): Promise<string[]>;
15
+ /**
16
+ * Validates the install request body for multiple servers.
17
+ * @param requestBody The installation request body containing multiple server names.
18
+ * @returns An object mapping server names to their validation errors. Empty arrays indicate success.
19
+ */
20
+ validateMultiple(requestBody: InstallServersRequestBody): Promise<Record<string, string[]>>;
21
+ }
@@ -0,0 +1,99 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { SUPPORTED_CLIENT_NAMES } from '../core/constants.js';
4
+ export class InstallRequestValidator {
5
+ serverFeedConfigs = new Map();
6
+ feedDirectory;
7
+ constructor(feedDirectory = path.join(__dirname, '../feeds')) {
8
+ this.feedDirectory = feedDirectory;
9
+ // Consider loading configs lazily or providing an explicit load method
10
+ // For now, let's assume pre-loading or loading on demand in validate
11
+ }
12
+ async loadServerFeedConfiguration(serverName) {
13
+ if (this.serverFeedConfigs.has(serverName)) {
14
+ return this.serverFeedConfigs.get(serverName);
15
+ }
16
+ const filePath = path.join(this.feedDirectory, `${serverName}.json`);
17
+ try {
18
+ const fileContent = await fs.readFile(filePath, 'utf-8');
19
+ const config = JSON.parse(fileContent);
20
+ // Basic validation of the loaded config structure could be added here
21
+ if (config && config.name === serverName) {
22
+ this.serverFeedConfigs.set(serverName, config);
23
+ return config;
24
+ }
25
+ console.error(`Configuration name mismatch in ${filePath}`);
26
+ return undefined;
27
+ }
28
+ catch (error) {
29
+ if (error.code === 'ENOENT') {
30
+ console.warn(`Server feed configuration not found for: ${serverName} at ${filePath}`);
31
+ }
32
+ else {
33
+ console.error(`Error loading server feed configuration for ${serverName}:`, error);
34
+ }
35
+ return undefined;
36
+ }
37
+ }
38
+ /**
39
+ * Validates the install request body for a specific server.
40
+ * @param serverName The name of the server to validate against.
41
+ * @param requestBody The installation request body.
42
+ * @returns An array of error messages, or an empty array if validation passes.
43
+ */
44
+ async validate(serverName, requestBody) {
45
+ const errors = [];
46
+ const config = await this.loadServerFeedConfiguration(serverName);
47
+ if (!config) {
48
+ errors.push(`Server configuration feed not found for '${serverName}'.`);
49
+ // Cannot perform further validation without the config
50
+ return errors;
51
+ }
52
+ // 1.2 Validate required environment variables
53
+ config.mcpServers.forEach(mcp => {
54
+ if (mcp.installation?.env) {
55
+ Object.entries(mcp.installation.env).forEach(([envVar, envConfig]) => {
56
+ if (envConfig.Required) {
57
+ if (!requestBody.env || !(envVar in requestBody.env) || !requestBody.env[envVar]) {
58
+ errors.push(`Missing required environment variable '${envVar}' for server '${serverName}' (category: ${mcp.name}).`);
59
+ }
60
+ }
61
+ });
62
+ }
63
+ });
64
+ // 1.3 Validate target clients
65
+ if (!requestBody.targetClients || requestBody.targetClients.length === 0) {
66
+ errors.push(`Request body must include a non-empty 'targetClients' array for server '${serverName}'.`);
67
+ }
68
+ else {
69
+ requestBody.targetClients.forEach((client) => {
70
+ if (!SUPPORTED_CLIENT_NAMES.includes(client)) {
71
+ errors.push(`Unsupported target client '${client}' specified for server '${serverName}'. Supported clients are: ${SUPPORTED_CLIENT_NAMES.join(', ')}.`);
72
+ }
73
+ });
74
+ }
75
+ // Add other validation rules as needed
76
+ return errors;
77
+ }
78
+ /**
79
+ * Validates the install request body for multiple servers.
80
+ * @param requestBody The installation request body containing multiple server names.
81
+ * @returns An object mapping server names to their validation errors. Empty arrays indicate success.
82
+ */
83
+ async validateMultiple(requestBody) {
84
+ const results = {};
85
+ if (!requestBody.serverList || Object.keys(requestBody.serverList).length === 0) {
86
+ return { '_global': ['Request body must include a non-empty \'serverCategoryList\' record.'] };
87
+ }
88
+ for (const serverName of Object.keys(requestBody.serverList)) {
89
+ results[serverName] = await this.validate(serverName, requestBody.serverList[serverName]);
90
+ }
91
+ return results;
92
+ }
93
+ }
94
+ // Helper __dirname for ES modules
95
+ import { fileURLToPath } from 'url';
96
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
97
+ // Export a singleton instance (optional, depends on usage pattern)
98
+ // export const installRequestValidator = new InstallRequestValidator();
99
+ //# sourceMappingURL=InstallRequestValidator.js.map
@@ -47,7 +47,7 @@
47
47
  <button id="onboardButton" style="display: none;"
48
48
  class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center">
49
49
  <i class='bx bx-plus-circle mr-2'></i>
50
- Onboard
50
+ Publish Server
51
51
  </button>
52
52
  </div>
53
53
  <script>