imcp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.github/ISSUE_TEMPLATE/JitAccess.yml +28 -0
  2. package/.github/acl/access.yml +20 -0
  3. package/.github/compliance/inventory.yml +5 -0
  4. package/.github/policies/jit.yml +19 -0
  5. package/README.md +137 -0
  6. package/dist/cli/commands/install.d.ts +2 -0
  7. package/dist/cli/commands/install.js +105 -0
  8. package/dist/cli/commands/list.d.ts +2 -0
  9. package/dist/cli/commands/list.js +90 -0
  10. package/dist/cli/commands/pull.d.ts +2 -0
  11. package/dist/cli/commands/pull.js +17 -0
  12. package/dist/cli/commands/serve.d.ts +2 -0
  13. package/dist/cli/commands/serve.js +32 -0
  14. package/dist/cli/commands/start.d.ts +2 -0
  15. package/dist/cli/commands/start.js +32 -0
  16. package/dist/cli/commands/sync.d.ts +2 -0
  17. package/dist/cli/commands/sync.js +17 -0
  18. package/dist/cli/commands/uninstall.d.ts +2 -0
  19. package/dist/cli/commands/uninstall.js +39 -0
  20. package/dist/cli/index.d.ts +2 -0
  21. package/dist/cli/index.js +114 -0
  22. package/dist/core/ConfigurationProvider.d.ts +31 -0
  23. package/dist/core/ConfigurationProvider.js +416 -0
  24. package/dist/core/InstallationService.d.ts +17 -0
  25. package/dist/core/InstallationService.js +144 -0
  26. package/dist/core/MCPManager.d.ts +17 -0
  27. package/dist/core/MCPManager.js +98 -0
  28. package/dist/core/RequirementService.d.ts +45 -0
  29. package/dist/core/RequirementService.js +123 -0
  30. package/dist/core/constants.d.ts +29 -0
  31. package/dist/core/constants.js +55 -0
  32. package/dist/core/installers/BaseInstaller.d.ts +73 -0
  33. package/dist/core/installers/BaseInstaller.js +247 -0
  34. package/dist/core/installers/ClientInstaller.d.ts +17 -0
  35. package/dist/core/installers/ClientInstaller.js +307 -0
  36. package/dist/core/installers/CommandInstaller.d.ts +36 -0
  37. package/dist/core/installers/CommandInstaller.js +170 -0
  38. package/dist/core/installers/GeneralInstaller.d.ts +32 -0
  39. package/dist/core/installers/GeneralInstaller.js +87 -0
  40. package/dist/core/installers/InstallerFactory.d.ts +52 -0
  41. package/dist/core/installers/InstallerFactory.js +95 -0
  42. package/dist/core/installers/NpmInstaller.d.ts +25 -0
  43. package/dist/core/installers/NpmInstaller.js +123 -0
  44. package/dist/core/installers/PipInstaller.d.ts +25 -0
  45. package/dist/core/installers/PipInstaller.js +114 -0
  46. package/dist/core/installers/RequirementInstaller.d.ts +32 -0
  47. package/dist/core/installers/RequirementInstaller.js +3 -0
  48. package/dist/core/installers/index.d.ts +6 -0
  49. package/dist/core/installers/index.js +7 -0
  50. package/dist/core/types.d.ts +152 -0
  51. package/dist/core/types.js +16 -0
  52. package/dist/index.d.ts +11 -0
  53. package/dist/index.js +19 -0
  54. package/dist/services/InstallRequestValidator.d.ts +21 -0
  55. package/dist/services/InstallRequestValidator.js +99 -0
  56. package/dist/services/ServerService.d.ts +47 -0
  57. package/dist/services/ServerService.js +145 -0
  58. package/dist/utils/UpdateCheckTracker.d.ts +39 -0
  59. package/dist/utils/UpdateCheckTracker.js +80 -0
  60. package/dist/utils/clientUtils.d.ts +29 -0
  61. package/dist/utils/clientUtils.js +105 -0
  62. package/dist/utils/feedUtils.d.ts +5 -0
  63. package/dist/utils/feedUtils.js +29 -0
  64. package/dist/utils/githubAuth.d.ts +1 -0
  65. package/dist/utils/githubAuth.js +123 -0
  66. package/dist/utils/logger.d.ts +14 -0
  67. package/dist/utils/logger.js +90 -0
  68. package/dist/utils/osUtils.d.ts +16 -0
  69. package/dist/utils/osUtils.js +235 -0
  70. package/dist/web/public/css/modal.css +250 -0
  71. package/dist/web/public/css/notifications.css +70 -0
  72. package/dist/web/public/index.html +157 -0
  73. package/dist/web/public/js/api.js +213 -0
  74. package/dist/web/public/js/modal.js +572 -0
  75. package/dist/web/public/js/notifications.js +99 -0
  76. package/dist/web/public/js/serverCategoryDetails.js +210 -0
  77. package/dist/web/public/js/serverCategoryList.js +82 -0
  78. package/dist/web/public/modal.html +61 -0
  79. package/dist/web/public/styles.css +155 -0
  80. package/dist/web/server.d.ts +5 -0
  81. package/dist/web/server.js +150 -0
  82. package/package.json +53 -0
  83. package/src/cli/commands/install.ts +140 -0
  84. package/src/cli/commands/list.ts +112 -0
  85. package/src/cli/commands/pull.ts +16 -0
  86. package/src/cli/commands/serve.ts +37 -0
  87. package/src/cli/commands/uninstall.ts +54 -0
  88. package/src/cli/index.ts +127 -0
  89. package/src/core/ConfigurationProvider.ts +489 -0
  90. package/src/core/InstallationService.ts +173 -0
  91. package/src/core/MCPManager.ts +134 -0
  92. package/src/core/RequirementService.ts +147 -0
  93. package/src/core/constants.ts +61 -0
  94. package/src/core/installers/BaseInstaller.ts +292 -0
  95. package/src/core/installers/ClientInstaller.ts +423 -0
  96. package/src/core/installers/CommandInstaller.ts +185 -0
  97. package/src/core/installers/GeneralInstaller.ts +89 -0
  98. package/src/core/installers/InstallerFactory.ts +109 -0
  99. package/src/core/installers/NpmInstaller.ts +128 -0
  100. package/src/core/installers/PipInstaller.ts +121 -0
  101. package/src/core/installers/RequirementInstaller.ts +38 -0
  102. package/src/core/installers/index.ts +9 -0
  103. package/src/core/types.ts +163 -0
  104. package/src/index.ts +44 -0
  105. package/src/services/InstallRequestValidator.ts +112 -0
  106. package/src/services/ServerService.ts +181 -0
  107. package/src/utils/UpdateCheckTracker.ts +86 -0
  108. package/src/utils/clientUtils.ts +112 -0
  109. package/src/utils/feedUtils.ts +31 -0
  110. package/src/utils/githubAuth.ts +142 -0
  111. package/src/utils/logger.ts +101 -0
  112. package/src/utils/osUtils.ts +250 -0
  113. package/src/web/public/css/modal.css +250 -0
  114. package/src/web/public/css/notifications.css +70 -0
  115. package/src/web/public/index.html +157 -0
  116. package/src/web/public/js/api.js +213 -0
  117. package/src/web/public/js/modal.js +572 -0
  118. package/src/web/public/js/notifications.js +99 -0
  119. package/src/web/public/js/serverCategoryDetails.js +210 -0
  120. package/src/web/public/js/serverCategoryList.js +82 -0
  121. package/src/web/public/modal.html +61 -0
  122. package/src/web/public/styles.css +155 -0
  123. package/src/web/server.ts +195 -0
  124. package/tsconfig.json +18 -0
