imcp 0.0.1

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 (124) hide show
  1. package/.github/ISSUE_TEMPLATE/JitAccess.yml +28 -0
  2. package/.github/acl/access.yml +20 -0
  3. package/.github/compliance/inventory.yml +5 -0
  4. package/.github/policies/jit.yml +19 -0
  5. package/README.md +137 -0
  6. package/dist/cli/commands/install.d.ts +2 -0
  7. package/dist/cli/commands/install.js +105 -0
  8. package/dist/cli/commands/list.d.ts +2 -0
  9. package/dist/cli/commands/list.js +90 -0
  10. package/dist/cli/commands/pull.d.ts +2 -0
  11. package/dist/cli/commands/pull.js +17 -0
  12. package/dist/cli/commands/serve.d.ts +2 -0
  13. package/dist/cli/commands/serve.js +32 -0
  14. package/dist/cli/commands/start.d.ts +2 -0
  15. package/dist/cli/commands/start.js +32 -0
  16. package/dist/cli/commands/sync.d.ts +2 -0
  17. package/dist/cli/commands/sync.js +17 -0
  18. package/dist/cli/commands/uninstall.d.ts +2 -0
  19. package/dist/cli/commands/uninstall.js +39 -0
  20. package/dist/cli/index.d.ts +2 -0
  21. package/dist/cli/index.js +114 -0
  22. package/dist/core/ConfigurationProvider.d.ts +31 -0
  23. package/dist/core/ConfigurationProvider.js +416 -0
  24. package/dist/core/InstallationService.d.ts +17 -0
  25. package/dist/core/InstallationService.js +144 -0
  26. package/dist/core/MCPManager.d.ts +17 -0
  27. package/dist/core/MCPManager.js +98 -0
  28. package/dist/core/RequirementService.d.ts +45 -0
  29. package/dist/core/RequirementService.js +123 -0
  30. package/dist/core/constants.d.ts +29 -0
  31. package/dist/core/constants.js +55 -0
  32. package/dist/core/installers/BaseInstaller.d.ts +73 -0
  33. package/dist/core/installers/BaseInstaller.js +247 -0
  34. package/dist/core/installers/ClientInstaller.d.ts +17 -0
  35. package/dist/core/installers/ClientInstaller.js +307 -0
  36. package/dist/core/installers/CommandInstaller.d.ts +36 -0
  37. package/dist/core/installers/CommandInstaller.js +170 -0
  38. package/dist/core/installers/GeneralInstaller.d.ts +32 -0
  39. package/dist/core/installers/GeneralInstaller.js +87 -0
  40. package/dist/core/installers/InstallerFactory.d.ts +52 -0
  41. package/dist/core/installers/InstallerFactory.js +95 -0
  42. package/dist/core/installers/NpmInstaller.d.ts +25 -0
  43. package/dist/core/installers/NpmInstaller.js +123 -0
  44. package/dist/core/installers/PipInstaller.d.ts +25 -0
  45. package/dist/core/installers/PipInstaller.js +114 -0
  46. package/dist/core/installers/RequirementInstaller.d.ts +32 -0
  47. package/dist/core/installers/RequirementInstaller.js +3 -0
  48. package/dist/core/installers/index.d.ts +6 -0
  49. package/dist/core/installers/index.js +7 -0
  50. package/dist/core/types.d.ts +152 -0
  51. package/dist/core/types.js +16 -0
  52. package/dist/index.d.ts +11 -0
  53. package/dist/index.js +19 -0
  54. package/dist/services/InstallRequestValidator.d.ts +21 -0
  55. package/dist/services/InstallRequestValidator.js +99 -0
  56. package/dist/services/ServerService.d.ts +47 -0
  57. package/dist/services/ServerService.js +145 -0
  58. package/dist/utils/UpdateCheckTracker.d.ts +39 -0
  59. package/dist/utils/UpdateCheckTracker.js +80 -0
  60. package/dist/utils/clientUtils.d.ts +29 -0
  61. package/dist/utils/clientUtils.js +105 -0
  62. package/dist/utils/feedUtils.d.ts +5 -0
  63. package/dist/utils/feedUtils.js +29 -0
  64. package/dist/utils/githubAuth.d.ts +1 -0
  65. package/dist/utils/githubAuth.js +123 -0
  66. package/dist/utils/logger.d.ts +14 -0
  67. package/dist/utils/logger.js +90 -0
  68. package/dist/utils/osUtils.d.ts +16 -0
  69. package/dist/utils/osUtils.js +235 -0
  70. package/dist/web/public/css/modal.css +250 -0
  71. package/dist/web/public/css/notifications.css +70 -0
  72. package/dist/web/public/index.html +157 -0
  73. package/dist/web/public/js/api.js +213 -0
  74. package/dist/web/public/js/modal.js +572 -0
  75. package/dist/web/public/js/notifications.js +99 -0
  76. package/dist/web/public/js/serverCategoryDetails.js +210 -0
  77. package/dist/web/public/js/serverCategoryList.js +82 -0
  78. package/dist/web/public/modal.html +61 -0
  79. package/dist/web/public/styles.css +155 -0
  80. package/dist/web/server.d.ts +5 -0
  81. package/dist/web/server.js +150 -0
  82. package/package.json +53 -0
  83. package/src/cli/commands/install.ts +140 -0
  84. package/src/cli/commands/list.ts +112 -0
  85. package/src/cli/commands/pull.ts +16 -0
  86. package/src/cli/commands/serve.ts +37 -0
  87. package/src/cli/commands/uninstall.ts +54 -0
  88. package/src/cli/index.ts +127 -0
  89. package/src/core/ConfigurationProvider.ts +489 -0
  90. package/src/core/InstallationService.ts +173 -0
  91. package/src/core/MCPManager.ts +134 -0
  92. package/src/core/RequirementService.ts +147 -0
  93. package/src/core/constants.ts +61 -0
  94. package/src/core/installers/BaseInstaller.ts +292 -0
  95. package/src/core/installers/ClientInstaller.ts +423 -0
  96. package/src/core/installers/CommandInstaller.ts +185 -0
  97. package/src/core/installers/GeneralInstaller.ts +89 -0
  98. package/src/core/installers/InstallerFactory.ts +109 -0
  99. package/src/core/installers/NpmInstaller.ts +128 -0
  100. package/src/core/installers/PipInstaller.ts +121 -0
  101. package/src/core/installers/RequirementInstaller.ts +38 -0
  102. package/src/core/installers/index.ts +9 -0
  103. package/src/core/types.ts +163 -0
  104. package/src/index.ts +44 -0
  105. package/src/services/InstallRequestValidator.ts +112 -0
  106. package/src/services/ServerService.ts +181 -0
  107. package/src/utils/UpdateCheckTracker.ts +86 -0
  108. package/src/utils/clientUtils.ts +112 -0
  109. package/src/utils/feedUtils.ts +31 -0
  110. package/src/utils/githubAuth.ts +142 -0
  111. package/src/utils/logger.ts +101 -0
  112. package/src/utils/osUtils.ts +250 -0
  113. package/src/web/public/css/modal.css +250 -0
  114. package/src/web/public/css/notifications.css +70 -0
  115. package/src/web/public/index.html +157 -0
  116. package/src/web/public/js/api.js +213 -0
  117. package/src/web/public/js/modal.js +572 -0
  118. package/src/web/public/js/notifications.js +99 -0
  119. package/src/web/public/js/serverCategoryDetails.js +210 -0
  120. package/src/web/public/js/serverCategoryList.js +82 -0
  121. package/src/web/public/modal.html +61 -0
  122. package/src/web/public/styles.css +155 -0
  123. package/src/web/server.ts +195 -0
  124. package/tsconfig.json +18 -0
