imcp 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/install.js +2 -2
- package/dist/cli/commands/list.js +2 -2
- package/dist/cli/commands/serve.js +3 -2
- package/dist/core/RequirementService.d.ts +0 -12
- package/dist/core/RequirementService.js +0 -24
- package/dist/core/installers/clients/BaseClientInstaller.d.ts +26 -3
- package/dist/core/installers/clients/BaseClientInstaller.js +121 -0
- package/dist/core/installers/clients/ClientInstaller.d.ts +1 -1
- package/dist/core/installers/clients/ClientInstaller.js +1 -1
- package/dist/core/installers/clients/ClientInstallerFactory.js +1 -1
- package/dist/core/installers/clients/ClineInstaller.d.ts +1 -6
- package/dist/core/installers/clients/ClineInstaller.js +1 -94
- package/dist/core/installers/clients/ExtensionInstaller.js +1 -1
- package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +1 -6
- package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -94
- package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +1 -5
- package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -94
- package/dist/core/installers/requirements/BaseInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/BaseInstaller.js +1 -1
- package/dist/core/installers/requirements/CommandInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/CommandInstaller.js +1 -1
- package/dist/core/installers/requirements/GeneralInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/InstallerFactory.d.ts +1 -1
- package/dist/core/installers/requirements/NpmInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/NpmInstaller.js +1 -1
- package/dist/core/installers/requirements/PipInstaller.d.ts +1 -1
- package/dist/core/installers/requirements/RequirementInstaller.d.ts +1 -1
- package/dist/core/loaders/ConfigurationLoader.d.ts +35 -0
- package/dist/core/loaders/ConfigurationLoader.js +257 -0
- package/dist/core/loaders/ConfigurationProvider.d.ts +38 -0
- package/dist/core/loaders/ConfigurationProvider.js +384 -0
- package/dist/core/loaders/ServerSchemaLoader.d.ts +22 -0
- package/dist/core/loaders/ServerSchemaLoader.js +109 -0
- package/dist/core/loaders/ServerSchemaProvider.d.ts +14 -0
- package/dist/core/loaders/ServerSchemaProvider.js +90 -0
- package/dist/core/metadatas/constants.d.ts +47 -0
- package/dist/core/metadatas/constants.js +94 -0
- package/dist/core/metadatas/types.d.ts +167 -0
- package/dist/core/metadatas/types.js +16 -0
- package/dist/core/onboard/FeedOnboardService.d.ts +15 -8
- package/dist/core/onboard/FeedOnboardService.js +215 -130
- package/dist/core/onboard/OnboardProcessor.d.ts +8 -2
- package/dist/core/onboard/OnboardProcessor.js +53 -9
- package/dist/core/onboard/OnboardStatus.d.ts +7 -2
- package/dist/core/onboard/OnboardStatusManager.d.ts +71 -25
- package/dist/core/onboard/OnboardStatusManager.js +231 -47
- package/dist/core/validators/FeedValidator.d.ts +8 -3
- package/dist/core/validators/FeedValidator.js +61 -7
- package/dist/core/validators/IServerValidator.d.ts +1 -1
- package/dist/core/validators/SSEServerValidator.d.ts +1 -1
- package/dist/core/validators/ServerValidatorFactory.d.ts +1 -1
- package/dist/core/validators/StdioServerValidator.d.ts +1 -1
- package/dist/core/validators/StdioServerValidator.js +85 -33
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/services/InstallationService.d.ts +50 -0
- package/dist/services/InstallationService.js +350 -0
- package/dist/services/MCPManager.d.ts +29 -0
- package/dist/services/MCPManager.js +192 -0
- package/dist/services/RequirementService.d.ts +40 -0
- package/dist/services/RequirementService.js +110 -0
- package/dist/services/ServerService.d.ts +2 -2
- package/dist/services/ServerService.js +6 -6
- package/dist/utils/adoUtils.d.ts +2 -2
- package/dist/utils/adoUtils.js +1 -1
- package/dist/utils/feedUtils.js +1 -1
- package/dist/utils/githubUtils.d.ts +1 -1
- package/dist/utils/githubUtils.js +1 -1
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +11 -1
- package/dist/utils/macroExpressionUtils.d.ts +1 -1
- package/dist/utils/osUtils.d.ts +1 -1
- package/dist/utils/osUtils.js +1 -1
- package/dist/web/contract/serverContract.d.ts +1 -1
- package/dist/web/public/index.html +1 -3
- package/dist/web/public/js/api.js +2 -80
- package/dist/web/public/js/modal/installation.js +1 -1
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
- package/dist/web/public/js/onboard/formProcessor.js +200 -34
- package/dist/web/public/js/onboard/index.js +2 -2
- package/dist/web/public/js/onboard/publishHandler.js +30 -22
- package/dist/web/public/js/onboard/templates.js +34 -40
- package/dist/web/public/js/onboard/uiHandlers.js +175 -84
- package/dist/web/public/js/onboard/validationHandlers.js +147 -64
- package/dist/web/public/js/serverCategoryDetails.js +19 -4
- package/dist/web/public/js/serverCategoryList.js +13 -1
- package/dist/web/public/onboard.html +1 -1
- package/dist/web/server.js +21 -8
- package/package.json +1 -1
- package/src/cli/commands/install.ts +3 -3
- package/src/cli/commands/list.ts +2 -2
- package/src/cli/commands/serve.ts +3 -2
- package/src/cli/index.ts +1 -1
- package/src/core/installers/clients/BaseClientInstaller.ts +134 -3
- package/src/core/installers/clients/ClientInstaller.ts +3 -3
- package/src/core/installers/clients/ClientInstallerFactory.ts +1 -1
- package/src/core/installers/clients/ClineInstaller.ts +1 -101
- package/src/core/installers/clients/ExtensionInstaller.ts +1 -1
- package/src/core/installers/clients/GithubCopilotInstaller.ts +1 -101
- package/src/core/installers/clients/MSRooCodeInstaller.ts +1 -102
- package/src/core/installers/requirements/BaseInstaller.ts +2 -2
- package/src/core/installers/requirements/CommandInstaller.ts +1 -1
- package/src/core/installers/requirements/GeneralInstaller.ts +1 -1
- package/src/core/installers/requirements/InstallerFactory.ts +1 -1
- package/src/core/installers/requirements/NpmInstaller.ts +12 -12
- package/src/core/installers/requirements/PipInstaller.ts +1 -1
- package/src/core/installers/requirements/RequirementInstaller.ts +1 -1
- package/src/core/{ConfigurationLoader.ts → loaders/ConfigurationLoader.ts} +31 -7
- package/src/core/{ConfigurationProvider.ts → loaders/ConfigurationProvider.ts} +18 -10
- package/src/core/loaders/ServerSchemaLoader.ts +117 -0
- package/src/core/loaders/ServerSchemaProvider.ts +99 -0
- package/src/core/{types.ts → metadatas/types.ts} +3 -2
- package/src/core/onboard/FeedOnboardService.ts +270 -146
- package/src/core/onboard/OnboardProcessor.ts +60 -11
- package/src/core/onboard/OnboardStatus.ts +7 -2
- package/src/core/onboard/OnboardStatusManager.ts +270 -43
- package/src/core/validators/FeedValidator.ts +65 -9
- package/src/core/validators/IServerValidator.ts +1 -1
- package/src/core/validators/SSEServerValidator.ts +2 -2
- package/src/core/validators/ServerValidatorFactory.ts +1 -1
- package/src/core/validators/StdioServerValidator.ts +86 -34
- package/src/index.ts +3 -3
- package/src/{core → services}/InstallationService.ts +5 -5
- package/src/{core → services}/MCPManager.ts +10 -5
- package/src/{core → services}/RequirementService.ts +2 -31
- package/src/services/ServerService.ts +7 -7
- package/src/utils/adoUtils.ts +3 -3
- package/src/utils/feedUtils.ts +2 -2
- package/src/utils/githubUtils.ts +2 -2
- package/src/utils/logger.ts +13 -1
- package/src/utils/macroExpressionUtils.ts +1 -1
- package/src/utils/osUtils.ts +4 -4
- package/src/web/contract/serverContract.ts +2 -2
- package/src/web/public/index.html +1 -3
- package/src/web/public/js/api.js +2 -80
- package/src/web/public/js/modal/installation.js +1 -1
- package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +41 -9
- package/src/web/public/js/onboard/formProcessor.js +200 -34
- package/src/web/public/js/onboard/index.js +2 -2
- package/src/web/public/js/onboard/publishHandler.js +30 -22
- package/src/web/public/js/onboard/templates.js +34 -40
- package/src/web/public/js/onboard/uiHandlers.js +175 -84
- package/src/web/public/js/onboard/validationHandlers.js +147 -64
- package/src/web/public/js/serverCategoryDetails.js +19 -4
- package/src/web/public/js/serverCategoryList.js +13 -1
- package/src/web/public/onboard.html +1 -1
- package/src/web/server.ts +30 -14
- package/src/core/ServerSchemaLoader.ts +0 -48
- package/src/core/ServerSchemaProvider.ts +0 -137
- package/src/services/InstallRequestValidator.ts +0 -112
- /package/src/core/{constants.ts → metadatas/constants.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { LOCAL_FEEDS_DIR, SUPPORTED_CLIENTS } from '
|
|
4
|
-
import { Logger } from '
|
|
5
|
-
import { readJsonFile } from '
|
|
3
|
+
import { LOCAL_FEEDS_DIR, SUPPORTED_CLIENTS } from '../metadatas/constants.js';
|
|
4
|
+
import { Logger } from '../../utils/logger.js';
|
|
5
|
+
import { readJsonFile } from '../../utils/clientUtils.js';
|
|
6
6
|
import {
|
|
7
7
|
MCPConfiguration,
|
|
8
8
|
MCPServerCategory,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
FeedConfiguration,
|
|
12
12
|
RequirementStatus,
|
|
13
13
|
InstallationStatus
|
|
14
|
-
} from '
|
|
14
|
+
} from '../metadatas/types.js';
|
|
15
15
|
|
|
16
16
|
export class ConfigurationLoader {
|
|
17
17
|
/**
|
|
@@ -177,7 +177,7 @@ export class ConfigurationLoader {
|
|
|
177
177
|
/**
|
|
178
178
|
* Loads feed configurations into the MCP configuration
|
|
179
179
|
*/
|
|
180
|
-
static async loadFeedsIntoConfiguration(configuration: MCPConfiguration, feedFile?: string): Promise<MCPConfiguration> {
|
|
180
|
+
static async loadFeedsIntoConfiguration(configuration: MCPConfiguration, feedFile?: string, settings?: { prLink?:string, adhocServers?: string[] }): Promise<MCPConfiguration> {
|
|
181
181
|
try {
|
|
182
182
|
await fs.mkdir(LOCAL_FEEDS_DIR, { recursive: true });
|
|
183
183
|
const feeds: Record<string, FeedConfiguration> = {};
|
|
@@ -186,10 +186,34 @@ export class ConfigurationLoader {
|
|
|
186
186
|
if (feedFile) {
|
|
187
187
|
try {
|
|
188
188
|
const content = await fs.readFile(feedFile, 'utf8');
|
|
189
|
-
|
|
189
|
+
let config = JSON.parse(content) as FeedConfiguration;
|
|
190
190
|
if (config && config.name) {
|
|
191
|
+
// Update systemTags if feedFile is provided
|
|
192
|
+
if (!config.systemTags) {
|
|
193
|
+
config.systemTags = {};
|
|
194
|
+
}
|
|
195
|
+
config.systemTags['adhoc'] = 'true';
|
|
196
|
+
|
|
197
|
+
// Update PullRequest if prLink is provided in settings
|
|
198
|
+
if (settings?.prLink) {
|
|
199
|
+
config.PullRequest = settings.prLink;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Update mcpServers systemTags if adhocServers are provided in settings
|
|
203
|
+
if (settings?.adhocServers && settings.adhocServers.length > 0 && config.mcpServers) {
|
|
204
|
+
config.mcpServers = config.mcpServers.map(server => {
|
|
205
|
+
if (settings.adhocServers!.includes(server.name)) {
|
|
206
|
+
if (!server.systemTags) {
|
|
207
|
+
server.systemTags = {};
|
|
208
|
+
}
|
|
209
|
+
server.systemTags['adhoc'] = 'true';
|
|
210
|
+
}
|
|
211
|
+
return server;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
191
215
|
feeds[config.name] = config;
|
|
192
|
-
console.log(`Loaded feed configuration from provided file: ${feedFile}`);
|
|
216
|
+
console.log(`Loaded and processed feed configuration from provided file: ${feedFile}`);
|
|
193
217
|
}
|
|
194
218
|
} catch (error) {
|
|
195
219
|
console.log(`Error loading feed configuration from provided file ${feedFile}:`, error);
|
|
@@ -3,9 +3,9 @@ import path from 'path';
|
|
|
3
3
|
import { exec } from 'child_process';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
|
-
import { GITHUB_REPO, LOCAL_FEEDS_DIR, SETTINGS_DIR, SUPPORTED_CLIENTS } from '
|
|
7
|
-
import { Logger } from '
|
|
8
|
-
import { checkGithubAuth } from '
|
|
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
9
|
import {
|
|
10
10
|
MCPConfiguration,
|
|
11
11
|
MCPServerCategory,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
OperationStatus,
|
|
17
17
|
ClientSettings,
|
|
18
18
|
McpConfig
|
|
19
|
-
} from '
|
|
19
|
+
} from '../metadatas/types.js';
|
|
20
20
|
import { ConfigurationLoader } from './ConfigurationLoader.js';
|
|
21
21
|
|
|
22
22
|
const execAsync = promisify(exec);
|
|
@@ -59,10 +59,18 @@ export class ConfigurationProvider {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
async initialize(feedFile?: string): Promise<void> {
|
|
62
|
+
async initialize(feedFile?: string, settings?: { prLink?:string, adhocServers?: string[] }): Promise<void> {
|
|
63
63
|
await this.withLock(async () => {
|
|
64
64
|
const configDir = path.dirname(this.configPath);
|
|
65
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
|
+
}
|
|
66
74
|
|
|
67
75
|
try {
|
|
68
76
|
try {
|
|
@@ -77,7 +85,7 @@ export class ConfigurationProvider {
|
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
// Always load feeds and client settings, whether file existed or not
|
|
80
|
-
await this.loadFeedsIntoConfiguration(feedFile);
|
|
88
|
+
await this.loadFeedsIntoConfiguration(feedFile, settings);
|
|
81
89
|
await this.loadClientMCPSettings();
|
|
82
90
|
} catch (error) {
|
|
83
91
|
Logger.error('Error during initialization', error);
|
|
@@ -327,7 +335,7 @@ export class ConfigurationProvider {
|
|
|
327
335
|
|
|
328
336
|
// Download latest release
|
|
329
337
|
Logger.debug('Downloading latest release...');
|
|
330
|
-
const { downloadGithubRelease } = await import('
|
|
338
|
+
const { downloadGithubRelease } = await import('../../utils/githubUtils.js');
|
|
331
339
|
const { version, downloadPath } = await downloadGithubRelease(
|
|
332
340
|
GITHUB_REPO.repoName,
|
|
333
341
|
'latest',
|
|
@@ -364,8 +372,8 @@ export class ConfigurationProvider {
|
|
|
364
372
|
});
|
|
365
373
|
}
|
|
366
374
|
|
|
367
|
-
private async loadFeedsIntoConfiguration(feedFile?: string): Promise<void> {
|
|
368
|
-
this.configuration = await ConfigurationLoader.loadFeedsIntoConfiguration(this.configuration, feedFile);
|
|
375
|
+
private async loadFeedsIntoConfiguration(feedFile?: string, settings?: { prLink?:string, adhocServers?: string[] }): Promise<void> {
|
|
376
|
+
this.configuration = await ConfigurationLoader.loadFeedsIntoConfiguration(this.configuration, feedFile, settings);
|
|
369
377
|
await this.saveConfiguration();
|
|
370
378
|
}
|
|
371
379
|
|
|
@@ -384,7 +392,7 @@ export class ConfigurationProvider {
|
|
|
384
392
|
async removeServerFromClientMCPSettings(serverName: string, target?: string): Promise<void> {
|
|
385
393
|
return await this.withLock(async () => {
|
|
386
394
|
// Load utils in async context to avoid circular dependencies
|
|
387
|
-
const { readJsonFile, writeJsonFile } = await import('
|
|
395
|
+
const { readJsonFile, writeJsonFile } = await import('../../utils/clientUtils.js');
|
|
388
396
|
|
|
389
397
|
// Filter clients if target is specified
|
|
390
398
|
const clientEntries = Object.entries(SUPPORTED_CLIENTS as Record<string, ClientSettings>);
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
import { ServerSchema } from './ServerSchemaProvider.js';
|
|
6
|
+
|
|
7
|
+
export class ServerSchemaLoader {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Loads a single schema file.
|
|
11
|
+
* @param filePath The absolute path to the schema file.
|
|
12
|
+
* @returns A Promise that resolves to the ServerSchema or undefined if not found or error.
|
|
13
|
+
*/
|
|
14
|
+
public static async loadSchema(filePath: string): Promise<ServerSchema | undefined> {
|
|
15
|
+
try {
|
|
16
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
17
|
+
const schema = JSON.parse(content);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
schema: schema
|
|
21
|
+
};
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
24
|
+
Logger.debug(`No schema file found at ${filePath}`);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
Logger.error(`Error loading schema from ${filePath}:`, error);
|
|
28
|
+
// Optionally rethrow or return undefined based on desired error handling
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Loads all schemas from the default feeds directory.
|
|
35
|
+
* @param defaultFeedsDir The path to the default feeds directory.
|
|
36
|
+
* @param schemaMap The map to populate with loaded schemas.
|
|
37
|
+
*/
|
|
38
|
+
public static async loadAllDefaultSchemas(defaultFeedsDir: string, schemaMap: Map<string, Map<string, ServerSchema>>): Promise<void> {
|
|
39
|
+
schemaMap.clear(); // Clear map for initial load from default directory
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const categoryDirs = await fs.readdir(defaultFeedsDir, { withFileTypes: true });
|
|
43
|
+
|
|
44
|
+
for (const categoryDir of categoryDirs) {
|
|
45
|
+
if (categoryDir.isDirectory()) {
|
|
46
|
+
const categoryName = categoryDir.name;
|
|
47
|
+
const categoryPath = path.join(defaultFeedsDir, categoryName);
|
|
48
|
+
const serverFiles = await fs.readdir(categoryPath);
|
|
49
|
+
const serverSchemas = new Map<string, ServerSchema>();
|
|
50
|
+
|
|
51
|
+
for (const file of serverFiles) {
|
|
52
|
+
if (file.endsWith('.json')) {
|
|
53
|
+
try {
|
|
54
|
+
const schemaFilePath = path.join(categoryPath, file);
|
|
55
|
+
const schema = await this.loadSchema(schemaFilePath);
|
|
56
|
+
if (schema) {
|
|
57
|
+
serverSchemas.set(file, schema); // file is serverName
|
|
58
|
+
Logger.debug(`Loaded schema '${file}' for category '${categoryName}' from default directory`);
|
|
59
|
+
}
|
|
60
|
+
} catch (error) { // Error already logged in loadSchema
|
|
61
|
+
Logger.error(`Skipping schema file ${file} in category ${categoryName} due to loading error.`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (serverSchemas.size > 0) {
|
|
66
|
+
schemaMap.set(categoryName, serverSchemas);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
Logger.error(`Error reading schemas from default directory ${defaultFeedsDir}:`, error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Loads schemas from an adhoc directory for a specific category.
|
|
77
|
+
* @param adhocSchemasDir The path to the adhoc schemas directory.
|
|
78
|
+
* @param categoryName The name of the category for these adhoc schemas.
|
|
79
|
+
* @param schemaMap The map to update with loaded adhoc schemas.
|
|
80
|
+
*/
|
|
81
|
+
public static async loadAdhocSchemas(adhocSchemasDir: string, categoryName: string, schemaMap: Map<string, Map<string, ServerSchema>>): Promise<void> {
|
|
82
|
+
try {
|
|
83
|
+
const serverFiles = await fs.readdir(adhocSchemasDir);
|
|
84
|
+
|
|
85
|
+
if (schemaMap.has(categoryName)) {
|
|
86
|
+
Logger.warn(`\x1b[33mAdhoc schema category '${categoryName}' (from dir: ${adhocSchemasDir}) conflicts with an existing category. Adhoc schemas in this category will override existing ones.\x1b[0m`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let serverSchemas = schemaMap.get(categoryName);
|
|
90
|
+
if (!serverSchemas) {
|
|
91
|
+
serverSchemas = new Map<string, ServerSchema>();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const file of serverFiles) {
|
|
95
|
+
if (file.endsWith('.json')) {
|
|
96
|
+
try {
|
|
97
|
+
const schemaFilePath = path.join(adhocSchemasDir, file);
|
|
98
|
+
const schema = await this.loadSchema(schemaFilePath);
|
|
99
|
+
if (schema) {
|
|
100
|
+
serverSchemas.set(file, schema); // file is serverName
|
|
101
|
+
Logger.debug(`Loaded adhoc schema '${file}' for category '${categoryName}'`);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) { // Error already logged in loadSchema
|
|
104
|
+
Logger.error(`Skipping adhoc schema file ${file} in category ${categoryName} due to loading error.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (serverSchemas.size > 0) {
|
|
110
|
+
schemaMap.set(categoryName, serverSchemas);
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
// This case should ideally be caught by the fs.access check in ServerSchemaProvider.initialize
|
|
114
|
+
Logger.error(`Error reading adhoc schemas from directory ${adhocSchemasDir} for category ${categoryName}:`, error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
import { ServerSchemaLoader } from './ServerSchemaLoader.js';
|
|
6
|
+
|
|
7
|
+
export interface ServerSchema {
|
|
8
|
+
schema: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ServerSchemaProvider {
|
|
12
|
+
private static instance: ServerSchemaProvider;
|
|
13
|
+
private schemaMap: Map<string, Map<string, ServerSchema>>;
|
|
14
|
+
private schemaLock: Promise<void> = Promise.resolve();
|
|
15
|
+
|
|
16
|
+
private constructor() {
|
|
17
|
+
this.schemaMap = new Map();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static getInstance(): ServerSchemaProvider {
|
|
21
|
+
if (!ServerSchemaProvider.instance) {
|
|
22
|
+
ServerSchemaProvider.instance = new ServerSchemaProvider();
|
|
23
|
+
// Initialize is now called with optional adhocSchemasDir,
|
|
24
|
+
// but getInstance is often called without it initially.
|
|
25
|
+
// The actual loading with adhoc dir will happen when MCPManager calls initialize.
|
|
26
|
+
}
|
|
27
|
+
return ServerSchemaProvider.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private async withLock<T>(operation: () => Promise<T>): Promise<T> {
|
|
31
|
+
const current = this.schemaLock;
|
|
32
|
+
let resolve: () => void;
|
|
33
|
+
this.schemaLock = new Promise<void>(r => resolve = r);
|
|
34
|
+
try {
|
|
35
|
+
await current;
|
|
36
|
+
return await operation();
|
|
37
|
+
} finally {
|
|
38
|
+
resolve!();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async initialize(adhocSchemasDir?: string): Promise<void> {
|
|
43
|
+
await this.withLock(async () => {
|
|
44
|
+
try {
|
|
45
|
+
// Create default feeds directory if it doesn't exist
|
|
46
|
+
await fs.mkdir(LOCAL_FEEDS_SCHEMA_DIR, { recursive: true });
|
|
47
|
+
|
|
48
|
+
// Load all schemas from the default feeds directory
|
|
49
|
+
await ServerSchemaLoader.loadAllDefaultSchemas(LOCAL_FEEDS_SCHEMA_DIR, this.schemaMap);
|
|
50
|
+
|
|
51
|
+
// Load schemas from adhoc directory if provided
|
|
52
|
+
if (adhocSchemasDir) {
|
|
53
|
+
try {
|
|
54
|
+
await fs.access(adhocSchemasDir); // Check if directory exists
|
|
55
|
+
const adhocCategoryName = path.basename(adhocSchemasDir);
|
|
56
|
+
Logger.info(`Loading adhoc schemas from: ${adhocSchemasDir} for category: ${adhocCategoryName}`);
|
|
57
|
+
await ServerSchemaLoader.loadAdhocSchemas(adhocSchemasDir, adhocCategoryName, this.schemaMap);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
60
|
+
Logger.warn(`Adhoc schemas directory not found: ${adhocSchemasDir}`);
|
|
61
|
+
} else {
|
|
62
|
+
Logger.error(`Error accessing adhoc schemas directory ${adhocSchemasDir}:`, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
Logger.error('Error during schema initialization:', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The actual loading methods (loadSchema, loadAllSchemas, loadAdhocSchemas) have been moved to ServerSchemaLoader.
|
|
74
|
+
// ServerSchemaProvider now delegates to ServerSchemaLoader for these operations.
|
|
75
|
+
|
|
76
|
+
async getSchema(categoryName: string, schemaFileName: string): Promise<ServerSchema | undefined> {
|
|
77
|
+
return await this.withLock(async () => {
|
|
78
|
+
const categorySchemas = this.schemaMap.get(categoryName);
|
|
79
|
+
if (!categorySchemas) {
|
|
80
|
+
Logger.debug(`No schemas found for category ${categoryName}`);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const schema = categorySchemas.get(schemaFileName);
|
|
84
|
+
if (!schema) {
|
|
85
|
+
Logger.debug(`Schema ${schemaFileName} not found in category ${categoryName}`);
|
|
86
|
+
}
|
|
87
|
+
return schema;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async reloadSchemas(): Promise<void> {
|
|
92
|
+
return await this.withLock(async () => {
|
|
93
|
+
// Reloading should re-evaluate both default and any configured adhoc directory
|
|
94
|
+
// For simplicity, we assume initialize would be called again if adhoc path changes.
|
|
95
|
+
// This reload will just reload from the paths known during the last full initialize.
|
|
96
|
+
await this.initialize(); // This will re-load default and adhoc if adhocSchemasDir was set
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -24,7 +24,6 @@ export interface RequirementStatus {
|
|
|
24
24
|
export interface MCPServerStatus {
|
|
25
25
|
installedStatus: Record<string, OperationStatus>; // client: installed
|
|
26
26
|
name: string;
|
|
27
|
-
tags?: string[];
|
|
28
27
|
error?: string;
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -48,7 +47,6 @@ export interface MCPServerCategory {
|
|
|
48
47
|
displayName: string;
|
|
49
48
|
description?: string;
|
|
50
49
|
type: 'local';
|
|
51
|
-
tags?: string[];
|
|
52
50
|
path?: string;
|
|
53
51
|
installationStatus?: InstallationStatus;
|
|
54
52
|
feedConfiguration?: FeedConfiguration;
|
|
@@ -123,6 +121,7 @@ export interface McpConfig {
|
|
|
123
121
|
dependencies?: DependencyConfig;
|
|
124
122
|
schemas?: string; // Path to the schema file
|
|
125
123
|
repository?: string; // Repository URL for the server
|
|
124
|
+
systemTags?: Record<string, string>; // System tags for the feed
|
|
126
125
|
installation: InstallationConfig;
|
|
127
126
|
}
|
|
128
127
|
|
|
@@ -151,8 +150,10 @@ export interface FeedConfiguration {
|
|
|
151
150
|
displayName: string;
|
|
152
151
|
description: string;
|
|
153
152
|
repository?: string;
|
|
153
|
+
PullRequest?: string; // Optional Pull Request link
|
|
154
154
|
requirements: RequirementConfig[];
|
|
155
155
|
mcpServers: McpConfig[];
|
|
156
|
+
systemTags?: Record<string, string>; // System tags for the feed
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
export interface ClientSettings {
|