@@ -0,0 +1,195 @@
1
+ import express, { Request, Response } from 'express';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { SUPPORTED_CLIENT_NAMES } from '../core/constants.js';
5
+ import { serverService } from '../services/ServerService.js';
6
+ import { openBrowser } from '../utils/osUtils.js';
7
+ import { ServerInstallOptions } from '../core/types.js';
8
+ import { Logger } from '../utils/logger.js';
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ const app = express();
12
+
13
+ // Middleware
14
+ app.use(express.static(path.join(__dirname, 'public')));
15
+ app.use(express.json());
16
+
17
+ // API Routes
18
+ interface ListQueryParams {
19
+ local?: string;
20
+ }
21
+
22
+ export interface InstallServersRequestBody {
23
+ serverList: Record<string, ServerInstallOptions>;
24
+ }
25
+
26
+ interface UninstallServersRequestBody {
27
+ serverList: string[];
28
+ }
29
+
30
+ interface ApiResponse<T> {
31
+ success: boolean;
32
+ data?: T;
33
+ error?: string;
34
+ }
35
+
36
+
37
+ // Get available targets
38
+ app.get('/api/targets', async (req: Request, res: Response) => {
39
+ try {
40
+ const response: ApiResponse<string[]> = {
41
+ success: true,
42
+ data: SUPPORTED_CLIENT_NAMES
43
+ };
44
+ res.json(response);
45
+ } catch (error) {
46
+ const message = error instanceof Error ? error.message : 'Unknown error';
47
+ res.status(500).json({
48
+ success: false,
49
+ error: message
50
+ });
51
+ }
52
+ });
53
+
54
+ // List server categories
55
+ app.get('/api/categories', async (req: Request<{}, {}, {}, ListQueryParams>, res: Response) => {
56
+ try {
57
+ const { local } = req.query;
58
+ const servers = await serverService.listServerCategories({
59
+ local: local !== 'false'
60
+ });
61
+
62
+ const response: ApiResponse<typeof servers> = {
63
+ success: true,
64
+ data: servers
65
+ };
66
+
67
+ res.json(response);
68
+ } catch (error) {
69
+ const message = error instanceof Error ? error.message : 'Unknown error';
70
+ res.status(500).json({
71
+ success: false,
72
+ error: message
73
+ });
74
+ }
75
+ });
76
+
77
+ // Get categories data (including feed configuration)
78
+ app.get('/api/categories/:categoryName', async (req: Request<{ categoryName: string }>, res: Response) => {
79
+ try {
80
+ const { categoryName } = req.params;
81
+ const serverData = await serverService.getServerCategory(categoryName);
82
+
83
+ if (!serverData) {
84
+ return res.status(404).json({
85
+ success: false,
86
+ error: `Server category ${categoryName} not found`
87
+ });
88
+ }
89
+
90
+ const response: ApiResponse<any> = {
91
+ success: true,
92
+ data: serverData
93
+ };
94
+ res.json(response);
95
+ } catch (error) {
96
+ const message = error instanceof Error ? error.message : 'Unknown error';
97
+ res.status(500).json({
98
+ success: false,
99
+ error: `Failed to get server category data for ${req.params.categoryName}: ${message}`
100
+ });
101
+ }
102
+ });
103
+
104
+ // Install servers for a category
105
+ app.post('/api/categories/:categoryName/install', async (req: Request<{ categoryName: string }, {}, InstallServersRequestBody>, res: Response) => {
106
+ try {
107
+ const { categoryName } = req.params;
108
+ const { serverList } = req.body;
109
+
110
+ if (!serverList || Object.keys(serverList).length === 0) {
111
+ return res.status(400).json({
112
+ success: false,
113
+ error: 'Invalid server list provided'
114
+ });
115
+ }
116
+
117
+ const results = await Promise.all(
118
+ Object.entries(serverList).map(([serverName, options]) => serverService.installMcpServer(categoryName, serverName, options))
119
+ );
120
+
121
+ const { success, messages } = serverService.formatOperationResults(results);
122
+
123
+ const response: ApiResponse<{ messages: string[] }> = {
124
+ success,
125
+ data: { messages }
126
+ };
127
+
128
+ res.json(response);
129
+ } catch (error) {
130
+ const message = error instanceof Error ? error.message : 'Unknown error';
131
+ res.status(500).json({
132
+ success: false,
133
+ error: `Failed to install server for ${req.params.categoryName}: ${message}`
134
+ });
135
+ }
136
+ });
137
+
138
+ // Uninstall tools from a server
139
+ app.post('/api/categories/:categoryName/uninstall', async (req: Request<{ categoryName: string }, {}, UninstallServersRequestBody>, res: Response) => {
140
+ try {
141
+ const { categoryName } = req.params;
142
+ const { serverList } = req.body;
143
+
144
+ if (!Array.isArray(serverList) || serverList.length === 0) {
145
+ return res.status(400).json({
146
+ success: false,
147
+ error: 'Invalid tool list provided'
148
+ });
149
+ }
150
+
151
+ const results = await Promise.all(
152
+ serverList.map(serverName => serverService.uninstallMcpServer(categoryName, serverName))
153
+ );
154
+
155
+ const { success, messages } = serverService.formatOperationResults(results);
156
+
157
+ const response: ApiResponse<{ messages: string[] }> = {
158
+ success,
159
+ data: { messages }
160
+ };
161
+
162
+ res.json(response);
163
+ } catch (error) {
164
+ const message = error instanceof Error ? error.message : 'Unknown error';
165
+ res.status(500).json({
166
+ success: false,
167
+ error: `Failed to uninstall servers from ${req.params.categoryName}: ${message}`
168
+ });
169
+ }
170
+ });
171
+
172
+ export async function startWebServer(port = 3000): Promise<void> {
173
+ return new Promise((resolve, reject) => {
174
+ const server = app.listen(port, () => {
175
+ const url = `http://localhost:${port}`;
176
+ Logger.log(`IMCP web interface running at ${url}`);
177
+
178
+ // Open the URL in the default browser
179
+ openBrowser(url).catch(err => {
180
+ console.warn(`Failed to open browser: ${err.message}`);
181
+ });
182
+
183
+ resolve();
184
+ });
185
+
186
+ server.on('error', (error) => {
187
+ reject(error);
188
+ });
189
+ });
190
+ }
191
+
192
+ // Allow running directly
193
+ if (import.meta.url === `file://${process.argv[1]}`) {
194
+ startWebServer().catch(console.error);
195
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "sourceMap": true,
14
+ "resolveJsonModule": true
15
+ },
16
+ "include": ["src/**/*"],
17
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
18
+ }