imcp 0.0.16 → 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 (135) 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 -1
  8. package/dist/core/installers/clients/ClientInstaller.js +1 -1
  9. package/dist/core/installers/clients/ClientInstallerFactory.js +1 -1
  10. package/dist/core/installers/clients/ClineInstaller.d.ts +1 -1
  11. package/dist/core/installers/clients/ClineInstaller.js +1 -1
  12. package/dist/core/installers/clients/ExtensionInstaller.js +1 -1
  13. package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +1 -1
  14. package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -1
  15. package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +1 -1
  16. package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -1
  17. package/dist/core/installers/requirements/BaseInstaller.d.ts +1 -1
  18. package/dist/core/installers/requirements/BaseInstaller.js +1 -1
  19. package/dist/core/installers/requirements/CommandInstaller.d.ts +1 -1
  20. package/dist/core/installers/requirements/CommandInstaller.js +1 -1
  21. package/dist/core/installers/requirements/GeneralInstaller.d.ts +1 -1
  22. package/dist/core/installers/requirements/InstallerFactory.d.ts +1 -1
  23. package/dist/core/installers/requirements/NpmInstaller.d.ts +1 -1
  24. package/dist/core/installers/requirements/NpmInstaller.js +1 -1
  25. package/dist/core/installers/requirements/PipInstaller.d.ts +1 -1
  26. package/dist/core/installers/requirements/RequirementInstaller.d.ts +1 -1
  27. package/dist/core/loaders/ConfigurationLoader.d.ts +32 -0
  28. package/dist/core/loaders/ConfigurationLoader.js +236 -0
  29. package/dist/core/loaders/ConfigurationProvider.d.ts +35 -0
  30. package/dist/core/loaders/ConfigurationProvider.js +375 -0
  31. package/dist/core/loaders/ServerSchemaLoader.d.ts +11 -0
  32. package/{src/core/ServerSchemaLoader.ts → dist/core/loaders/ServerSchemaLoader.js} +43 -48
  33. package/dist/core/loaders/ServerSchemaProvider.d.ts +17 -0
  34. package/{src/core/ServerSchemaProvider.ts → dist/core/loaders/ServerSchemaProvider.js} +120 -137
  35. package/dist/core/metadatas/constants.d.ts +47 -0
  36. package/dist/core/metadatas/constants.js +94 -0
  37. package/dist/core/metadatas/types.d.ts +166 -0
  38. package/dist/core/metadatas/types.js +16 -0
  39. package/dist/core/onboard/FeedOnboardService.d.ts +1 -1
  40. package/dist/core/onboard/FeedOnboardService.js +1 -1
  41. package/dist/core/onboard/OnboardProcessor.d.ts +1 -1
  42. package/dist/core/onboard/OnboardProcessor.js +1 -1
  43. package/dist/core/onboard/OnboardStatus.d.ts +1 -1
  44. package/dist/core/onboard/OnboardStatusManager.d.ts +1 -1
  45. package/dist/core/onboard/OnboardStatusManager.js +1 -1
  46. package/dist/core/validators/FeedValidator.d.ts +1 -1
  47. package/dist/core/validators/IServerValidator.d.ts +1 -1
  48. package/dist/core/validators/SSEServerValidator.d.ts +1 -1
  49. package/dist/core/validators/ServerValidatorFactory.d.ts +1 -1
  50. package/dist/core/validators/StdioServerValidator.d.ts +1 -1
  51. package/dist/core/validators/StdioServerValidator.js +1 -1
  52. package/dist/index.d.ts +3 -3
  53. package/dist/index.js +3 -3
  54. package/dist/services/InstallationService.d.ts +50 -0
  55. package/dist/services/InstallationService.js +350 -0
  56. package/dist/services/MCPManager.d.ts +28 -0
  57. package/dist/services/MCPManager.js +188 -0
  58. package/dist/services/RequirementService.d.ts +40 -0
  59. package/dist/services/RequirementService.js +110 -0
  60. package/dist/services/ServerService.d.ts +2 -2
  61. package/dist/services/ServerService.js +5 -5
  62. package/dist/utils/adoUtils.d.ts +2 -2
  63. package/dist/utils/adoUtils.js +1 -1
  64. package/dist/utils/feedUtils.js +1 -1
  65. package/dist/utils/githubUtils.d.ts +1 -1
  66. package/dist/utils/githubUtils.js +1 -1
  67. package/dist/utils/logger.js +1 -1
  68. package/dist/utils/macroExpressionUtils.d.ts +1 -1
  69. package/dist/utils/osUtils.d.ts +1 -1
  70. package/dist/utils/osUtils.js +1 -1
  71. package/dist/web/contract/serverContract.d.ts +1 -1
  72. package/dist/web/public/index.html +1 -3
  73. package/dist/web/public/js/api.js +2 -80
  74. package/dist/web/server.js +2 -2
  75. package/package.json +1 -1
  76. package/src/cli/commands/install.ts +3 -3
  77. package/src/cli/commands/list.ts +2 -2
  78. package/src/cli/commands/serve.ts +3 -2
  79. package/src/cli/index.ts +1 -1
  80. package/src/core/installers/clients/BaseClientInstaller.ts +134 -3
  81. package/src/core/installers/clients/ClientInstaller.ts +3 -3
  82. package/src/core/installers/clients/ClientInstallerFactory.ts +1 -1
  83. package/src/core/installers/clients/ClineInstaller.ts +1 -101
  84. package/src/core/installers/clients/ExtensionInstaller.ts +1 -1
  85. package/src/core/installers/clients/GithubCopilotInstaller.ts +1 -101
  86. package/src/core/installers/clients/MSRooCodeInstaller.ts +1 -102
  87. package/src/core/installers/requirements/BaseInstaller.ts +2 -2
  88. package/src/core/installers/requirements/CommandInstaller.ts +1 -1
  89. package/src/core/installers/requirements/GeneralInstaller.ts +1 -1
  90. package/src/core/installers/requirements/InstallerFactory.ts +1 -1
  91. package/src/core/installers/requirements/NpmInstaller.ts +12 -12
  92. package/src/core/installers/requirements/PipInstaller.ts +1 -1
  93. package/src/core/installers/requirements/RequirementInstaller.ts +1 -1
  94. package/src/core/{ConfigurationLoader.ts → loaders/ConfigurationLoader.ts} +31 -7
  95. package/src/core/{ConfigurationProvider.ts → loaders/ConfigurationProvider.ts} +18 -10
  96. package/src/core/loaders/ServerSchemaLoader.ts +117 -0
  97. package/src/core/loaders/ServerSchemaProvider.ts +99 -0
  98. package/src/core/{types.ts → metadatas/types.ts} +3 -2
  99. package/src/core/onboard/FeedOnboardService.ts +270 -146
  100. package/src/core/onboard/OnboardProcessor.ts +60 -11
  101. package/src/core/onboard/OnboardStatus.ts +7 -2
  102. package/src/core/onboard/OnboardStatusManager.ts +270 -43
  103. package/src/core/validators/FeedValidator.ts +65 -9
  104. package/src/core/validators/IServerValidator.ts +1 -1
  105. package/src/core/validators/SSEServerValidator.ts +2 -2
  106. package/src/core/validators/ServerValidatorFactory.ts +1 -1
  107. package/src/core/validators/StdioServerValidator.ts +86 -34
  108. package/src/index.ts +3 -3
  109. package/src/{core → services}/InstallationService.ts +5 -5
  110. package/src/{core → services}/MCPManager.ts +10 -5
  111. package/src/{core → services}/RequirementService.ts +2 -31
  112. package/src/services/ServerService.ts +7 -7
  113. package/src/utils/adoUtils.ts +3 -3
  114. package/src/utils/feedUtils.ts +2 -2
  115. package/src/utils/githubUtils.ts +2 -2
  116. package/src/utils/logger.ts +13 -1
  117. package/src/utils/macroExpressionUtils.ts +1 -1
  118. package/src/utils/osUtils.ts +4 -4
  119. package/src/web/contract/serverContract.ts +2 -2
  120. package/src/web/public/index.html +1 -3
  121. package/src/web/public/js/api.js +2 -80
  122. package/src/web/public/js/modal/installation.js +1 -1
  123. package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
  124. package/src/web/public/js/onboard/formProcessor.js +200 -34
  125. package/src/web/public/js/onboard/index.js +2 -2
  126. package/src/web/public/js/onboard/publishHandler.js +30 -22
  127. package/src/web/public/js/onboard/templates.js +34 -40
  128. package/src/web/public/js/onboard/uiHandlers.js +175 -84
  129. package/src/web/public/js/onboard/validationHandlers.js +147 -64
  130. package/src/web/public/js/serverCategoryDetails.js +19 -4
  131. package/src/web/public/js/serverCategoryList.js +13 -1
  132. package/src/web/public/onboard.html +1 -1
  133. package/src/web/server.ts +30 -14
  134. package/src/services/InstallRequestValidator.ts +0 -112
  135. /package/src/core/{constants.ts → metadatas/constants.ts} +0 -0
