imcp 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/.github/workflows/build.yml +28 -0
  2. package/README.md +21 -4
  3. package/dist/cli/commands/start.d.ts +2 -0
  4. package/dist/cli/commands/start.js +32 -0
  5. package/dist/cli/commands/sync.d.ts +2 -0
  6. package/dist/cli/commands/sync.js +17 -0
  7. package/dist/cli/index.js +0 -0
  8. package/dist/core/ConfigurationLoader.d.ts +32 -0
  9. package/dist/core/ConfigurationLoader.js +236 -0
  10. package/dist/core/ConfigurationProvider.d.ts +35 -0
  11. package/dist/core/ConfigurationProvider.js +375 -0
  12. package/dist/core/InstallationService.d.ts +50 -0
  13. package/dist/core/InstallationService.js +350 -0
  14. package/dist/core/MCPManager.d.ts +28 -0
  15. package/dist/core/MCPManager.js +188 -0
  16. package/dist/core/RequirementService.d.ts +40 -0
  17. package/dist/core/RequirementService.js +110 -0
  18. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  19. package/dist/core/ServerSchemaLoader.js +43 -0
  20. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  21. package/dist/core/ServerSchemaProvider.js +120 -0
  22. package/dist/core/constants.d.ts +47 -0
  23. package/dist/core/constants.js +94 -0
  24. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  25. package/dist/core/installers/BaseInstaller.js +253 -0
  26. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  27. package/dist/core/installers/ClientInstaller.js +564 -0
  28. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  29. package/dist/core/installers/CommandInstaller.js +173 -0
  30. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  31. package/dist/core/installers/GeneralInstaller.js +85 -0
  32. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  33. package/dist/core/installers/InstallerFactory.js +97 -0
  34. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  35. package/dist/core/installers/NpmInstaller.js +127 -0
  36. package/dist/core/installers/PipInstaller.d.ts +28 -0
  37. package/dist/core/installers/PipInstaller.js +127 -0
  38. package/dist/core/installers/RequirementInstaller.d.ts +33 -0
  39. package/dist/core/installers/RequirementInstaller.js +3 -0
  40. package/dist/core/types.d.ts +166 -0
  41. package/dist/core/types.js +16 -0
  42. package/dist/services/InstallRequestValidator.d.ts +21 -0
  43. package/dist/services/InstallRequestValidator.js +99 -0
  44. package/dist/web/public/index.html +1 -1
  45. package/dist/web/public/js/modal/installHandler.js +227 -0
  46. package/dist/web/public/js/modal/loadingUI.js +74 -0
  47. package/dist/web/public/js/modal/messageQueue.js +101 -45
  48. package/dist/web/public/js/modal/modalUI.js +214 -0
  49. package/dist/web/public/js/modal/version.js +20 -0
  50. package/dist/web/public/onboard.html +4 -4
  51. package/package.json +1 -1
  52. package/src/web/public/index.html +1 -1
  53. package/src/web/public/onboard.html +4 -4
  54. package/wiki/Installation.md +3 -0
  55. package/wiki/Publish.md +3 -0
  56. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  57. package/dist/core/onboard/InstallOperationManager.js +0 -144
@@ -0,0 +1,28 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main] # Or your default branch
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ strategy:
12
+ matrix:
13
+ node-version: [20.x, 22.x] # Specify Node.js versions to test against
14
+
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+
18
+ - name: Use Node.js ${{ matrix.node-version }}
19
+ uses: actions/setup-node@v3
20
+ with:
21
+ node-version: ${{ matrix.node-version }}
22
+ cache: "npm"
23
+
24
+ - name: Install dependencies
25
+ run: npm ci
26
+
27
+ - name: Build project
28
+ run: npm run build
package/README.md CHANGED
@@ -8,18 +8,22 @@ IMCP allows you to:
8
8
 
9
9
  - Discover and install available MCP servers to your local agents
10
10
  - Run a local UI interface with simple click experience to manage MCP servers
11
- - (in progress) Distribute your own MCP servers to others
11
+ - Distribute your own MCP servers to others
12
12
 
13
13
  ## Get started
14
+
14
15
  - Quick usage with latest version
16
+
15
17
  ```
16
18
  npx -y imcp@latest serve
17
19
  ```
18
20
 
19
21
  - Or install it globally
22
+
20
23
  ```bash
21
24
  npm install -g imcp
22
25
  ```
