imcp 0.0.18 → 0.1.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 (96) hide show
  1. package/.roo/rules-code/rules.md +88 -0
  2. package/dist/cli/index.js +0 -0
  3. package/dist/core/metadatas/constants.d.ts +7 -0
  4. package/dist/core/metadatas/constants.js +7 -0
  5. package/dist/core/onboard/FeedOnboardService.d.ts +7 -3
  6. package/dist/core/onboard/FeedOnboardService.js +52 -5
  7. package/dist/core/onboard/OnboardProcessor.js +22 -22
  8. package/dist/services/MCPManager.js +66 -6
  9. package/dist/services/TelemetryService.d.ts +15 -0
  10. package/dist/services/TelemetryService.js +54 -0
  11. package/dist/utils/githubAuth.js +65 -0
  12. package/dist/utils/logger.d.ts +16 -0
  13. package/dist/utils/logger.js +78 -1
  14. package/dist/utils/versionUtils.d.ts +1 -0
  15. package/dist/utils/versionUtils.js +29 -0
  16. package/dist/web/public/css/serverCategoryList.css +120 -0
  17. package/dist/web/public/index.html +6 -3
  18. package/dist/web/public/js/flights/flights.js +0 -1
  19. package/dist/web/public/js/onboard/formProcessor.js +18 -11
  20. package/dist/web/public/js/onboard/publishHandler.js +30 -0
  21. package/dist/web/public/js/onboard/templates.js +5 -1
  22. package/dist/web/public/js/onboard/uiHandlers.js +266 -39
  23. package/dist/web/public/js/onboard/validationHandlers.js +71 -39
  24. package/dist/web/public/js/serverCategoryList.js +91 -7
  25. package/dist/web/public/onboard.html +2 -2
  26. package/dist/web/server.js +11 -1
  27. package/{src/web/public/js/onboard → docs}/ONBOARDING_PAGE_DESIGN.md +15 -125
  28. package/docs/Telemetry.md +136 -0
  29. package/memory-bank/activeContext.md +14 -0
  30. package/memory-bank/decisionLog.md +28 -0
  31. package/memory-bank/productContext.md +41 -0
  32. package/memory-bank/progress.md +5 -0
  33. package/memory-bank/systemPatterns.md +3 -0
  34. package/package.json +2 -1
  35. package/src/core/metadatas/constants.ts +9 -0
  36. package/src/core/onboard/FeedOnboardService.ts +59 -5
  37. package/src/core/onboard/OnboardProcessor.ts +25 -23
  38. package/src/services/MCPManager.ts +78 -8
  39. package/src/services/TelemetryService.ts +59 -0
  40. package/src/utils/githubAuth.ts +84 -1
  41. package/src/utils/logger.ts +83 -1
  42. package/src/utils/versionUtils.ts +33 -0
  43. package/src/web/public/css/serverCategoryList.css +120 -0
  44. package/src/web/public/index.html +6 -3
  45. package/src/web/public/js/onboard/formProcessor.js +18 -11
  46. package/src/web/public/js/onboard/publishHandler.js +30 -0
  47. package/src/web/public/js/onboard/templates.js +5 -1
  48. package/src/web/public/js/onboard/uiHandlers.js +266 -39
  49. package/src/web/public/js/onboard/validationHandlers.js +71 -39
  50. package/src/web/public/js/serverCategoryList.js +91 -7
  51. package/src/web/public/onboard.html +2 -2
  52. package/src/web/server.ts +11 -1
  53. package/dist/cli/commands/start.d.ts +0 -2
  54. package/dist/cli/commands/start.js +0 -32
  55. package/dist/cli/commands/sync.d.ts +0 -2
  56. package/dist/cli/commands/sync.js +0 -17
  57. package/dist/core/ConfigurationLoader.d.ts +0 -32
  58. package/dist/core/ConfigurationLoader.js +0 -236
  59. package/dist/core/ConfigurationProvider.d.ts +0 -35
  60. package/dist/core/ConfigurationProvider.js +0 -375
  61. package/dist/core/InstallationService.d.ts +0 -50
  62. package/dist/core/InstallationService.js +0 -350
  63. package/dist/core/MCPManager.d.ts +0 -28
  64. package/dist/core/MCPManager.js +0 -188
  65. package/dist/core/RequirementService.d.ts +0 -40
  66. package/dist/core/RequirementService.js +0 -110
  67. package/dist/core/ServerSchemaLoader.d.ts +0 -11
  68. package/dist/core/ServerSchemaLoader.js +0 -43
  69. package/dist/core/ServerSchemaProvider.d.ts +0 -17
  70. package/dist/core/ServerSchemaProvider.js +0 -120
  71. package/dist/core/constants.d.ts +0 -47
  72. package/dist/core/constants.js +0 -94
  73. package/dist/core/installers/BaseInstaller.d.ts +0 -74
  74. package/dist/core/installers/BaseInstaller.js +0 -253
  75. package/dist/core/installers/ClientInstaller.d.ts +0 -23
  76. package/dist/core/installers/ClientInstaller.js +0 -564
  77. package/dist/core/installers/CommandInstaller.d.ts +0 -37
  78. package/dist/core/installers/CommandInstaller.js +0 -173
  79. package/dist/core/installers/GeneralInstaller.d.ts +0 -33
  80. package/dist/core/installers/GeneralInstaller.js +0 -85
  81. package/dist/core/installers/InstallerFactory.d.ts +0 -54
  82. package/dist/core/installers/InstallerFactory.js +0 -97
  83. package/dist/core/installers/NpmInstaller.d.ts +0 -26
  84. package/dist/core/installers/NpmInstaller.js +0 -127
  85. package/dist/core/installers/PipInstaller.d.ts +0 -28
  86. package/dist/core/installers/PipInstaller.js +0 -127
  87. package/dist/core/installers/RequirementInstaller.d.ts +0 -33
  88. package/dist/core/installers/RequirementInstaller.js +0 -3
  89. package/dist/core/types.d.ts +0 -166
  90. package/dist/core/types.js +0 -16
  91. package/dist/services/InstallRequestValidator.d.ts +0 -21
  92. package/dist/services/InstallRequestValidator.js +0 -99
  93. package/dist/web/public/js/modal/installHandler.js +0 -227
  94. package/dist/web/public/js/modal/loadingUI.js +0 -74
  95. package/dist/web/public/js/modal/modalUI.js +0 -214
  96. package/dist/web/public/js/modal/version.js +0 -20
