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