26
+
23
27
  ```
24
28
  imcp serve
25
29
  ```
@@ -35,22 +39,35 @@ imcp serve
35
39
  Starts a local web interface for managing MCP servers.
36
40
 
37
41
  ```bash
38
- imcp serve [options]
42
+ npx -y imcp@latest serve [options]
39
43
  ```
40
44
 
41
45
  Options:
46
+
42
47
  - `-p, --port <port>`: Port to run the server on (default: 3000)
43
48
  - `-f, --feed-file <filepath>`: Path to a custom feed configuration file
49
+ - `-s, --schema-directory <schemaDir>`: Path to a directory containing adhoc schema files
44
50
 
45
51
  Example:
52
+
46
53
  ```bash
47
54
  # Start the web interface on port 8080
48
- imcp serve --port 8080
55
+ npx -y imcp@latest serve --port 8080
49
56
 
50
57
  # Start with a custom feed configuration file
51
- imcp serve --feed-file ./custom-feed.json
58
+ npx -y imcp@latest serve --feed-file ./custom-feed.json
59
+
60
+ # Start with a custom feed configuration file and adhoc schema files.
61
+ npx -y imcp@latest serve --feed-file ./custom-feed.json --schema-directory ./feeds/schemas/ai-coder-tools
52
62
  ```
53
63
 
64
+ ## MCP Installation and Publish
65
+
66
+ For details on how to install and publish MCP servers, please refer to the following documents:
67
+
68
+ - [Installation Guide](wiki/Installation.md)
69
+ - [Publishing Guide](wiki/Publish.md)
70
+
54
71
  ## License
55
72
 