@@ -6,7 +6,7 @@ import { SUPPORTED_CLIENT_NAMES } from '../core/metadatas/constants.js';
6
6
  import { serverService } from '../services/ServerService.js';
7
7
  import { feedOnboardService } from '../core/onboard/FeedOnboardService.js';
8
8
  import { openBrowser } from '../utils/osUtils.js';
9
- import { Logger } from '../utils/logger.js';
9
+ import { Logger, EventType, EventStatus } from '../utils/logger.js';
10
10
  import { configProvider } from '../core/loaders/ConfigurationProvider.js';
11
11
  import { onboardStatusManager } from '../core/onboard/OnboardStatusManager.js';
12
12
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -299,9 +299,19 @@ export async function startWebServer(port = 3000) {
299
299
  openBrowser(url).catch(err => {
300
300
  console.warn(`Failed to open browser: ${err.message}`);
301
301
  });
302
+ // Track IMCP serve event
303
+ Logger.trackEvent(EventType.IMCP_SERVE, {
304
+ status: EventStatus.SUCCESS,
305
+ port: port,
306
+ });
302
307
  resolve();
303
308
  });
304
309
  server.on('error', (error) => {
310
+ Logger.trackEvent(EventType.IMCP_SERVE, {
311
+ status: EventStatus.FAILED,
312
+ errorMessage: error instanceof Error ? error.message : String(error),
313
+ port: port
314
+ });
305
315
  reject(error);
306
316
  });
307
317
  });
@@ -15,8 +15,6 @@ The JavaScript logic is modularized into several files within `src/web/public/js
15
15
  - **`publishHandler.js`**: Manages the publishing process. This includes initiating publish requests (`handlePublish`), and utilizing shared functions from `validationHandlers.js` for polling status and displaying results.
16
16
  - **`templates.js`**: Contains HTML string templates for dynamically generated form sections (e.g., server items, environment variables, requirements).
17
17
  - **`state.js`**: Manages client-side state, primarily counters for dynamically added elements (servers, env vars per server, requirements per server).
18
- - **`templates.js`**: Contains HTML string templates for dynamically generated form sections (e.g., server items, environment variables, requirements).
19
- - **`state.js`**: Manages client-side state, primarily counters for dynamically added elements (servers, env vars per server, requirements per server).
20
18
 
21
19
  ---
22
20
 
@@ -73,7 +71,7 @@ Located in `formProcessor.js`, this function populates the HTML form using a `Fe
73
71
  - **Environment Variables:** Iterates `server.installation.env`, calls `window.addEnvVariable()` for each, and populates its fields.
74
72
  - **Package Dependencies:**
75
73
  - Iterates through `server.dependencies.requirements` (which are `{name, version, order}` objects, referred to as `depReq`).
76
- - For each `depReq`, searches the top-level `feedConfig.requirements` array to find the corresponding full `RequirementConfig` object (`fullReq`) by matching `fullReq.name === depReq.name` AND `fullReq.version === depReq.version`.
74
+ - For each `depReq`, searches the top-level `feedConfig.requirements` array to find the corresponding full `RequirementConfig` object (`fullReq`) by matching `fullReq.name === depReq.name`.
77
75
  - If `fullReq` is found, `window.addServerRequirement()` is called to create the UI block for this requirement within the server.
78
76
  - All fields of the requirement (`type`, `version`, `alias`, `registry` details) are then populated using data from `fullReq` and `depReq.order`.
79
77
  - Conditional UI elements (alias field, specific registry config sections) are toggled based on the requirement's type and selected registry.
@@ -197,132 +195,22 @@ This summary covers the main design patterns and implementation choices made for
197
195
 
198
196
  ---
199
197
 
200
- ## 9. Recent Fixes and Changes (May 2025)
198
+ ## 9. Recent Changes (May 2025)
201
199
 
202
- This section documents significant fixes and behavior changes implemented recently.
203
-
204
- - **Visibility of Existing Category Servers:**
200
+ - **Requirement Lookup in `populateForm`:**
201
+ Requirement lookup for server dependencies now matches by `name` only (not `name` and `version`).
205
202
 
206
- - **Issue:** When selecting an existing category in the "Create Server in Existing Category" tab, the container holding the list of existing MCP servers (`existingCategoryMcpServersContainer`) and the servers themselves were not becoming visible, even though the data was being fetched and `populateForm` was called.
207
- - **Root Cause Analysis:** Extensive logging revealed that `existingCategoryMcpServersContainer` was being correctly unhidden before `populateForm` was called. However, immediately after `populateForm` completed, the container was found to be hidden again. The exact mechanism causing this re-hiding was elusive but seemed to occur synchronously within or immediately after `populateForm`'s execution, despite `populateForm` itself not directly hiding the container. Standard form reset (`form.reset()`) was ruled out as the cause.
208
- - **Solution:**
209
- 1. In `templates.js`, the `serverTemplate` was modified to ensure that the main content `div` of a server item (`server-content-${serverIndex}`) includes the `hidden` class by default. This allows the `toggleSectionContent` function to correctly manage its visibility.
210
- 2. In `uiHandlers.js`, within the `addServer` function, if a server is being rendered as `isReadOnly` (i.e., an existing server), its content section (`#server-content-${newServerIndex}`) is explicitly made visible by removing the `hidden` class. This ensures that existing servers are expanded by default when displayed.
211
- 3. **Crucially**, in `index.js`, within the `handleExistingCategorySelection` function, after `populateForm` is called to display the existing servers, a line was added to explicitly call `mcpServersContainer.classList.remove('hidden');`. This ensures that the main container for these servers is visible, overriding whatever was causing it to become hidden.
212
- - **Outcome:** Existing servers for a selected category are now correctly displayed and visible.
203
+ - **UI and Validation Improvements:**
213
204
 
