Conversation
- Add dashboard module with metrics collector, HTML template, and handler - Dashboard shows server info, registered instances, health status, sessions - Supports content negotiation: HTML for browsers, JSON for API clients - Add DASHBOARD_ENABLED config (default true, disable with =false) - Instances show health status (healthy/degraded/offline) based on metrics - HTML includes auto-refresh every 30 seconds - Safe for MCP clients - they use POST /mcp, not GET / - Add 44 unit tests for metrics, handler, and HTML template Closes #275
Test Coverage ReportOverall Coverage: 95.77%
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR implements an instance health dashboard accessible at GET / that provides real-time visibility into the GitLab MCP server's multi-instance federation state, health metrics, and configuration. The dashboard supports content negotiation, serving HTML for browsers and JSON for API clients, while remaining safe for MCP clients that use POST endpoints.
Changes:
- Adds a comprehensive health monitoring dashboard with server metrics, instance health status, rate limiting metrics, and session counts
- Implements content negotiation to serve HTML dashboards to browsers and JSON to API clients
- Provides 44 unit tests ensuring metrics collection, HTML rendering, and HTTP handling work correctly
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server.ts | Registers GET / route for dashboard when DASHBOARD_ENABLED is true (default) |
| src/config.ts | Adds DASHBOARD_ENABLED environment variable configuration |
| src/dashboard/metrics.ts | Implements metrics collection from InstanceRegistry and SessionManager with health status determination |
| src/dashboard/handler.ts | Handles HTTP requests with Accept header content negotiation between HTML and JSON |
| src/dashboard/html-template.ts | Generates responsive HTML with dark theme, XSS escaping, and auto-refresh |
| src/dashboard/index.ts | Barrel exports for dashboard module |
| tests/unit/dashboard/metrics.test.ts | Tests metrics collection, status determination, and uptime formatting |
| tests/unit/dashboard/html-template.test.ts | Tests HTML rendering, XSS protection, and content formatting |
| tests/unit/dashboard/handler.test.ts | Tests content negotiation and response generation |
- Vite/Rollup cannot resolve .d.ts files as runtime imports
- Renamed declaration file to regular .ts (content unchanged)
- File contains `declare global` + `export {}` which is valid in both formats
Fixes #285
- Add try/catch in dashboardHandler for collectMetrics/renderDashboard failures - Add safe URL parsing in renderInstanceCard with fallback to raw URL - Use GITLAB_TOKEN config constant instead of direct process.env access
- Remove unused lastSuccessfulRequestMs parameter from determineInstanceStatus - Add .js extension to dashboard import in server.ts - Add safe URL parsing for session hostnames in html-template.ts - Add comprehensive tests for collectMetrics function
- Add tests for error handling in dashboardHandler - Add tests for getMetrics export function - Add tests for OAuth and token auth modes - Add tests for unknown status indicator - Add tests for invalid URL parsing fallbacks - Add tests for queue filling warning - Add tests for formatRelativeTime (hours, days) - Add tests for invalid URL in sessions byInstance Coverage: Lines 100%, Branches 92.85%
|
🎉 This PR is included in version 6.56.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /for server monitoringChanges
New files
src/dashboard/metrics.ts— MetricsCollector aggregating data from InstanceRegistry, SessionManagersrc/dashboard/html-template.ts— Responsive HTML template with dark themesrc/dashboard/handler.ts— Express handler with Accept header content negotiationsrc/dashboard/index.ts— Barrel exportsModified files
src/config.ts— AddedDASHBOARD_ENABLEDenv var (default: true)src/server.ts— Registered GET / route before MCP middlewareFeatures
DASHBOARD_ENABLED=falseTest plan
Closes #275