@@ -0,0 +1,114 @@
1
+ import { BaseInstaller } from './BaseInstaller.js';
2
+ /**
3
+ * Installer implementation for Python packages using pip
4
+ */
5
+ export class PipInstaller extends BaseInstaller {
6
+ /**
7
+ * Check if this installer can handle the given requirement type
8
+ * @param requirement The requirement to check
9
+ * @returns True if this installer can handle the requirement
10
+ */
11
+ canHandle(requirement) {
12
+ return requirement.type === 'pip';
13
+ }
14
+ /**
15
+ * Check if the Python package is already installed
16
+ * @param requirement The requirement to check
17
+ * @returns The status of the requirement
18
+ */
19
+ async checkInstallation(requirement) {
20
+ try {
21
+ const { stdout, stderr } = await this.execPromise(`pip show ${requirement.name}`);
22
+ // If we get an output and no error, the package is installed
23
+ const installed = stdout.includes(requirement.name);
24
+ const versionMatch = stdout.match(/Version: (.+)/);
25
+ const installedVersion = versionMatch ? versionMatch[1] : undefined;
26
+ return {
27
+ name: requirement.name,
28
+ type: 'pip',
29
+ installed,
30
+ version: installedVersion,
31
+ inProgress: false
32
+ };
33
+ }
34
+ catch (error) {
35
+ return {
36
+ name: requirement.name,
37
+ type: 'pip',
38
+ installed: false,
39
+ error: error instanceof Error ? error.message : String(error),
40
+ inProgress: false
41
+ };
42
+ }
43
+ }
44
+ /**
45
+ * Install the Python package
46
+ * @param requirement The requirement to install
47
+ * @returns The status of the installation
48
+ */
49
+ async install(requirement) {
50
+ try {
51
+ const status = await this.checkInstallation(requirement);
52
+ if (status.installed) {
53
+ return status;
54
+ }
55
+ // If no registry is specified, use standard pip installation
56
+ if (!requirement.registry) {
57
+ // Standard pip installation
58
+ const { stderr } = await this.execPromise(`pip install ${requirement.name}==${requirement.version}`);
59
+ if (stderr && stderr.toLowerCase().includes('error')) {
60
+ throw new Error(stderr);
61
+ }
62
+ }
63
+ else {
64
+ // Handle different registry types
65
+ let packageSource;
66
+ if (requirement.registry.githubRelease) {
67
+ const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
68
+ packageSource = result.resolvedPath;
69
+ // Install from the downloaded wheel or tar.gz file
70
+ const { stderr } = await this.execPromise(`pip install "${packageSource}"`);
71
+ if (stderr && stderr.toLowerCase().includes('error')) {
72
+ throw new Error(stderr);
73
+ }
74
+ }
75
+ else if (requirement.registry.artifacts) {
76
+ const registryUrl = requirement.registry.artifacts.registryUrl;
77
+ // Install using the custom index URL
78
+ const { stderr } = await this.execPromise(`pip install ${requirement.name}==${requirement.version} --index-url ${registryUrl}`);
79
+ if (stderr && stderr.toLowerCase().includes('error')) {
80
+ throw new Error(stderr);
81
+ }
82
+ }
83
+ else if (requirement.registry.local) {
84
+ packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
85
+ // Install from the local path
86
+ const { stderr } = await this.execPromise(`pip install "${packageSource}"`);
87
+ if (stderr && stderr.toLowerCase().includes('error')) {
88
+ throw new Error(stderr);
89
+ }
90
+ }
91
+ else {
92
+ throw new Error('Invalid registry configuration');
93
+ }
94
+ }
95
+ return {
96
+ name: requirement.name,
97
+ type: 'pip',
98
+ installed: true,
99
+ version: requirement.version,
100
+ inProgress: false
101
+ };
102
+ }
103
+ catch (error) {
104
+ return {
105
+ name: requirement.name,
106
+ type: 'pip',
107
+ installed: false,
108
+ error: error instanceof Error ? error.message : String(error),
109
+ inProgress: false
110
+ };
111
+ }
112
+ }
113
+ }
114
+ //# sourceMappingURL=PipInstaller.js.map
@@ -0,0 +1,32 @@
1
+ import { RequirementConfig, RequirementStatus } 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
+ /**
14
+ * Install the requirement
15
+ * @param requirement The requirement to install
16
+ * @returns The status of the installation
17
+ */
18
+ install(requirement: RequirementConfig): Promise<RequirementStatus>;
19
+ /**
20
+ * Check if the requirement is already installed
21
+ * @param requirement The requirement to check
22
+ * @returns The status of the requirement
23
+ */
24
+ checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus>;
25
+ /**
26
+ * Check if updates are available for the requirement
27
+ * @param requirement The requirement to check
28
+ * @param currentStatus The current status of the requirement
29
+ * @returns The status of the requirement with update information
30
+ */
31
+ checkForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus): Promise<RequirementStatus>;
32
+ }
@@ -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,6 @@
1
+ export { RequirementInstaller } from './RequirementInstaller.js';
2
+ export { BaseInstaller } from './BaseInstaller.js';
3
+ export { NpmInstaller } from './NpmInstaller.js';
4
+ export { PipInstaller } from './PipInstaller.js';
5
+ export { GeneralInstaller } from './GeneralInstaller.js';
6
+ export { InstallerFactory, createInstallerFactory } from './InstallerFactory.js';
@@ -0,0 +1,7 @@
1
+ // Export all installer implementations
2
+ export { BaseInstaller } from './BaseInstaller.js';
3
+ export { NpmInstaller } from './NpmInstaller.js';
4
+ export { PipInstaller } from './PipInstaller.js';
5
+ export { GeneralInstaller } from './GeneralInstaller.js';
6
+ export { InstallerFactory, createInstallerFactory } from './InstallerFactory.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,152 @@
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
+ checkTime: string;
17
+ };
18
+ operationStatus?: OperationStatus;
19
+ updateInfo?: {
20
+ available: boolean;
21
+ latestVersion?: string;
22
+ [key: string]: any;
23
+ } | null;
24
+ }
25
+ export interface MCPServerStatus {
26
+ installedStatus: Record<string, OperationStatus>;
27
+ name: string;
28
+ error?: string;
29
+ }
30
+ export interface OperationStatus {
31
+ status: 'pending' | 'in-progress' | 'completed' | 'failed';
32
+ type: 'install' | 'uninstall' | 'update' | 'check';
33
+ target: 'requirement' | 'server';
34
+ message?: string;
35
+ error?: string;
36
+ operationId?: string;
37
+ }
38
+ export interface InstallationStatus {
39
+ requirementsStatus: Record<string, RequirementStatus>;
40
+ serversStatus: Record<string, MCPServerStatus>;
41
+ lastUpdated: string;
42
+ }
43
+ export interface MCPServerCategory {
44
+ name: string;
45
+ displayName: string;
46
+ description?: string;
47
+ type: 'local';
48
+ path?: string;
49
+ installationStatus?: InstallationStatus;
50
+ feedConfiguration?: FeedConfiguration;
51
+ }
52
+ export interface ServerCategoryListOptions {
53
+ local?: boolean;
54
+ }
55
+ export interface ServerOperationResult {
56
+ success: boolean;
57
+ message?: string;
58
+ error?: Error;
59
+ output?: string;
60
+ status?: OperationStatus[];
61
+ }
62
+ export interface MCPConfiguration {
63
+ localServerCategories: MCPServerCategory[];
64
+ feeds: Record<string, FeedConfiguration>;
65
+ }
66
+ export interface ServerInstallOptions {
67
+ force?: boolean;
68
+ env?: Record<string, string>;
69
+ targetClients?: string[];
70
+ }
71
+ export interface ServerUninstallOptions {
72
+ removeData?: boolean;
73
+ }
74
+ export interface EnvVariableConfig {
75
+ Required: boolean;
76
+ Description: string;
77
+ Default?: string;
78
+ }
79
+ export interface InstallationConfig {
80
+ command: string;
81
+ args: string[];
82
+ env?: Record<string, EnvVariableConfig>;
83
+ }
84
+ export interface DependencyConfig {
85
+ requirements?: Array<{
86
+ name: string;
87
+ version: string;
88
+ }>;
89
+ mcpServers?: Array<{
90
+ name: string;
91
+ }>;
92
+ }
93
+ export interface McpConfig {
94
+ name: string;
95
+ description: string;
96
+ mode: 'stdio' | 'http';
97
+ dependencies?: DependencyConfig;
98
+ installation: InstallationConfig;
99
+ }
100
+ export interface RegistryConfig {
101
+ githubRelease?: {
102
+ repository: string;
103
+ assetsName?: string;
104
+ assetName: string;
105
+ };
106
+ artifacts?: {
107
+ registryUrl: string;
108
+ assetName?: string;
109
+ };
110
+ local?: {
111
+ localPath: string;
112
+ assetName?: string;
113
+ };
114
+ }
115
+ export interface RequirementConfig {
116
+ name: string;
117
+ type: 'npm' | 'pip' | 'command' | 'other';
118
+ alias?: string;
119
+ version: string;
120
+ registry?: RegistryConfig;
121
+ }
122
+ export interface FeedConfiguration {
123
+ name: string;
124
+ displayName: string;
125
+ description: string;
126
+ requirements: RequirementConfig[];
127
+ mcpServers: McpConfig[];
128
+ }
129
+ export declare enum MCPEvent {
130
+ SERVER_INSTALLED = "server:installed",
131
+ SERVER_UNINSTALLED = "server:uninstalled",
132
+ SERVER_STARTED = "server:started",
133
+ SERVER_STOPPED = "server:stopped",
134
+ CONFIG_CHANGED = "config:changed"
135
+ }
136
+ export interface MCPEventData {
137
+ [MCPEvent.SERVER_INSTALLED]: {
138
+ server: MCPServerCategory;
139
+ };
140
+ [MCPEvent.SERVER_UNINSTALLED]: {
141
+ serverName: string;
142
+ };
143
+ [MCPEvent.SERVER_STARTED]: {
144
+ server: MCPServerCategory;
145
+ };
146
+ [MCPEvent.SERVER_STOPPED]: {
147
+ serverName: string;
148
+ };
149
+ [MCPEvent.CONFIG_CHANGED]: {
150
+ configuration: MCPConfiguration;
151
+ };
152
+ }
@@ -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,11 @@
1
+ export { MCPServerCategory, ServerCategoryListOptions, ServerInstallOptions, ServerUninstallOptions, ServerOperationResult, MCPConfiguration, MCPEvent, MCPEventData, RequirementConfig, RequirementStatus, RegistryConfig } from './core/types.js';
2
+ export { MCPManager, mcpManager } from './core/MCPManager.js';
3
+ export { ServerService, serverService } from './services/ServerService.js';
4
+ export { RequirementService, requirementService } from './core/RequirementService.js';
5
+ export { RequirementInstaller, BaseInstaller, NpmInstaller, PipInstaller, GeneralInstaller, InstallerFactory, createInstallerFactory } from './core/installers/index.js';
6
+ export { startWebServer } from './web/server.js';
7
+ export declare const VERSION = "0.0.1";
8
+ export declare const DEFAULT_CONFIG: {
9
+ readonly configPath: "./config/servers.json";
10
+ readonly webPort: 3000;
11
+ };
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ // Public types
2
+ export { MCPEvent } from './core/types.js';
3
+ // Core functionality
4
+ export { MCPManager, mcpManager } from './core/MCPManager.js';
5
+ // Services
6
+ export { ServerService, serverService } from './services/ServerService.js';
7
+ export { RequirementService, requirementService } from './core/RequirementService.js';
8
+ // Installer interfaces and implementations
9
+ export { BaseInstaller, NpmInstaller, PipInstaller, GeneralInstaller, InstallerFactory, createInstallerFactory } from './core/installers/index.js';
10
+ // Web server
11
+ export { startWebServer } from './web/server.js';
12
+ // Version information
13
+ export const VERSION = '0.0.1';
14
+ // Default configuration
15
+ export const DEFAULT_CONFIG = {
16
+ configPath: './config/servers.json',
17
+ webPort: 3000
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ import { ServerInstallOptions } from '../core/types.js';
2
+ import { InstallServersRequestBody } from '../web/server.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
@@ -0,0 +1,47 @@
1
+ import { MCPServerCategory, ServerInstallOptions, ServerCategoryListOptions, ServerOperationResult, ServerUninstallOptions } from '../core/types.js';
2
+ /**
3
+ * ServerService provides a unified interface for server management operations.
4
+ * This layer handles business logic that's shared between the CLI and web interface.
5
+ */
6
+ export declare class ServerService {
7
+ /**
8
+ * Lists available MCP servers based on the provided options
9
+ */
10
+ listServerCategories(options?: ServerCategoryListOptions): Promise<MCPServerCategory[]>;
11
+ /**
12
+ * Gets a server by name
13
+ */
14
+ getServerCategory(categoryName: string): Promise<MCPServerCategory | undefined>;
15
+ /**
16
+ * Check for updates to requirements for a server category
17
+ * @param serverCategory The server category to check
18
+ * @private
19
+ */
20
+ private checkRequirementsForUpdate;
21
+ /**
22
+ * Installs a specific mcp tool for a server.
23
+ * TODO: This might require enhancing MCPManager to handle category-specific installs.
24
+ */
25
+ installMcpServer(category: string, serverName: string, options?: ServerInstallOptions): Promise<ServerOperationResult>;
26
+ /**
27
+ * Installs a specific mcp tool for a server.
28
+ * TODO: This might require enhancing MCPManager to handle category-specific installs.
29
+ */
30
+ uninstallMcpServer(category: string, serverName: string, options?: ServerUninstallOptions): Promise<ServerOperationResult>;
31
+ /**
32
+ * Validates server names
33
+ */
34
+ validateServerName(category: string, name: string): Promise<boolean>;
35
+ /**
36
+ * Formats success/error messages for operations
37
+ */
38
+ formatOperationResults(results: ServerOperationResult[]): {
39
+ success: boolean;
40
+ messages: string[];
41
+ };
42
+ /**
43
+ * Syncs MCP server configurations from remote feed source
44
+ */
45
+ syncFeeds(): Promise<void>;
46
+ }
47
+ export declare const serverService: ServerService;