@@ -0,0 +1,375 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { exec } from 'child_process';
4
+ import { promisify } from 'util';
5
+ import { fileURLToPath } from 'url';
6
+ import { GITHUB_REPO, LOCAL_FEEDS_DIR, SETTINGS_DIR, SUPPORTED_CLIENTS } from '../metadatas/constants.js';
7
+ import { Logger } from '../../utils/logger.js';
8
+ import { checkGithubAuth } from '../../utils/githubAuth.js';
9
+ import { ConfigurationLoader } from './ConfigurationLoader.js';
10
+ const execAsync = promisify(exec);
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ export class ConfigurationProvider {
13
+ static instance;
14
+ configPath;
15
+ configuration;
16
+ configLock = Promise.resolve();
17
+ tempDir;
18
+ constructor() {
19
+ // Initialize configuration in user's appdata/imcp directory
20
+ this.configPath = path.join(SETTINGS_DIR, 'configurations.json');
21
+ this.configuration = {
22
+ localServerCategories: [],
23
+ feeds: {},
24
+ clientMCPSettings: {}
25
+ };
26
+ this.tempDir = path.join(LOCAL_FEEDS_DIR, '../temp');
27
+ }
28
+ static getInstance() {
29
+ if (!ConfigurationProvider.instance) {
30
+ ConfigurationProvider.instance = new ConfigurationProvider();
31
+ }
32
+ return ConfigurationProvider.instance;
33
+ }
34
+ async withLock(operation) {
35
+ const current = this.configLock;
36
+ let resolve;
37
+ this.configLock = new Promise(r => resolve = r);
38
+ try {
39
+ await current;
40
+ return await operation();
41
+ }
42
+ finally {
43
+ resolve();
44
+ }
45
+ }
46
+ async initialize(feedFile) {
47
+ await this.withLock(async () => {
48
+ const configDir = path.dirname(this.configPath);
49
+ await fs.mkdir(configDir, { recursive: true });
50
+ try {
51
+ try {
52
+ const config = JSON.parse(await fs.readFile(this.configPath, 'utf8'));
53
+ this.configuration = config;
54
+ }
55
+ catch (error) {
56
+ if (error.code !== 'ENOENT') {
57
+ throw error;
58
+ }
59
+ // File doesn't exist, use default empty configuration
60
+ await this.saveConfiguration();
61
+ }
62
+ // Always load feeds and client settings, whether file existed or not
63
+ await this.loadFeedsIntoConfiguration(feedFile);
64
+ await this.loadClientMCPSettings();
65
+ }
66
+ catch (error) {
67
+ Logger.error('Error during initialization', error);
68
+ throw error;
69
+ }
70
+ });
71
+ }
72
+ async saveConfiguration() {
73
+ const configDir = path.dirname(this.configPath);
74
+ await fs.mkdir(configDir, { recursive: true });
75
+ await fs.writeFile(this.configPath, JSON.stringify(this.configuration, null, 2));
76
+ }
77
+ async getServerCategories() {
78
+ return await this.withLock(async () => {
79
+ return this.configuration.localServerCategories;
80
+ });
81
+ }
82
+ async getServerCategory(categoryName) {
83
+ return await this.withLock(async () => {
84
+ return this.configuration.localServerCategories.find(s => s.name === categoryName);
85
+ });
86
+ }
87
+ async getClientMcpSettings() {
88
+ return await this.withLock(async () => {
89
+ return this.configuration.clientMCPSettings;
90
+ });
91
+ }
92
+ async getFeedConfiguration(categoryName) {
93
+ return await this.withLock(async () => {
94
+ return this.configuration.feeds[categoryName];
95
+ });
96
+ }
97
+ async getServerMcpConfig(categoryName, serverName) {
98
+ return await this.withLock(async () => {
99
+ return this.configuration.feeds[categoryName]?.mcpServers.find(s => s.name === serverName);
100
+ });
101
+ }
102
+ async getInstallationStatus(categoryName) {
103
+ return await this.withLock(async () => {
104
+ // Inline getServerCategory logic
105
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
106
+ return category?.installationStatus;
107
+ });
108
+ }
109
+ async getServerStatus(categoryName, serverName) {
110
+ return await this.withLock(async () => {
111
+ // Inline getInstallationStatus logic
112
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
113
+ const status = category?.installationStatus;
114
+ return status?.serversStatus[serverName];
115
+ });
116
+ }
117
+ async getRequirementStatus(categoryName, requirementName) {
118
+ return await this.withLock(async () => {
119
+ // Inline getInstallationStatus logic
120
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
121
+ const status = category?.installationStatus;
122
+ return status?.requirementsStatus[requirementName];
123
+ });
124
+ }
125
+ async updateInstallationStatus(categoryName, requirementStatus, serverStatus) {
126
+ return await this.withLock(async () => {
127
+ // Inline getServerCategory logic
128
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
129
+ if (!category)
130
+ return false;
131
+ if (!category.installationStatus) {
132
+ category.installationStatus = {
133
+ requirementsStatus: {},
134
+ serversStatus: {},
135
+ lastUpdated: new Date().toISOString()
136
+ };
137
+ }
138
+ category.installationStatus.requirementsStatus = {
139
+ ...category.installationStatus.requirementsStatus,
140
+ ...requirementStatus
141
+ };
142
+ category.installationStatus.serversStatus = {
143
+ ...category.installationStatus.serversStatus,
144
+ ...serverStatus
145
+ };
146
+ category.installationStatus.lastUpdated = new Date().toISOString();
147
+ await this.saveConfiguration();
148
+ return true;
149
+ });
150
+ }
151
+ async updateRequirementStatus(categoryName, requirementName, status) {
152
+ return await this.withLock(async () => {
153
+ // Inline getServerCategory logic
154
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
155
+ if (!category?.installationStatus)
156
+ return false;
157
+ category.installationStatus.requirementsStatus[requirementName] = status;
158
+ category.installationStatus.lastUpdated = new Date().toISOString();
159
+ await this.saveConfiguration();
160
+ return true;
161
+ });
162
+ }
163
+ async updateRequirementOperationStatus(categoryName, requirementName, operationStatus) {
164
+ return await this.withLock(async () => {
165
+ // Inline getServerCategory logic
166
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
167
+ if (!category?.installationStatus?.requirementsStatus[requirementName])
168
+ return false;
169
+ category.installationStatus.requirementsStatus[requirementName].operationStatus = operationStatus;
170
+ category.installationStatus.lastUpdated = new Date().toISOString();
171
+ await this.saveConfiguration();
172
+ return true;
173
+ });
174
+ }
175
+ async updateServerStatus(categoryName, serverName, status) {
176
+ return await this.withLock(async () => {
177
+ // Inline getServerCategory logic
178
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
179
+ if (!category?.installationStatus)
180
+ return false;
181
+ category.installationStatus.serversStatus[serverName] = status;
182
+ category.installationStatus.lastUpdated = new Date().toISOString();
183
+ await this.saveConfiguration();
184
+ return true;
185
+ });
186
+ }
187
+ async updateServerOperationStatus(categoryName, serverName, clientName, operationStatus) {
188
+ return await this.withLock(async () => {
189
+ // Inline getServerCategory logic
190
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
191
+ if (!category?.installationStatus?.serversStatus[serverName])
192
+ return false;
193
+ category.installationStatus.serversStatus[serverName].installedStatus[clientName] = operationStatus;
194
+ category.installationStatus.lastUpdated = new Date().toISOString();
195
+ await this.saveConfiguration();
196
+ return true;
197
+ });
198
+ }
199
+ async isRequirementsReady(categoryName, serverName) {
200
+ return await this.withLock(async () => {
201
+ // Inline getServerCategory logic
202
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
203
+ if (!category?.feedConfiguration)
204
+ return false;
205
+ const serverConfig = category.feedConfiguration.mcpServers.find(s => s.name === serverName);
206
+ if (!serverConfig?.dependencies?.requirements)
207
+ return true; // No requirements means ready
208
+ const requirementNames = serverConfig.dependencies.requirements.map(r => r.name);
209
+ // Inline getInstallationStatus logic (using the already fetched category)
210
+ const status = category?.installationStatus;
211
+ if (!status?.requirementsStatus)
212
+ return false;
213
+ return requirementNames.every(name => {
214
+ const reqStatus = status.requirementsStatus[name];
215
+ return reqStatus?.installed && !reqStatus?.error;
216
+ });
217
+ });
218
+ }
219
+ async GetServerRequirementStatus(categoryName, serverName) {
220
+ return await this.withLock(async () => {
221
+ // Inline getServerCategory logic
222
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
223
+ if (!category?.feedConfiguration)
224
+ return [];
225
+ const serverConfig = category.feedConfiguration.mcpServers.find(s => s.name === serverName);
226
+ if (!serverConfig?.dependencies?.requirements)
227
+ return [];
228
+ const requirementNames = serverConfig.dependencies.requirements.map(r => r.name);
229
+ return requirementNames
230
+ .map(name => category?.installationStatus?.requirementsStatus[name])
231
+ .filter(x => x !== undefined);
232
+ });
233
+ }
234
+ async isServerReady(categoryName, serverName, clients) {
235
+ return await this.withLock(async () => {
236
+ // Inline the logic from getServerStatus and getInstallationStatus to avoid nested lock
237
+ const category = this.configuration.localServerCategories.find(s => s.name === categoryName);
238
+ const installationStatus = category?.installationStatus;
239
+ const serverStatus = installationStatus?.serversStatus[serverName];
240
+ if (!serverStatus)
241
+ return false;
242
+ return clients.every(clientName => {
243
+ // Add optional chaining for safety in case installedStatus is missing
244
+ const clientStatus = serverStatus.installedStatus?.[clientName];
245
+ return clientStatus?.status === 'completed' && !clientStatus?.error;
246
+ });
247
+ });
248
+ }
249
+ async syncFeeds() {
250
+ return await this.withLock(async () => {
251
+ Logger.log('Starting feed synchronization...');
252
+ try {
253
+ // Check GitHub authentication first
254
+ await checkGithubAuth();
255
+ Logger.debug({
256
+ action: 'create_directories',
257
+ paths: {
258
+ localFeeds: LOCAL_FEEDS_DIR,
259
+ tempDir: this.tempDir
260
+ }
261
+ });
262
+ await fs.mkdir(LOCAL_FEEDS_DIR, { recursive: true });
263
+ await fs.mkdir(this.tempDir, { recursive: true });
264
+ // Clean up temp directory
265
+ await fs.rm(this.tempDir, { recursive: true, force: true });
266
+ // Download latest release
267
+ Logger.debug('Downloading latest release...');
268
+ const { downloadGithubRelease } = await import('../../utils/githubUtils.js');
269
+ const { version, downloadPath } = await downloadGithubRelease(GITHUB_REPO.repoName, 'latest', GITHUB_REPO.feedAssetsName, undefined, true, this.tempDir);
270
+ Logger.debug({
271
+ action: 'download_release',
272
+ downloadPath,
273
+ version,
274
+ repoName: GITHUB_REPO.repoName,
275
+ });
276
+ Logger.debug('Updating local feeds...');
277
+ await fs.rm(LOCAL_FEEDS_DIR, { recursive: true, force: true });
278
+ const sourceFeedsDir = downloadPath;
279
+ try {
280
+ await fs.access(downloadPath);
281
+ }
282
+ catch (err) {
283
+ throw new Error(`Could not find feeds directory in downloaded path: ${sourceFeedsDir}`);
284
+ }
285
+ await fs.cp(sourceFeedsDir, LOCAL_FEEDS_DIR, { recursive: true, force: true });
286
+ Logger.log('Successfully updated local feeds');
287
+ }
288
+ catch (error) {
289
+ Logger.error('Error during feed synchronization', error);
290
+ throw new Error('Failed to sync feeds. Use --verbose for detailed error information.');
291
+ }
292
+ });
293
+ }
294
+ async loadFeedsIntoConfiguration(feedFile) {
295
+ this.configuration = await ConfigurationLoader.loadFeedsIntoConfiguration(this.configuration, feedFile);
296
+ await this.saveConfiguration();
297
+ }
298
+ async loadClientMCPSettings() {
299
+ this.configuration = await ConfigurationLoader.loadClientMCPSettings(this.configuration);
300
+ await this.saveConfiguration();
301
+ }
302
+ // Public method to reload client MCP settings
303
+ async reloadClientMCPSettings() {
304
+ return await this.withLock(async () => {
305
+ await this.loadClientMCPSettings();
306
+ });
307
+ }
308
+ async removeServerFromClientMCPSettings(serverName, target) {
309
+ return await this.withLock(async () => {
310
+ // Load utils in async context to avoid circular dependencies
311
+ const { readJsonFile, writeJsonFile } = await import('../../utils/clientUtils.js');
312
+ // Filter clients if target is specified
313
+ const clientEntries = Object.entries(SUPPORTED_CLIENTS);
314
+ const targetClients = target
315
+ ? clientEntries.filter(([clientName]) => clientName === target)
316
+ : clientEntries;
317
+ for (const [clientName, clientSettings] of targetClients) {
318
+ const settingPath = process.env.CODE_INSIDERS
319
+ ? clientSettings.codeInsiderSettingPath
320
+ : clientSettings.codeSettingPath;
321
+ try {
322
+ const content = await readJsonFile(settingPath, true);
323
+ let modified = false;
324
+ // Handle GitHub Copilot's different structure
325
+ if (clientName === 'GithubCopilot' && content.mcp?.servers?.[serverName]) {
326
+ delete content.mcp.servers[serverName];
327
+ modified = true;
328
+ }
329
+ else if (content.mcpServers?.[serverName]) {
330
+ delete content.mcpServers[serverName];
331
+ modified = true;
332
+ }
333
+ // Only write if we actually modified the content
334
+ if (modified) {
335
+ await writeJsonFile(settingPath, content);
336
+ Logger.debug(`Removed server ${serverName} from client ${clientName} settings`);
337
+ }
338
+ }
339
+ catch (error) {
340
+ Logger.error(`Failed to remove server ${serverName} from client ${clientName} settings:`, error);
341
+ }
342
+ }
343
+ // Also update our in-memory configuration
344
+ if (this.configuration.clientMCPSettings) {
345
+ if (target) {
346
+ // Only update settings for the target client
347
+ const clientSettings = this.configuration.clientMCPSettings[target];
348
+ if (clientSettings) {
349
+ if (clientSettings.mcpServers?.[serverName]) {
350
+ delete clientSettings.mcpServers[serverName];
351
+ }
352
+ if (clientSettings.servers?.[serverName]) { // For GitHub Copilot
353
+ delete clientSettings.servers[serverName];
354
+ }
355
+ }
356
+ }
357
+ else {
358
+ // Update all clients if no target specified
359
+ for (const clientSettings of Object.values(this.configuration.clientMCPSettings)) {
360
+ if (clientSettings.mcpServers?.[serverName]) {
361
+ delete clientSettings.mcpServers[serverName];
362
+ }
363
+ if (clientSettings.servers?.[serverName]) { // For GitHub Copilot
364
+ delete clientSettings.servers[serverName];
365
+ }
366
+ }
367
+ }
368
+ await this.saveConfiguration();
369
+ }
370
+ });
371
+ }
372
+ }
373
+ // Export a singleton instance
374
+ export const configProvider = ConfigurationProvider.getInstance();
375
+ //# sourceMappingURL=ConfigurationProvider.js.map
@@ -0,0 +1,11 @@
1
+ import { ServerSchema } from './ServerSchemaProvider.js';
2
+ export declare class ServerSchemaLoader {
3
+ /**
4
+ * Load schema for a specific server in a category
5
+ */
6
+ static loadSchema(categoryName: string, serverName: string): Promise<ServerSchema | undefined>;
7
+ /**
8
+ * Validate schema content against expected format
9
+ */
10
+ static validateSchema(schema: any): boolean;
11
+ }
@@ -1,48 +1,43 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { LOCAL_FEEDS_SCHEMA_DIR } from './constants.js';
4
- import { Logger } from '../utils/logger.js';
5
- import { ServerSchema } from './ServerSchemaProvider.js';
6
-
7
- export class ServerSchemaLoader {
8
- /**
9
- * Load schema for a specific server in a category
10
- */
11
- static async loadSchema(categoryName: string, serverName: string): Promise<ServerSchema | undefined> {
12
- try {
13
- const schemaPath = path.join(LOCAL_FEEDS_SCHEMA_DIR, categoryName, `${serverName}.json`);
14
- const content = await fs.readFile(schemaPath, 'utf8');
15
- const schema = JSON.parse(content);
16
-
17
- // Validate schema structure
18
- if (!schema.version || !schema.schema) {
19
- Logger.debug(`Invalid schema format for server ${serverName} in category ${categoryName}`);
20
- return undefined;
21
- }
22
-
23
- return {
24
- schema: schema
25
- };
26
- } catch (error) {
27
- if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
28
- Logger.debug(`No schema file found for server ${serverName} in category ${categoryName}`);
29
- return undefined;
30
- }
31
- Logger.error(`Error loading schema for server ${serverName} in category ${categoryName}:`, error);
32
- throw error;
33
- }
34
- }
35
-
36
- /**
37
- * Validate schema content against expected format
38
- */
39
- static validateSchema(schema: any): boolean {
40
- return (
41
- typeof schema === 'object' &&
42
- schema !== null &&
43
- typeof schema.version === 'string' &&
44
- typeof schema.schema === 'object' &&
45
- schema.schema !== null
46
- );
47
- }
48
- }
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { LOCAL_FEEDS_SCHEMA_DIR } from '../metadatas/constants.js';
4
+ import { Logger } from '../../utils/logger.js';
5
+ export class ServerSchemaLoader {
6
+ /**
7
+ * Load schema for a specific server in a category
8
+ */
9
+ static async loadSchema(categoryName, serverName) {
10
+ try {
11
+ const schemaPath = path.join(LOCAL_FEEDS_SCHEMA_DIR, categoryName, `${serverName}.json`);
12
+ const content = await fs.readFile(schemaPath, 'utf8');
13
+ const schema = JSON.parse(content);
14
+ // Validate schema structure
15
+ if (!schema.version || !schema.schema) {
16
+ Logger.debug(`Invalid schema format for server ${serverName} in category ${categoryName}`);
17
+ return undefined;
18
+ }
19
+ return {
20
+ schema: schema
21
+ };
22
+ }
23
+ catch (error) {
24
+ if (error.code === 'ENOENT') {
25
+ Logger.debug(`No schema file found for server ${serverName} in category ${categoryName}`);
26
+ return undefined;
27
+ }
28
+ Logger.error(`Error loading schema for server ${serverName} in category ${categoryName}:`, error);
29
+ throw error;
30
+ }
31
+ }
32
+ /**
33
+ * Validate schema content against expected format
34
+ */
35
+ static validateSchema(schema) {
36
+ return (typeof schema === 'object' &&
37
+ schema !== null &&
38
+ typeof schema.version === 'string' &&
39
+ typeof schema.schema === 'object' &&
40
+ schema.schema !== null);
41
+ }
42
+ }
43
+ //# sourceMappingURL=ServerSchemaLoader.js.map
@@ -0,0 +1,17 @@
1
+ export interface ServerSchema {
2
+ schema: Record<string, any>;
3
+ }
4
+ export declare class ServerSchemaProvider {
5
+ private static instance;
6
+ private schemaMap;
7
+ private schemaLock;
8
+ private constructor();
9
+ static getInstance(): Promise<ServerSchemaProvider>;
10
+ private withLock;
11
+ initialize(): Promise<void>;
12
+ private loadSchema;
13
+ private loadAllSchemas;
14
+ getSchema(categoryName: string, schemaFileName: string): Promise<ServerSchema | undefined>;
15
+ reloadSchemas(): Promise<void>;
16
+ }
17
+ export declare function getServerSchemaProvider(): Promise<ServerSchemaProvider>;