214
- - **Requirement Lookup in `populateForm`:**
205
+ - Unique IDs are used for validation panels and buttons per tab to avoid cross-tab issues.
206
+ - Switching between tabs and view modes now preserves form data and ensures correct UI state.
207
+ - The JSON editor view is now properly toggled and content is preserved as expected.
208
+ - Polling for operation status (validation/publish) is more robust and status checks are case-insensitive.
209
+ - Progress steps for operations are now shown in a collapsible section for better feedback.
215
210
 
216
- - **Issue:** The logic in `formProcessor.js` (`populateForm`) for finding the full `RequirementConfig` for a server's dependency was matching on both `name` and `version`.
217
- - **Change Request:** The lookup should only be based on the requirement `name`, ignoring the `version` specified in the server's dependency list when matching against the global `feedConfig.requirements`.
218
- - **Solution:** In `formProcessor.js`, the line:
219
- `const fullReq = (feedConfig.requirements || []).find(r => r.name === depReq.name && r.version === depReq.version);`
220
- was changed to:
221
- `const fullReq = (feedConfig.requirements || []).find(r => r.name === depReq.name);`
222
- The associated warning message was also updated to reflect this change in lookup behavior.
223
-
224
- - **Code Cleanup:**
225
-
226
- - All diagnostic `console.log` statements added during the debugging of the visibility issue were removed from `index.js`, `formProcessor.js`, and `uiHandlers.js`.
227
- - The experimental `requestAnimationFrame` logic for forcing a reflow in `formProcessor.js` was removed as it was not the solution to the visibility problem.
228
-
229
- - **Tab Switching and View Mode Toggling Enhancements:**
230
-
231
- - **Context:** A series of changes were made to improve the user experience related to switching between the main onboarding tabs ("Create New Category", "Create Server in Existing Category") and toggling between the Form view and JSON editor view.
232
- - **Issues Addressed & Solutions:**
233
- 1. **JSON View Buttons Hidden (`uiHandlers.js`):**
234
- - **Problem:** Buttons like "Cancel" and "Publish JSON" were visible in the JSON editor view, which was not desired.
235
- - **Solution:** The `toggleViewMode` function in `uiHandlers.js` was updated to explicitly hide the `jsonEditorActionsContainer` when switching to JSON view.
236
- 2. **JSON View Content Preservation (`uiHandlers.js`):**
237
- - **Problem:** Clicking the JSON view toggle switch again while already in JSON view would cause the editor's content to be re-processed or cleared.
238
- - **Solution:** The `toggleViewMode` function in `uiHandlers.js` now checks if the target view (Form or JSON) is already active. If so, it returns early, preventing unnecessary re-rendering and preserving the current content.
239
- 3. \*\*Tab Switching Logic Improvements (`index.js`):
240
- - **Problem 1:** Clicking on a main navigation tab that was already active would still trigger tab switching logic, potentially causing unnecessary view updates.
241
- - **Solution 1:** The `switchTab` function in `index.js` now checks if the `targetTab` is the same as the `activeTab`. If so, it returns immediately.
242
- - **Problem 2:** When switching away from the "Create New Category" tab and then back to it (without being in an edit-category scenario), any entered form data was lost due to an automatic form reset.
243
- - **Solution 2:** The automatic call to `resetOnboardFormDynamicContent('onboardForm')` within `switchTab` for the "Create New Category" tab (in non-edit scenarios) was removed. This allows form data to be preserved when tabbing away and back.
244
- - **Problem 3:** If the JSON view was active and a user clicked on a different main navigation tab, the new tab's form content could render on top of or alongside the still-visible JSON editor.
245
- - **Solution 3:** The `switchTab` function in `index.js` was updated. If the JSON view is active when a tab switch is initiated, it now first calls `toggleViewMode(false, ...)` to programmatically switch back to the Form view (for the currently active tab) before proceeding to display the content of the newly selected tab. This ensures a clean transition from JSON view to the new tab's form view.
246
- - **Outcome:** These changes provide a more stable, predictable, and user-friendly experience when navigating between tabs and view modes. Data entered by the user is better preserved, and UI rendering artifacts during transitions are avoided.
247
-
248
- - **Dropdown Reset, Form Disappearance, and Misplaced Validation (May 2025 - Current Session):**
249
- - **Context:** A series of interconnected issues were addressed to improve the stability and correctness of the "Create New Server in Existing Category" tab and its interaction with view toggling and validation.
250
- - **Issues Addressed & Solutions:**
251
- 1. **Existing Category Dropdown Reset (`formProcessor.js`):**
252
- - **Problem:** After selecting a category from the `existingCategorySelect` dropdown on the "Create New Server in Existing Category" tab, the dropdown would immediately reset to its default "Select a category" or "Loading..." state.
253
- - **Root Cause:** The `populateForm` function, called upon category selection, invoked `resetOnboardFormDynamicContent`. Inside `resetOnboardFormDynamicContent`, the line `formToReset.reset()` was being called for the `onboardServerForm` (the form containing the dropdown). This `HTMLFormElement.reset()` method reverts all form controls to their initial HTML values.
254
- - **Solution:** The `resetOnboardFormDynamicContent` function in `formProcessor.js` was modified. The `formToReset.reset()` call is now conditional: it is skipped if `formId` is `'onboardServerForm'`, thus preserving the dropdown's selected value. Other dynamic content clearing (server list, counters) within the function remains active.
255
- 2. **Form Disappearance on JSON Toggle (Existing Category Tab - `formProcessor.js`):**
256
- - **Problem:** On the "Create New Server in Existing Category" tab, if a category was selected (displaying its basic info and servers), then the view was toggled to JSON and back to Form view, the displayed category information would vanish.
257
- - **Root Cause:** When `toggleViewMode` (in `uiHandlers.js`) switched from JSON back to Form view, it called `populateForm`. However, `populateForm` lacked specific logic to re-populate the basic category information fields (name, display name, description, repository) for the `onboardServerForm`. Additionally, the containers for this basic info (`existingCategoryBasicInfoContainer`) and the MCP servers (`existingCategoryMcpServersContainer`) were not being explicitly made visible again after `resetOnboardFormDynamicContent` (called by `populateForm`) might have hidden them or cleared their content.
258
- - **Solution:**
259
- - An `else if (formId === 'onboardServerForm' && feedConfig)` block was added to `populateForm` in `formProcessor.js`. This block now explicitly populates the read-only basic category information fields using the `feedConfig` data.
260
- - Within this new block, `existingCategoryBasicInfoContainer.classList.remove('hidden')` and `existingCategoryMcpServersContainer.classList.remove('hidden')` are called to ensure these sections are visible.
261
- 3. **Validation Results on Wrong Tab (Multiple Files):**
262
- - **Problem:** Clicking the "Validate" button on the "Create New Server in Existing Category" tab would display the validation results in the validation panel of the "Create New Category" tab.
263
- - **Root Cause:** Validation panels, content areas, and buttons on both tabs shared common HTML IDs (e.g., `validationStatusPanel`, `validateButton`). JavaScript's `getElementById` would typically find the first matching element in the DOM, leading to the incorrect panel being targeted.
264
- - **Solution (Multi-file update):**
265
- - **HTML (`onboard.html`):** All relevant validation-related element IDs were made unique for each tab (e.g., `validationStatusPanelNewCategory`, `validateButtonNewCategory`, `validationStatusPanelExistingCategory`, `validateButtonExistingCategory`).
266
- - **Event Listeners (`index.js`):** Event listeners for the "Validate" buttons were updated to target these new unique IDs.
267
- - **Validation Logic (`validationHandlers.js`):**
268
- - The `handleValidation` function was updated to accept `activeTab` and `currentSelectedCategoryData` as parameters. It now dynamically determines the correct, unique element IDs for the panel, content area, form, validate button, and publish button based on the `activeTab`.
269
- - The `pollValidationStatus` function was modified to accept these dynamic element IDs as parameters, ensuring it updates the UI on the correct tab during polling.
270
- - The call to `getFormData` within `handleValidation` was adjusted to pass the `forExistingCategoryTab` flag and `currentSelectedCategoryData` when validating for the "Create Server in Existing Category" tab.
271
- - **Form Reset Logic (`formProcessor.js`):**
272
- - The `resetOnboardFormDynamicContent` function was updated. When resetting validation panels, it now determines the correct unique panel ID and content ID based on the `formId` parameter, ensuring it hides and clears the appropriate panel for the active tab.
273
- - **Outcome:** These fixes ensure that the "Create New Server in Existing Category" tab functions correctly with respect to category selection, view toggling, and validation display, providing a more robust and intuitive user experience.
274
-
275
- - **API Data Integrity and UI State for "Create Server" Tab (May 2025 - Current Session):**
276
- - **Context:** Two issues were addressed related to the "Create Server in Existing Category" tab's interaction with backend APIs and UI feedback during operations.
277
- - **Issues Addressed & Solutions:**
278
- 1. **Incomplete Data Sent to API:**
279
- - **Problem:** When using the "Validate" or "Publish" buttons on the "Create Server in Existing Category" tab, only the data for the newly added server(s) was being sent to the backend, omitting the data of the existing category to which they were being added.
280
- - **Solution:**
281
- - The `handleValidation` function in `validationHandlers.js` was updated. It now retrieves the new server data using `getFormData` and then merges it with the `currentSelectedCategoryData` (the full data of the existing category) before sending the combined `FeedConfiguration` to the `/api/categories/onboard/validate` endpoint.
282
- - Similarly, the `handlePublish` function in `publishHandler.js` was updated to perform the same merge of new server data with `currentSelectedCategoryData` before sending the complete payload to the `/api/categories/onboard` endpoint.
283
- - **Outcome:** The backend now receives the full, correct `FeedConfiguration` when a new server is validated or published within an existing category.
284
- 2. **Persistent Spinner on Publish Failure:**
285
- - **Problem:** If a publish operation failed (e.g., backend returns a "FAILED" status), the "Publish" button would remain in its loading state (displaying a spinner icon) instead of reverting to its active state.
286
- - **Root Cause:** The status check within the `pollOperationStatus` function (in `validationHandlers.js`) was case-sensitive when comparing the received status string (e.g., "failed") against expected terminal states (e.g., "FAILED"). If the casing didn't match, the logic to reset button states wasn't triggered.
287
- - **Solution:**
288
- - The `pollOperationStatus` function in `validationHandlers.js` was modified to convert the received status string to uppercase before comparing it against 'COMPLETED', 'FAILED', or 'SUCCEEDED'. This makes the check case-insensitive.
289
- - Additionally, the direct error/failure handling paths within `handlePublish` (in `publishHandler.js`) were enhanced to ensure both "Publish" and "Validate" buttons are comprehensively reset (disabling, innerHTML, and opacity classes) if the initial publish call itself fails or returns a terminal status immediately.
290
- - **Outcome:** The "Publish" and "Validate" buttons now reliably revert to their default active states when an operation (validation or publish) concludes with a failure, regardless of the casing of the status string from the backend or whether the failure occurs immediately or during polling.
291
- - **Overall Outcome:** These changes improve the reliability of data submission and provide more accurate UI feedback for asynchronous operations on the "Create Server in Existing Category" tab.
292
-
293
- - **Enhanced Operation Status Polling and Display (May 2025 - Current Session):**
294
- - **Context:** Significant improvements were made to the handling of asynchronous operations (validation and publishing), including more detailed progress display, robust polling, and clearer API interactions.
295
- - **Issues Addressed & Solutions:**
296
- 1. **Server-Side API (`server.ts` - `/api/categories/:categoryName/onboard/status`):**
297
- - The endpoint now requires an `operationType` query parameter (e.g., `VALIDATION_ONLY`, `FULL_ONBOARDING`).
298
- - The response payload (`OperationStatus`) was enhanced to include:
299
- - `steps`: An array of objects detailing each step of the operation (name, serverName, timestamp, status, errorMessage).
300
- - `operationType`: Reflects the type of operation being tracked, taken from the status object.
301
- - `feedConfiguration`: Conditionally included for successful `VALIDATION_ONLY` operations if present in the result.
302
- - The `onboardingId` in the response is `categoryName_operationType`.
303
- - The `message` field in the response now prioritizes the last step's name or an overall error message.
304
- 2. **Client-Side Polling Logic (`validationHandlers.js` - `pollOperationStatus`):**
305
- - The function now accepts an `operationType` parameter, which is passed to the API.
306
- - It returns a boolean promise (`Promise<boolean>`) indicating whether polling should continue, allowing the caller (`handleValidation` or `handlePublish`) to manage `clearInterval`.
307
- - Calls `ensureProgressToggleListener` to ensure the UI for displaying progress steps is interactive.
308
- - Status comparisons (`COMPLETED`, `FAILED`, `SUCCEEDED`) are now case-insensitive.
309
- 3. **Operation Initiation (`publishHandler.js` - `handlePublish`, `validationHandlers.js` - `handleValidation`):**
310
- - When initiating polling, these functions now pass the correct `operationType` (`FULL_ONBOARDING` for publish, `VALIDATION_ONLY` for validate) and use the original `finalFeedConfiguration.name` as the `categoryName` for the polling request.
311
- - They now manage `clearInterval` based on the boolean returned by `pollOperationStatus`.
312
- - Both handlers call `ensureProgressToggleListener` at the beginning to prepare the UI for status updates.
313
- - `handlePublish` includes improved error handling for the initial publish request, ensuring UI elements are correctly updated even if the initial call fails or returns a terminal status.
314
- 4. **UI Display (`validationHandlers.js` - `updateOperationDisplay`):**
315
- - A new collapsible "Progress" section is displayed, showing detailed `steps` from the API response. Each step includes:
316
- - A status icon (error, in-progress spinner, success).
317
- - The step name, server name (if applicable), and timestamp.
318
- - An error message for the step, if any.
319
- - The visibility of the "Progress" section is managed by `ensureProgressToggleListener` (which attaches a click handler to the section header) and the `toggleSectionContent` utility.
320
- - The `operationType` is now displayed.
321
- - The logic for displaying the overall status spinner has been updated to cover more in-progress states (e.g., `PENDING`, `VALIDATING`, `PRCREATING`, `PUBLISHING`) and uses case-insensitive comparisons.
322
- 5. **Progress Section Toggling (`validationHandlers.js` - `ensureProgressToggleListener`):**
323
- - A new exported utility function, `ensureProgressToggleListener`, was added. It attaches a click event listener to the status content element. This listener delegates to `toggleSectionContent` (from `uiHandlers.js`) when the progress section header is clicked, allowing users to expand or collapse the detailed list of progress steps. The listener is attached only once per status content element.
324
- - **Outcome:** These changes provide users with more granular and interactive feedback on long-running operations, improve the robustness and accuracy of status polling, and align client-server communication for tracking asynchronous onboarding tasks.
325
- ---
211
+ - **General Cleanup:**
212
+ - Redundant diagnostic logs and experimental code were removed.
213
+ - Form reset logic was improved to avoid unwanted clearing of dropdowns or form fields.
326
214
 