56
73
  MIT
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function createStartCommand(): Command;
@@ -0,0 +1,32 @@
1
+ import { Command } from 'commander';
2
+ import { startWebServer } from '../../web/server.js';
3
+ import { mcpManager } from '../../core/MCPManager.js';
4
+ export function createStartCommand() {
5
+ return new Command('start')
6
+ .description('Start local web interface')
7
+ .option('-p, --port <port>', 'Port to run the server on', '3000')
8
+ .action(async (options) => {
9
+ try {
10
+ // Sync feeds before start the local UI
11
+ await mcpManager.syncFeeds();
12
+ // Ensure MCP manager is initialized before starting the web server
13
+ await mcpManager.initialize();
14
+ const port = parseInt(options.port, 10);
15
+ if (isNaN(port) || port < 1 || port > 65535) {
16
+ throw new Error('Invalid port number');
17
+ }
18
+ await startWebServer(port);
19
+ // The server is running, keep the process alive
20
+ process.on('SIGINT', () => {
21
+ console.log('\nShutting down server...');
22
+ process.exit(0);
23
+ });
24
+ }
25
+ catch (error) {
26
+ const message = error instanceof Error ? error.message : 'Unknown error';
27
+ console.error('Failed to start web server:', message);
28
+ process.exit(1);
29
+ }
30
+ });
31
+ }
32
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function createSyncCommand(): Command;
@@ -0,0 +1,17 @@
1
+ import { Command } from 'commander';
2
+ import { serverService } from '../../services/ServerService.js';
3
+ export function createSyncCommand() {
4
+ return new Command('sync')
5
+ .description('Sync MCP server configurations from remote feed source')
6
+ .action(async () => {
7
+ try {
8
+ await serverService.syncFeeds();
9
+ }
10
+ catch (error) {
11
+ const message = error instanceof Error ? error.message : 'Unknown error';
12
+ console.error('Error syncing configurations:', message);
13
+ process.exit(1);
14
+ }
15
+ });
16
+ }
17
+ //# sourceMappingURL=sync.js.map
package/dist/cli/index.js CHANGED
File without changes
@@ -0,0 +1,32 @@
1
+ import { MCPConfiguration } from './types.js';
2
+ export declare class ConfigurationLoader {
3
+ /**
4
+ * Updates the installed status for a server and client combination
5
+ */
6
+ private static updateServerInstalledStatus;
7
+ /**
8
+ * Removes a client's status from a server
9
+ */
10
+ private static removeClientStatus;
11
+ /**
12
+ * Synchronizes server categories with client MCP settings.
13
+ * Uses clientMCPSettings as source of truth for installation status.
14
+ */
15
+ static syncServerCategoriesWithClientSettings(configuration: MCPConfiguration): MCPConfiguration;
16
+ /**
17
+ * Initializes installation status for a feed configuration
18
+ */
19
+ private static initializeInstallationStatus;
20
+ /**
21
+ * Synchronizes server categories with feeds
22
+ */
23
+ private static syncServerCategoriesWithFeeds;
24
+ /**
25
+ * Loads feed configurations into the MCP configuration
26
+ */
27
+ static loadFeedsIntoConfiguration(configuration: MCPConfiguration, feedFile?: string): Promise<MCPConfiguration>;
28
+ /**
29
+ * Loads MCP client settings into the configuration
30
+ */
31
+ static loadClientMCPSettings(configuration: MCPConfiguration): Promise<MCPConfiguration>;
32
+ }
@@ -0,0 +1,236 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { LOCAL_FEEDS_DIR, SUPPORTED_CLIENTS } from './constants.js';
4
+ import { Logger } from '../utils/logger.js';
5
+ import { readJsonFile } from '../utils/clientUtils.js';
6
+ export class ConfigurationLoader {
7
+ /**
8
+ * Updates the installed status for a server and client combination
9
+ */
10
+ static updateServerInstalledStatus(serverStatus, clientName, operationStatus) {
11
+ if (!serverStatus.installedStatus) {
12
+ serverStatus.installedStatus = {};
13
+ }
14
+ serverStatus.installedStatus[clientName] = operationStatus;
15
+ }
16
+ /**
17
+ * Removes a client's status from a server
18
+ */
19
+ static removeClientStatus(serverStatus, clientName) {
20
+ if (serverStatus.installedStatus && serverStatus.installedStatus[clientName]) {
21
+ delete serverStatus.installedStatus[clientName];
22
+ }
23
+ }
24
+ /**
25
+ * Synchronizes server categories with client MCP settings.
26
+ * Uses clientMCPSettings as source of truth for installation status.
27
+ */
28
+ static syncServerCategoriesWithClientSettings(configuration) {
29
+ if (!configuration.clientMCPSettings) {
30
+ return configuration;
31
+ }
32
+ configuration.localServerCategories = configuration.localServerCategories.map(category => {
33
+ if (!category.installationStatus?.serversStatus) {
34
+ return category;
35
+ }
36
+ const updatedServerStatus = { ...category.installationStatus.serversStatus };
37
+ const clientSettings = configuration.clientMCPSettings;
38
+ for (const [clientName, settings] of Object.entries(clientSettings)) {
39
+ const clientServers = clientName === 'GithubCopilot'
40
+ ? settings.servers || {}
41
+ : settings.mcpServers || {};
42
+ Object.keys(updatedServerStatus).forEach(serverName => {
43
+ if (clientServers[serverName]) {
44
+ if (!updatedServerStatus[serverName].installedStatus[clientName]) {
45
+ const operationStatus = {
46
+ status: 'completed',
47
+ type: 'install',
48
+ target: 'server',
49
+ message: `Server ${serverName} is configured for client ${clientName}`
50
+ };
51
+ ConfigurationLoader.updateServerInstalledStatus(updatedServerStatus[serverName], clientName, operationStatus);
52
+ }
53
+ }
54
+ else {
55
+ ConfigurationLoader.removeClientStatus(updatedServerStatus[serverName], clientName);
56
+ }
57
+ });
58
+ }
59
+ return {
60
+ ...category,
61
+ installationStatus: {
62
+ ...category.installationStatus,
63
+ serversStatus: updatedServerStatus,
64
+ lastUpdated: new Date().toISOString()
65
+ }
66
+ };
67
+ });
68
+ return configuration;
69
+ }
70
+ /**
71
+ * Initializes installation status for a feed configuration
72
+ */
73
+ static initializeInstallationStatus(feedConfig) {
74
+ const requirementsStatus = {};
75
+ const serversStatus = {};
76
+ if (feedConfig) {
77
+ if (feedConfig.requirements) {
78
+ for (const req of feedConfig.requirements) {
79
+ requirementsStatus[req.name] = {
80
+ name: req.name,
81
+ type: req.type,
82
+ installed: false,
83
+ version: req.version,
84
+ error: undefined
85
+ };
86
+ }
87
+ }
88
+ if (feedConfig.mcpServers) {
89
+ for (const mcp of feedConfig.mcpServers) {
90
+ serversStatus[mcp.name] = {
91
+ name: mcp.name,
92
+ error: undefined,
93
+ installedStatus: {}
94
+ };
95
+ }
96
+ }
97
+ }
98
+ return {
99
+ requirementsStatus,
100
+ serversStatus,
101
+ lastUpdated: new Date().toISOString()
102
+ };
103
+ }
104
+ /**
105
+ * Synchronizes server categories with feeds
106
+ */
107
+ static async syncServerCategoriesWithFeeds(configuration) {
108
+ // Filter out categories that don't have corresponding feeds and update existing ones
109
+ configuration.localServerCategories = configuration.localServerCategories
110
+ .filter(server => configuration.feeds[server.name])
111
+ .map(server => {
112
+ server.feedConfiguration = configuration.feeds[server.name];
113
+ if (!server.installationStatus ||
114
+ !server.installationStatus.requirementsStatus ||
115
+ Object.keys(server.installationStatus.requirementsStatus).length === 0 ||
116
+ !server.installationStatus.serversStatus ||
117
+ Object.keys(server.installationStatus.serversStatus).length < Object.keys(server.feedConfiguration?.mcpServers || []).length) {
118
+ server.installationStatus = ConfigurationLoader.initializeInstallationStatus(server.feedConfiguration);
119
+ }
120
+ return server;
121
+ });
122
+ // Add new categories for feeds that don't have a corresponding category
123
+ const existingServerNames = new Set(configuration.localServerCategories.map(category => category.name));
124
+ for (const [feedName, feedConfig] of Object.entries(configuration.feeds)) {
125
+ if (!existingServerNames.has(feedName)) {
126
+ const newServerCategory = {
127
+ name: feedName,
128
+ displayName: feedConfig.displayName || feedName,
129
+ type: 'local',
130
+ description: feedConfig.description || `Local MCP server category: ${feedName}`,
131
+ installationStatus: ConfigurationLoader.initializeInstallationStatus(feedConfig),
132
+ feedConfiguration: feedConfig
133
+ };
134
+ configuration.localServerCategories.push(newServerCategory);
135
+ console.log(`Created new local server entry for feed: ${feedName}`);
136
+ }
137
+ }
138
+ return configuration;
139
+ }
140
+ /**
141
+ * Loads feed configurations into the MCP configuration
142
+ */
143
+ static async loadFeedsIntoConfiguration(configuration, feedFile) {
144
+ try {
145
+ await fs.mkdir(LOCAL_FEEDS_DIR, { recursive: true });
146
+ const feeds = {};
147
+ // Load provided feed file if specified
148
+ if (feedFile) {
149
+ try {
150
+ const content = await fs.readFile(feedFile, 'utf8');
151
+ const config = JSON.parse(content);
152
+ if (config && config.name) {
153
+ feeds[config.name] = config;
154
+ console.log(`Loaded feed configuration from provided file: ${feedFile}`);
155
+ }
156
+ }
157
+ catch (error) {
158
+ console.log(`Error loading feed configuration from provided file ${feedFile}:`, error);
159
+ }
160
+ }
161
+ // Load feeds from LOCAL_FEEDS_DIR
162
+ const files = await fs.readdir(LOCAL_FEEDS_DIR);
163
+ const jsonFiles = files.filter(file => file.endsWith('.json'));
164
+ if (jsonFiles.length === 0 && !feedFile) {
165
+ console.log(`No feed configuration files found in ${LOCAL_FEEDS_DIR}`);
166
+ return configuration;
167
+ }
168
+ for (const file of jsonFiles) {
169
+ try {
170
+ const filePath = path.join(LOCAL_FEEDS_DIR, file);
171
+ const content = await fs.readFile(filePath, 'utf8');
172
+ const config = JSON.parse(content);
173
+ if (config && config.name) {
174
+ // If feed exists from provided file, skip the local one
175
+ if (!feeds[config.name]) {
176
+ feeds[config.name] = config;
177
+ }
178
+ else {
179
+ console.log(`Skipping local feed ${config.name} as it was provided via --feed-file`);
180
+ }
181
+ }
182
+ }
183
+ catch (error) {
184
+ console.warn(`Error loading feed configuration from ${file}:`, error);
185
+ }
186
+ }
187
+ configuration.feeds = feeds;
188
+ return await ConfigurationLoader.syncServerCategoriesWithFeeds(configuration);
189
+ }
190
+ catch (error) {
191
+ console.error("Error loading feed configurations:", error);
192
+ throw error;
193
+ }
194
+ }
195
+ /**
196
+ * Loads MCP client settings into the configuration
197
+ */
198
+ static async loadClientMCPSettings(configuration) {
199
+ try {
200
+ Logger.debug('Starting to load MCP client settings...');
201
+ const settings = {};
202
+ for (const [clientName, clientSettings] of Object.entries(SUPPORTED_CLIENTS)) {
203
+ const settingPath = process.env.CODE_INSIDERS
204
+ ? clientSettings.codeInsiderSettingPath
205
+ : clientSettings.codeSettingPath;
206
+ try {
207
+ let content = await readJsonFile(settingPath, true);
208
+ if (clientName === 'GithubCopilot') {
209
+ if (!content.mcp) {
210
+ content = {
211
+ servers: {},
212
+ inputs: []
213
+ };
214
+ }
215
+ else {
216
+ content = content.mcp;
217
+ }
218
+ }
219
+ settings[clientName] = content;
220
+ Logger.debug(`Successfully loaded MCP settings for ${clientName}`);
221
+ }
222
+ catch (error) {
223
+ Logger.debug(`Warning: Could not load MCP settings for client ${clientName}: ${error instanceof Error ? error.message : String(error)}`);
224
+ settings[clientName] = {};
225
+ }
226
+ }
227
+ configuration.clientMCPSettings = settings;
228
+ return ConfigurationLoader.syncServerCategoriesWithClientSettings(configuration);
229
+ }
230
+ catch (error) {
231
+ Logger.error('Error loading client MCP settings:', error);
232
+ throw error;
233
+ }
234
+ }
235
+ }
236
+ //# sourceMappingURL=ConfigurationLoader.js.map
@@ -0,0 +1,35 @@
1
+ import { MCPServerCategory, FeedConfiguration, InstallationStatus, RequirementStatus, MCPServerStatus, OperationStatus, McpConfig } from './types.js';
2
+ export declare class ConfigurationProvider {
3
+ private static instance;
4
+ private configPath;
5
+ private configuration;
6
+ private configLock;
7
+ private tempDir;
8
+ private constructor();
9
+ static getInstance(): ConfigurationProvider;
10
+ private withLock;
11
+ initialize(feedFile?: string): Promise<void>;
12
+ private saveConfiguration;
13
+ getServerCategories(): Promise<MCPServerCategory[]>;
14
+ getServerCategory(categoryName: string): Promise<MCPServerCategory | undefined>;
15
+ getClientMcpSettings(): Promise<Record<string, Record<string, any>> | undefined>;
16
+ getFeedConfiguration(categoryName: string): Promise<FeedConfiguration | undefined>;
17
+ getServerMcpConfig(categoryName: string, serverName: string): Promise<McpConfig | undefined>;
18
+ getInstallationStatus(categoryName: string): Promise<InstallationStatus | undefined>;
19
+ getServerStatus(categoryName: string, serverName: string): Promise<MCPServerStatus | undefined>;
20
+ getRequirementStatus(categoryName: string, requirementName: string): Promise<RequirementStatus | undefined>;
21
+ updateInstallationStatus(categoryName: string, requirementStatus: Record<string, RequirementStatus>, serverStatus: Record<string, MCPServerStatus>): Promise<boolean>;
22
+ updateRequirementStatus(categoryName: string, requirementName: string, status: RequirementStatus): Promise<boolean>;
23
+ updateRequirementOperationStatus(categoryName: string, requirementName: string, operationStatus: OperationStatus): Promise<boolean>;
24
+ updateServerStatus(categoryName: string, serverName: string, status: MCPServerStatus): Promise<boolean>;
25
+ updateServerOperationStatus(categoryName: string, serverName: string, clientName: string, operationStatus: OperationStatus): Promise<boolean>;
26
+ isRequirementsReady(categoryName: string, serverName: string): Promise<boolean>;
27
+ GetServerRequirementStatus(categoryName: string, serverName: string): Promise<RequirementStatus[]>;
28
+ isServerReady(categoryName: string, serverName: string, clients: string[]): Promise<boolean>;
29
+ syncFeeds(): Promise<void>;
30
+ private loadFeedsIntoConfiguration;
31
+ private loadClientMCPSettings;
32
+ reloadClientMCPSettings(): Promise<void>;
33
+ removeServerFromClientMCPSettings(serverName: string, target?: string): Promise<void>;
34
+ }
35
+ export declare const configProvider: ConfigurationProvider;