imcp 0.0.12 → 0.0.14
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/core/ConfigurationProvider.d.ts +2 -1
- package/dist/core/ConfigurationProvider.js +20 -24
- package/dist/core/InstallationService.d.ts +17 -0
- package/dist/core/InstallationService.js +127 -61
- package/dist/core/MCPManager.d.ts +1 -0
- package/dist/core/MCPManager.js +3 -0
- package/dist/core/RequirementService.d.ts +4 -4
- package/dist/core/RequirementService.js +11 -7
- package/dist/core/ServerSchemaProvider.d.ts +1 -1
- package/dist/core/ServerSchemaProvider.js +15 -10
- package/dist/core/constants.d.ts +3 -0
- package/dist/core/constants.js +4 -1
- package/dist/core/installers/clients/ClientInstaller.js +58 -40
- package/dist/core/installers/requirements/PipInstaller.js +10 -5
- package/dist/core/onboard/FeedOnboardService.d.ts +35 -0
- package/dist/core/onboard/FeedOnboardService.js +137 -0
- package/dist/core/types.d.ts +6 -1
- package/dist/core/validators/FeedValidator.d.ts +13 -0
- package/dist/core/validators/FeedValidator.js +27 -0
- package/dist/services/ServerService.d.ts +5 -0
- package/dist/services/ServerService.js +15 -0
- package/dist/utils/githubAuth.js +0 -10
- package/dist/utils/githubUtils.d.ts +16 -0
- package/dist/utils/githubUtils.js +55 -39
- package/dist/web/contract/serverContract.d.ts +64 -0
- package/dist/web/contract/serverContract.js +2 -0
- package/dist/web/public/css/detailsWidget.css +157 -32
- package/dist/web/public/css/onboard.css +44 -0
- package/dist/web/public/css/serverDetails.css +35 -19
- package/dist/web/public/index.html +16 -10
- package/dist/web/public/js/detailsWidget.js +43 -40
- package/dist/web/public/js/modal/index.js +58 -0
- package/dist/web/public/js/modal/installHandler.js +227 -0
- package/dist/web/public/js/modal/installModal.js +163 -0
- package/dist/web/public/js/modal/installation.js +281 -0
- package/dist/web/public/js/modal/loadingModal.js +52 -0
- package/dist/web/public/js/modal/loadingUI.js +74 -0
- package/dist/web/public/js/modal/messageQueue.js +112 -0
- package/dist/web/public/js/modal/modalSetup.js +512 -0
- package/dist/web/public/js/modal/modalUI.js +214 -0
- package/dist/web/public/js/modal/modalUtils.js +49 -0
- package/dist/web/public/js/modal/version.js +20 -0
- package/dist/web/public/js/modal/versionUtils.js +20 -0
- package/dist/web/public/js/modal.js +25 -1041
- package/dist/web/public/js/onboard/formProcessor.js +309 -0
- package/dist/web/public/js/onboard/index.js +131 -0
- package/dist/web/public/js/onboard/state.js +32 -0
- package/dist/web/public/js/onboard/templates.js +375 -0
- package/dist/web/public/js/onboard/uiHandlers.js +196 -0
- package/dist/web/public/js/serverCategoryDetails.js +211 -123
- package/dist/web/public/onboard.html +150 -0
- package/dist/web/server.js +25 -0
- package/package.json +3 -4
- package/src/core/ConfigurationProvider.ts +37 -29
- package/src/core/InstallationService.ts +176 -62
- package/src/core/MCPManager.ts +4 -0
- package/src/core/RequirementService.ts +12 -8
- package/src/core/ServerSchemaLoader.ts +48 -0
- package/src/core/ServerSchemaProvider.ts +137 -0
- package/src/core/constants.ts +4 -1
- package/src/core/installers/clients/ClientInstaller.ts +66 -49
- package/src/core/installers/requirements/PipInstaller.ts +10 -5
- package/src/core/types.ts +6 -1
- package/src/services/ServerService.ts +15 -0
- package/src/utils/githubAuth.ts +14 -27
- package/src/utils/githubUtils.ts +84 -47
- package/src/web/public/css/detailsWidget.css +235 -0
- package/src/web/public/css/serverDetails.css +126 -0
- package/src/web/public/index.html +16 -10
- package/src/web/public/js/detailsWidget.js +264 -0
- package/src/web/public/js/modal/index.js +58 -0
- package/src/web/public/js/modal/installModal.js +163 -0
- package/src/web/public/js/modal/installation.js +281 -0
- package/src/web/public/js/modal/loadingModal.js +52 -0
- package/src/web/public/js/modal/messageQueue.js +112 -0
- package/src/web/public/js/modal/modalSetup.js +512 -0
- package/src/web/public/js/modal/modalUtils.js +49 -0
- package/src/web/public/js/modal/versionUtils.js +20 -0
- package/src/web/public/js/modal.js +25 -1041
- package/src/web/public/js/serverCategoryDetails.js +211 -123
- package/src/web/server.ts +31 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { showConfirm } from '../notifications.js';
|
|
2
|
+
import { handleInstallation, handleUninstallation } from './installHandler.js';
|
|
3
|
+
import { showLoadingModal } from './loadingUI.js';
|
|
4
|
+
import { compareVersions } from './version.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Show installation modal for MCP tools
|
|
8
|
+
* @param {string} categoryName Category name
|
|
9
|
+
* @param {string} serverName Server name
|
|
10
|
+
*/
|
|
11
|
+
export async function showInstallModal(categoryName, serverName) {
|
|
12
|
+
console.log("Showing install modal for:", serverName);
|
|
13
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
14
|
+
|
|
15
|
+
const elements = getModalElements();
|
|
16
|
+
if (!elements) return;
|
|
17
|
+
|
|
18
|
+
initializeModal(elements, serverName);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const { targetData, serverData } = await fetchModalData(categoryName);
|
|
22
|
+
const mcpServer = findMcpServer(serverData, serverName);
|
|
23
|
+
|
|
24
|
+
renderModalContent(elements, {
|
|
25
|
+
targetData,
|
|
26
|
+
serverData,
|
|
27
|
+
mcpServer,
|
|
28
|
+
categoryName,
|
|
29
|
+
serverName
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
setupFormHandler(elements, categoryName, serverName, serverData);
|
|
33
|
+
elements.modal.style.display = "block";
|
|
34
|
+
} catch (error) {
|
|
35
|
+
handleModalError(error, elements.targetDiv);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Close modal and refresh with selected category
|
|
41
|
+
*/
|
|
42
|
+
export function closeModal() {
|
|
43
|
+
const modal = document.getElementById('installModal');
|
|
44
|
+
if (modal) {
|
|
45
|
+
modal.style.display = "none";
|
|
46
|
+
refreshWithCategory();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Setup click outside modal handler
|
|
52
|
+
*/
|
|
53
|
+
export function setupModalOutsideClick() {
|
|
54
|
+
window.onclick = function (event) {
|
|
55
|
+
const modal = document.getElementById('installModal');
|
|
56
|
+
if (event.target === modal) {
|
|
57
|
+
closeModal();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Private helper functions
|
|
63
|
+
|
|
64
|
+
function getModalElements() {
|
|
65
|
+
const modal = document.getElementById('installModal');
|
|
66
|
+
if (!modal) {
|
|
67
|
+
console.error('Modal container not found');
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const elements = {
|
|
72
|
+
modal,
|
|
73
|
+
title: modal.querySelector('#modalTitle'),
|
|
74
|
+
envInputs: modal.querySelector('#modalEnvInputs'),
|
|
75
|
+
targetDiv: modal.querySelector('#modalTargets'),
|
|
76
|
+
requirements: modal.querySelector('#modalRequirements'),
|
|
77
|
+
arguments: modal.querySelector('#modalArguments')
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (!Object.values(elements).every(Boolean)) {
|
|
81
|
+
console.error('Required modal elements not found');
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return elements;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function initializeModal(elements, serverName) {
|
|
89
|
+
window.selectedClients = [];
|
|
90
|
+
elements.title.textContent = `Install ${serverName}`;
|
|
91
|
+
clearModalSections(elements);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function clearModalSections(elements) {
|
|
95
|
+
['envInputs', 'targetDiv', 'requirements', 'arguments'].forEach(section => {
|
|
96
|
+
elements[section].innerHTML = '';
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function fetchModalData(categoryName) {
|
|
101
|
+
const [targetResponse, serverResponse] = await Promise.all([
|
|
102
|
+
fetch('/api/targets'),
|
|
103
|
+
fetch(`/api/categories/${categoryName}`)
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
if (!targetResponse.ok || !serverResponse.ok) {
|
|
107
|
+
throw new Error('Failed to fetch required data');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const [targetData, serverData] = await Promise.all([
|
|
111
|
+
targetResponse.json(),
|
|
112
|
+
serverResponse.json()
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
if (!targetData.success || !serverData.success) {
|
|
116
|
+
throw new Error('Invalid data received');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return { targetData, serverData };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function findMcpServer(serverData, serverName) {
|
|
123
|
+
const mcpServer = serverData.data.feedConfiguration.mcpServers
|
|
124
|
+
.find(server => server.name === serverName);
|
|
125
|
+
|
|
126
|
+
if (!mcpServer) {
|
|
127
|
+
throw new Error('Server configuration not found');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return mcpServer;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function renderModalContent(elements, data) {
|
|
134
|
+
const { targetData, serverData, mcpServer, categoryName, serverName } = data;
|
|
135
|
+
const installationStatus = serverData.data.installationStatus || {};
|
|
136
|
+
const serverStatuses = installationStatus.serversStatus || {};
|
|
137
|
+
const serverStatus = serverStatuses[serverName] || { installedStatus: {} };
|
|
138
|
+
|
|
139
|
+
renderClientSection(elements.targetDiv, targetData.data, serverStatus, serverName, categoryName);
|
|
140
|
+
renderEnvironmentSection(elements.envInputs, mcpServer, targetData.clientMcpSettings, serverName);
|
|
141
|
+
renderArgumentsSection(elements.arguments, mcpServer);
|
|
142
|
+
renderRequirementsSection(elements.requirements, mcpServer, serverData, categoryName, serverName);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function setupFormHandler(elements, categoryName, serverName, serverData) {
|
|
146
|
+
const form = document.getElementById('installForm');
|
|
147
|
+
form.onsubmit = (e) => handleFormSubmit(e, {
|
|
148
|
+
elements,
|
|
149
|
+
categoryName,
|
|
150
|
+
serverName,
|
|
151
|
+
serverData
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function handleFormSubmit(event, options) {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
const { elements, categoryName, serverName, serverData } = options;
|
|
158
|
+
|
|
159
|
+
const formData = collectFormData(elements);
|
|
160
|
+
if (!validateFormData(formData)) return;
|
|
161
|
+
|
|
162
|
+
const installOptions = buildInstallOptions(formData, serverData, serverName);
|
|
163
|
+
handleInstallation(categoryName, serverName, formData.targets, installOptions);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function collectFormData(elements) {
|
|
167
|
+
return {
|
|
168
|
+
envVars: getEnvironmentVariables(elements.envInputs),
|
|
169
|
+
args: getArguments(elements.arguments),
|
|
170
|
+
pythonEnv: getPythonEnvironment(),
|
|
171
|
+
targets: getSelectedTargets(),
|
|
172
|
+
requirements: getSelectedRequirements()
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function validateFormData(formData) {
|
|
177
|
+
const { targets, requirements } = formData;
|
|
178
|
+
if (targets.length === 0 && requirements.length === 0) {
|
|
179
|
+
showError('Please select at least one client or requirement to update.');
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function handleModalError(error, targetDiv) {
|
|
186
|
+
console.error("Error loading data:", error);
|
|
187
|
+
targetDiv.innerHTML = `<p class="text-red-500">Error: ${error.message}</p>`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function refreshWithCategory() {
|
|
191
|
+
const lastSelected = localStorage.getItem('lastSelectedCategory');
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
if (lastSelected) {
|
|
194
|
+
window.location.href = window.location.pathname + '?category=' + encodeURIComponent(lastSelected);
|
|
195
|
+
} else {
|
|
196
|
+
location.reload();
|
|
197
|
+
}
|
|
198
|
+
}, 100);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Add CSS styles for the toggle switch
|
|
202
|
+
const styleElement = document.createElement('style');
|
|
203
|
+
styleElement.textContent = `
|
|
204
|
+
.toggle-bg.bg-blue-500 {
|
|
205
|
+
background-color: #3b82f6;
|
|
206
|
+
}
|
|
207
|
+
.toggle-bg {
|
|
208
|
+
transition: background-color 0.3s;
|
|
209
|
+
}
|
|
210
|
+
.toggle-bg div {
|
|
211
|
+
transition: transform 0.3s;
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
document.head.appendChild(styleElement);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Close modal and ensure selected category persists
|
|
3
|
+
*/
|
|
4
|
+
export function closeModal() {
|
|
5
|
+
document.getElementById('installModal').style.display = "none";
|
|
6
|
+
|
|
7
|
+
// Get the last selected category from localStorage
|
|
8
|
+
const lastSelected = localStorage.getItem('lastSelectedCategory');
|
|
9
|
+
|
|
10
|
+
// Refresh page and restore selection
|
|
11
|
+
if (lastSelected) {
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
window.location.href = window.location.pathname + '?category=' + encodeURIComponent(lastSelected);
|
|
14
|
+
}, 100);
|
|
15
|
+
} else {
|
|
16
|
+
location.reload();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Close modal if clicked outside content
|
|
22
|
+
*/
|
|
23
|
+
export function setupModalOutsideClick() {
|
|
24
|
+
window.onclick = function (event) {
|
|
25
|
+
const installModal = document.getElementById('installModal');
|
|
26
|
+
if (event.target == installModal) {
|
|
27
|
+
closeModal();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Setup toggle switch styles
|
|
34
|
+
*/
|
|
35
|
+
export function setupToggleStyles() {
|
|
36
|
+
const styleElement = document.createElement('style');
|
|
37
|
+
styleElement.textContent = `
|
|
38
|
+
.toggle-bg.bg-blue-500 {
|
|
39
|
+
background-color: #3b82f6;
|
|
40
|
+
}
|
|
41
|
+
.toggle-bg {
|
|
42
|
+
transition: background-color 0.3s;
|
|
43
|
+
}
|
|
44
|
+
.toggle-bg div {
|
|
45
|
+
transition: transform 0.3s;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
document.head.appendChild(styleElement);
|
|
49
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple version comparison function
|
|
3
|
+
* @param {string} v1 First version
|
|
4
|
+
* @param {string} v2 Second version
|
|
5
|
+
* @returns {number} 1 if v1 > v2, -1 if v1 < v2, 0 if equal
|
|
6
|
+
*/
|
|
7
|
+
export function compareVersions(v1, v2) {
|
|
8
|
+
const v1Parts = v1.split('.').map(Number);
|
|
9
|
+
const v2Parts = v2.split('.').map(Number);
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
12
|
+
const v1Part = v1Parts[i] || 0;
|
|
13
|
+
const v2Part = v2Parts[i] || 0;
|
|
14
|
+
|
|
15
|
+
if (v1Part > v2Part) return 1;
|
|
16
|
+
if (v1Part < v2Part) return -1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple version comparison function
|
|
3
|
+
* @param {string} v1 First version
|
|
4
|
+
* @param {string} v2 Second version
|
|
5
|
+
* @returns {number} 1 if v1 > v2, -1 if v1 < v2, 0 if equal
|
|
6
|
+
*/
|
|
7
|
+
export function compareVersions(v1, v2) {
|
|
8
|
+
const v1Parts = v1.split('.').map(Number);
|
|
9
|
+
const v2Parts = v2.split('.').map(Number);
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
12
|
+
const v1Part = v1Parts[i] || 0;
|
|
13
|
+
const v2Part = v2Parts[i] || 0;
|
|
14
|
+
|
|
15
|
+
if (v1Part > v2Part) return 1;
|
|
16
|
+
if (v1Part < v2Part) return -1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return 0;
|
|
20
|
+
}
|