327
215
  ## 10. Server Validation System
328
216
 
@@ -331,6 +219,7 @@ The server validation system consists of multiple components that work together
331
219
  ### Server Validator Architecture
332
220
 
333
221
  - **`IServerValidator` Interface**: Defines the common validation contract for all server validators:
222
+
334
223
  - `validateServer(server: McpConfig, config: FeedConfiguration): Promise<boolean>`
335
224
  - Implementations throw errors with descriptive messages when validation fails
336
225
 
@@ -342,6 +231,7 @@ The server validation system consists of multiple components that work together
342
231
  ### Validator Implementations
343
232
 
344
233
  1. **StdioServerValidator**:
234
+
345
235
  - Validates stdio-mode MCP server configurations
346
236
  - Key validation steps:
347
237
  - Verifies installation command exists and is executable
@@ -0,0 +1,136 @@
1
+ # Application Insights Telemetry Integration
2
+
3
+ This document describes the telemetry implementation in the MCP SDK using Azure Application Insights.
4
+
5
+ ## Overview
6
+
7
+ The MCP SDK integrates Azure Application Insights for telemetry tracking across various operations. This provides insights into server operations, requirement updates, and system health.
8
+
9
+ ## Implementation Details
10
+
11
+ ### TelemetryService
12
+
13
+ Located in `src/services/TelemetryService.ts`, this service provides a centralized interface for telemetry operations:
14
+
15
+ - Initialization with Application Insights configuration
16
+ - Event tracking
17
+ - Exception tracking
18
+ - Trace logging
19
+ - Metric tracking
20
+ - Data flushing capability
21
+
22
+ ```typescript
23
+ // Example usage:
24
+ TelemetryService.trackEvent("eventName", { property: "value" });
25
+ TelemetryService.trackException(error, { context: "operation" });
26
+ ```
27
+
28
+ ### Key Features
29
+
30
+ 1. **Cloud Role Tagging**: Services are tagged as 'imcp' for clear identification in Application Insights
31
+ 2. **Batch Processing**: Configured with a max batch size of 250 events
32
+ 3. **Automatic Error Handling**: Graceful handling of initialization failures
33
+
34
+ ## Integration Points
35
+ The telemetry service is integrated at key points throughout the system:
36
+
37
+ ### User Identity Tracking
38
+ - GitHub user information persistence for Mac/Linux systems
39
+ - Automatic alias extraction from Microsoft accounts
40
+ - Cross-platform username resolution (using OS username for Windows)
41
+
42
+ ### Server Operations
43
+ - Server installation/uninstallation tracking
44
+ - Operation success/failure monitoring
45
+ - Target client tracking
46
+
47
+ ### Requirement Management
48
+ - Requirement update tracking
49
+ - Version change monitoring
50
+ - Update operation status tracking
51
+
52
+ ### Feed Management
53
+ - Feed onboarding process monitoring
54
+ - Sync operations tracking
55
+ - Configuration changes tracking
56
+
57
+ ## Event Types
58
+
59
+ The system tracks several types of events:
60
+
61
+ 1. **Server Events**
62
+ - Installation (`SERVER_INSTALL`)
63
+ - Uninstallation (`SERVER_UNINSTALL`)
64
+
65
+ 2. **Requirement Events**
66
+ - Updates (`REQUIREMENT_UPDATE`)
67
+
68
+ 3. **Feed Events**
69
+ - Onboard (`FEED_ONBOARD`)
70
+ - Validate (`FEED_VALIDATE`)
71
+
72
+ 4 **IMCP Events**
73
+ - IMCP serve (`IMCP_SERVE`)
74
+
75
+ ## Best Practices
76
+ 1. **Error Tracking**
77
+ - Always include error messages in failed operations
78
+ - Track operation context with properties
79
+
80
+ 2. **Event Properties**
81
+ - Include relevant identifiers (categoryName, serverName)
82
+ - Track operation status
83
+ - Include version information when applicable
84
+ - Include user alias in events (automatically handled by Logger)
85
+
86
+ 3. **User Identity Persistence**
87
+ - Store GitHub user information (alias, name, email) for Mac/Linux users
88
+ - Skip persistence for Windows users (uses OS username)
89
+ - Only persist for Microsoft accounts (username ending with _microsoft)
90
+ - Cache user information to avoid repeated API calls
91
+ - Include version information when applicable
92
+
93
+ 4. **Performance Monitoring**
94
+ - Use metric tracking for performance-sensitive operations
95
+ - Implement proper batching for high-volume events
96
+
97
+ ## Configuration
98
+
99
+ The telemetry service is configured with:
100
+ - Azure resource: [imcp-telemetry](https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/b211ffce-ec5c-4267-b15c-138d440e3fbc/resourcegroups/aicoder/providers/microsoft.insights/components/imcp-telemetry/overview)
101
+ - Instrumentation Key: `c5fc06c7-a96c-4d80-9aff-bc9c933db0d1`
102
+ - Cloud Role: `imcp`
103
+ - Batch Size: 250 events
104
+
105
+ ## User Identity in Telemetry
106
+
107
+ The system implements user identity tracking through the Logger class (`src/utils/logger.ts`):
108
+
109
+ 1. **User Resolution**
110
+ - Windows: Uses OS username directly via `os.userInfo()`
111
+ - Mac/Linux: Uses GitHub alias stored in user info file
112
+ - Falls back to OS username if user info is unavailable
113
+
114
+ 2. **Identity Storage**
115
+ - Location: Stored in system-specific settings directory
116
+ - Format: JSON file containing alias, name, and email
117
+ - Updates: Managed during GitHub authentication
118
+
119
+ 3. **Identity Usage**
120
+ - All telemetry events automatically include username/alias
121
+ - Consistent user tracking across sessions
122
+ - Microsoft account validation ensures organizational identity
123
+
124
+ ## Future Improvements
125
+
126
+ 1. **Enhanced Metrics**
127
+ - Add performance metrics for key operations
128
+ - Implement custom metric dimensions
129
+
130
+ 2. **Error Analysis**
131
+ - Implement more detailed error categorization
132
+ - Add correlation IDs for related operations
133
+
134
+ 3. **User Analytics**
135
+ - Track user interaction patterns
136
+ - Monitor feature usage statistics
@@ -0,0 +1,14 @@
1
+ # Active Context
2
+
3
+ ## Current Focus
4
+
5
+ - [2025-05-16 09:22:21] - Task completed: Made "IMCP Server Manager" title in `src/web/public/index.html` clickable, linking to `index.html`.
6
+ - [YYYY-MM-DD HH:MM:SS] - Initializing Memory Bank.
7
+
8
+ ## Recent Changes
9
+
10
+ - [YYYY-MM-DD HH:MM:SS] - Created activeContext.md.
11
+
12
+ ## Open Questions/Issues
13
+
14
+ - None
@@ -0,0 +1,28 @@
1
+ # Decision Log
2
+
3
+ This file records significant architectural or technical decisions, including rationale and implications.
4
+ Update this file with a timestamped entry whenever a major decision is made.
5
+
6
+ ---
7
+
8
+ ---
9
+
10
+ [2025-05-15 19:56:12] - Memory Bank updated to reflect onboarding page architecture and features as described in [`docs/ONBOARDING_PAGE_DESIGN.md`](../docs/ONBOARDING_PAGE_DESIGN.md).
11
+
12
+ - Modular JS architecture for onboarding UI, form-to-JSON, validation, publishing, and state.
13
+ - Central `FeedConfiguration` model for category/server/requirement data.
14
+ - Enhanced UX: dynamic sections, toggling, notifications, robust validation/publishing.
15
+ - Recent improvements: server visibility, requirement lookup, async feedback, tab/view handling.
16
+ [2025-05-15 20:48:27] - Implemented MCP Server Duplication Feature.
17
+ - Added a duplicate button to the right of the delete button in the server item template (`src/web/public/js/onboard/templates.js`).
18
+ - Modified `duplicateServer` function in `src/web/public/js/onboard/uiHandlers.js` to correctly retrieve data from the server to be duplicated, even if it's read-only. This was achieved by temporarily enabling form fields of the source server item before calling `getFormData`.
19
+ - Ensured that the duplicated server is always created as a new, editable server, and all its content (including environment variables and requirements) is copied from the original server.
20
+ - The `populateServerManually` function ensures that sub-items (env vars, requirements) of the duplicated server are also created in an editable state.
21
+ - This functionality applies to both "Create New Category" and "Create Server in Existing Category" tabs.
22
+ - Fixed the error "Could not retrieve data for the server to duplicate" when duplicating read-only servers.
23
+
24
+ [2025-05-16 00:34:40] - [Fixed duplicate server functionality]
25
+ - Issue: Duplicating non-first servers failed with "Could not retrieve data" error
26
+ - Fix: Modified duplicateServer() to temporarily enable ALL disabled fields before form submission
27
+ - Impact: Ensures complete server data is captured regardless of position in list
28
+ - Files affected: src/web/public/js/onboard/uiHandlers.js
@@ -0,0 +1,41 @@
1
+ # Product Context
2
+
3
+ This file contains the high-level project description, goals, features, and overall architecture for the onboarding page and related systems.
4
+
5
+ ---
6
+
7
+ ## Onboarding Page Overview
8
+
9
+ - **Purpose:** Dynamic onboarding UI for configuring new server categories and MCP servers.
10
+ - **Frontend Structure:** Modular JavaScript in [`src/web/public/js/onboard/`](src/web/public/js/onboard):
11
+ - `index.js`: Entry point, tab switching, event listeners, loading/editing categories.
12
+ - `formProcessor.js`: Converts form ↔ JSON (`FeedConfiguration`), validation, populating UI.
13
+ - `uiHandlers.js`: Dynamic UI (add/remove servers, env vars, requirements), view toggling, section collapsing.
14
+ - `templates.js`: HTML templates for servers, env vars, requirements.
15
+ - `state.js`: Tracks counters for dynamic elements.
16
+ - `validationHandlers.js`: Validation logic, polling, progress display.
17
+ - `publishHandler.js`: Handles publishing, status polling, and feedback.
18
+
19
+ ---
20
+
21
+ ## Core Data Model
22
+
23
+ - **FeedConfiguration** (see [`src/core/types.ts`](src/core/types.ts)):
24
+ - `name`, `displayName`, `description`, `repository`
25
+ - `mcpServers`: Array of server configs (mode, install, env, dependencies)
26
+ - `requirements`: Unique, fully defined requirements (type, name, version, registry, alias)
27
+
28
+ ---
29
+
30
+ ## Key Features
31
+
32
+ - Dynamic form sections for servers, environment variables, and requirements.
33
+ - Toggle between form and JSON editor views.
34
+ - Robust validation and publishing flows with polling and progress UI.
35
+ - Custom notification system for user feedback.
36
+ - Enhanced UX for editing, tab switching, and error handling.
37
+ - All code and UI logic is aligned with [`docs/ONBOARDING_PAGE_DESIGN.md`](../docs/ONBOARDING_PAGE_DESIGN.md).
38
+
39
+ ---
40
+
41
+ _Last updated: 2025-05-15_
@@ -0,0 +1,5 @@
1
+ # Progress Log
2
+
3
+ - [YYYY-MM-DD HH:MM:SS] - Initializing Memory Bank.
4
+
5
+ - [2025-05-16 09:22:36] - Completed: Made "IMCP Server Manager" title clickable in `src/web/public/index.html`.
@@ -0,0 +1,3 @@
1
+ # System Patterns
2
+
3
+ - [YYYY-MM-DD HH:MM:SS] - Initializing Memory Bank.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imcp",
3
- "version": "0.0.18",
3
+ "version": "0.1.1",
4
4
  "description": "Node.js SDK for Model Context Protocol (MCP)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,6 +25,7 @@
25
25
  "author": "",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
+ "applicationinsights": "^2.9.3",
28
29
  "axios": "^1.6.2",
29
30
  "commander": "^11.1.0",
30
31
  "express": "^4.18.2",
@@ -31,6 +31,15 @@ export const SETTINGS_DIR = (() => {
31
31
  * Local feeds directory path
32
32
  */
33
33
  export const LOCAL_FEEDS_DIR = path.join(SETTINGS_DIR, 'feeds');
34
+
35
+ /**
36
+ * Path to the user information file
37
+ */
38
+ export const USER_INFO_PATH = path.join(SETTINGS_DIR, 'settings', 'user_info.json');
39
+
40
+ /**
41
+ * Path to the local feeds schema directory
42
+ */
34
43
  export const LOCAL_FEEDS_SCHEMA_DIR = path.join(LOCAL_FEEDS_DIR, 'schemas');
35
44
 
36
45
  const CODE_STRORAGE_DIR = (() => {
@@ -2,7 +2,7 @@ import { FeedConfiguration, McpConfig } from '../metadatas/types.js';
2
2
  import { configProvider } from '../loaders/ConfigurationProvider.js';
3
3
  import { ServerSchemaProvider } from '../loaders/ServerSchemaProvider.js';
4
4
  import { feedValidator } from '../validators/FeedValidator.js';
5
- import { Logger } from '../../utils/logger.js';
5
+ import { Logger, EventType, EventStatus } from '../../utils/logger.js';
6
6
  import { OnboardingProcessStatus, OperationStatus, OperationType, ValidationOperationResult } from './OnboardStatus.js';
7
7
  import { onboardStatusManager } from './OnboardStatusManager.js';
8
8
  import { onboardProcessor } from './OnboardProcessor.js';
@@ -28,8 +28,10 @@ export class FeedOnboardService {
28
28
  }
29
29
 
30
30
  /**
31
- * Onboard a new feed configuration
31
+ * Onboard a new feed configuration. This method performs validation and initiates the onboarding process.
32
32
  * @param config Feed configuration to onboard
33
+ * @param forExistingCategory Whether this onboarding is for an existing category
34
+ * @returns Promise resolving to operation status with optional feed configuration
33
35
  */
34
36
  public async onboardFeed(config: FeedConfiguration, forExistingCategory?: boolean): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
35
37
  // Perform static validation first
@@ -47,10 +49,21 @@ export class FeedOnboardService {
47
49
  // For now, let's return a FAILED status for the attempted FULL_ONBOARDING initiation.
48
50
  // A more robust solution might involve a different return type or error code.
49
51
  const onboardingId = this.createOperationId(config.name, 'FULL_ONBOARDING'); // Hypothetical ID
52
+ const errorMessage = `No prior successful validation found for feed: ${config.name}. Please validate the configuration before publishing.`;
53
+
54
+ // Track failed event
55
+ Logger.trackEvent(EventType.FEED_ONBOARD, {
56
+ status: EventStatus.FAILED,
57
+ feedName: config.name,
58
+ errorMessage,
59
+ onboardingId: onboardingId,
60
+ feedConfiguration: config
61
+ });
62
+
50
63
  return {
51
64
  onboardingId: onboardingId,
52
65
  status: OnboardingProcessStatus.FAILED, // Or a new status like 'VALIDATION_REQUIRED'
53
- message: 'The feed configuration has not been validated or has changed. Please validate the configuration before publishing.',
66
+ message: errorMessage,
54
67
  lastQueried: new Date().toISOString(),
55
68
  feedConfiguration: config
56
69
  };
@@ -60,6 +73,7 @@ export class FeedOnboardService {
60
73
  // If validation exists and matches, proceed to initiate FULL_ONBOARDING.
61
74
  // _initiateOperation will handle checks for existing non-completed or successfully completed FULL_ONBOARDING operations.
62
75
  const operationStatus = await this._initiateOperation(config, 'FULL_ONBOARDING', serverList, forExistingCategory);
76
+
63
77
  return {
64
78
  ...operationStatus,
65
79
  feedConfiguration: config
@@ -67,9 +81,11 @@ export class FeedOnboardService {
67
81
  }
68
82
 
69
83
  /**
70
- * Validate a feed configuration without performing full onboarding
84
+ * Validate a feed configuration without performing full onboarding.
85
+ * This method performs static validation and initiates the validation process.
71
86
  * @param config Feed configuration to validate
72
- * @returns Operation status indicating the result of the validation initiation
87
+ * @param forExistingCategory Whether this validation is for an existing category
88
+ * @returns Promise resolving to operation status with optional feed configuration
73
89
  */
74
90
  public async validateFeed(config: FeedConfiguration, forExistingCategory?: boolean): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
75
91
  // Perform static validation first
@@ -365,9 +381,29 @@ export class FeedOnboardService {
365
381
  validationStatus: result.validationStatus // Ensure validationStatus is also updated on success
366
382
  });
367
383
  Logger.log(`[${onboardingId}] Successfully validated feed: ${config.name}`);
384
+
385
+ // Track successful validation
386
+ Logger.trackEvent(EventType.FEED_VALIDATE, {
387
+ status: EventStatus.SUCCESS,
388
+ feedName: config.name,
389
+ operationType: 'VALIDATION_ONLY',
390
+ onboardingId: onboardingId,
391
+ feedConfiguration: config
392
+ });
368
393
  } catch (error) {
394
+ const errorMessage = error instanceof Error ? error.message : String(error);
369
395
  // Error is already logged and status updated by _validateFeedConfiguration or its callers
370
396
  Logger.error(`[${onboardingId}] Feed validation process failed for ${config.name} (already handled):`, error);
397
+
398
+ // Track validation failure
399
+ Logger.trackEvent(EventType.FEED_VALIDATE, {
400
+ status: EventStatus.FAILED,
401
+ feedName: config.name,
402
+ operationType: 'VALIDATION_ONLY',
403
+ errorMessage: errorMessage,
404
+ onboardingId: onboardingId,
405
+ feedConfiguration: config
406
+ });
371
407
  }
372
408
  }
373
409
 
@@ -428,6 +464,15 @@ export class FeedOnboardService {
428
464
  Logger.log(`[${onboardingId}] ConfigurationProvider re-initialized.`);
429
465
 
430
466
  Logger.log(`[${onboardingId}] Successfully completed full onboarding for feed: ${config.name}`);
467
+
468
+ // Track successful onboarding
469
+ Logger.trackEvent(EventType.FEED_ONBOARD, {
470
+ status: EventStatus.SUCCESS,
471
+ feedName: config.name,
472
+ onboardingId: onboardingId,
473
+ prUrl: prInfo.url,
474
+ feedConfiguration: config
475
+ });
431
476
  } catch (reinitError) {
432
477
  Logger.warn(`[${onboardingId}] Failed to re-initialize providers after PR creation for feed ${config.name}:`);
433
478
  Logger.warn(`Skipping re-initialization of providers due to error: ${reinitError}`,);
@@ -437,6 +482,15 @@ export class FeedOnboardService {
437
482
  Logger.error(`[${onboardingId}] Full feed onboarding process failed:`, error);
438
483
  const errorMessage = error instanceof Error ? error.message : String(error);
439
484
 
485
+ // Track onboarding failure
486
+ Logger.trackEvent(EventType.FEED_ONBOARD, {
487
+ status: EventStatus.FAILED,
488
+ feedName: config.name,
489
+ onboardingId: onboardingId,
490
+ errorMessage,
491
+ feedConfiguration: config
492
+ });
493
+
440
494
  // Check if status is already FAILED (e.g., by _validateFeedConfiguration)
441
495
  // to avoid overwriting a more specific error message or step from validation.
442
496
  const currentStatus = await onboardStatusManager.getStatus(config.name, operationType);