code-auditor-mcp 1.19.0 β 1.21.0
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/analyzers/schemaAnalyzer.d.ts +21 -0
- package/dist/analyzers/schemaAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/schemaAnalyzer.js +405 -0
- package/dist/analyzers/schemaAnalyzer.js.map +1 -0
- package/dist/auditRunner.d.ts.map +1 -1
- package/dist/auditRunner.js +5 -1
- package/dist/auditRunner.js.map +1 -1
- package/dist/codeIndexDb.d.ts +98 -1
- package/dist/codeIndexDb.d.ts.map +1 -1
- package/dist/codeIndexDb.js +277 -0
- package/dist/codeIndexDb.js.map +1 -1
- package/dist/mcp-hybrid.d.ts +10 -0
- package/dist/mcp-hybrid.d.ts.map +1 -0
- package/dist/mcp-hybrid.js +41 -0
- package/dist/mcp-hybrid.js.map +1 -0
- package/dist/mcp-index.d.ts +11 -0
- package/dist/mcp-index.d.ts.map +1 -0
- package/dist/mcp-index.js +101 -0
- package/dist/mcp-index.js.map +1 -0
- package/dist/mcp-tools/workflowGuide.d.ts.map +1 -1
- package/dist/mcp-tools/workflowGuide.js +67 -10
- package/dist/mcp-tools/workflowGuide.js.map +1 -1
- package/dist/mcp-tools-shared.d.ts +46 -0
- package/dist/mcp-tools-shared.d.ts.map +1 -0
- package/dist/mcp-tools-shared.js +1161 -0
- package/dist/mcp-tools-shared.js.map +1 -0
- package/dist/mcp-ui-server.d.ts +27 -0
- package/dist/mcp-ui-server.d.ts.map +1 -0
- package/dist/mcp-ui-server.js +484 -0
- package/dist/mcp-ui-server.js.map +1 -0
- package/dist/mcp-ui-simple.d.ts +27 -0
- package/dist/mcp-ui-simple.d.ts.map +1 -0
- package/dist/mcp-ui-simple.js +425 -0
- package/dist/mcp-ui-simple.js.map +1 -0
- package/dist/mcp.js +122 -24
- package/dist/mcp.js.map +1 -1
- package/dist/services/CodeMapGenerator.d.ts +32 -0
- package/dist/services/CodeMapGenerator.d.ts.map +1 -1
- package/dist/services/CodeMapGenerator.js +169 -1
- package/dist/services/CodeMapGenerator.js.map +1 -1
- package/dist/services/SchemaParser.d.ts +89 -0
- package/dist/services/SchemaParser.d.ts.map +1 -0
- package/dist/services/SchemaParser.js +434 -0
- package/dist/services/SchemaParser.js.map +1 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/examples/schema-example.json +364 -0
- package/examples/schema-example.yaml +137 -0
- package/package.json +9 -2
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Simple MCP-UI HTTP Server for Code Auditor
|
|
4
|
+
*
|
|
5
|
+
* This provides HTTP endpoints that return UI resources for interactive dashboards
|
|
6
|
+
* while reusing all the existing audit tool logic.
|
|
7
|
+
*/
|
|
8
|
+
import express from 'express';
|
|
9
|
+
import cors from 'cors';
|
|
10
|
+
import { randomUUID } from 'crypto';
|
|
11
|
+
import { createUIResource } from '@mcp-ui/server';
|
|
12
|
+
import { ToolHandlers } from './mcp-tools-shared.js';
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
const app = express();
|
|
15
|
+
const PORT = process.env.MCP_UI_PORT || 3001;
|
|
16
|
+
// Middleware
|
|
17
|
+
app.use(express.json());
|
|
18
|
+
app.use(cors({
|
|
19
|
+
origin: '*',
|
|
20
|
+
exposedHeaders: ['Content-Type'],
|
|
21
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
22
|
+
}));
|
|
23
|
+
/**
|
|
24
|
+
* API endpoint to run audit and return UI resource
|
|
25
|
+
*/
|
|
26
|
+
app.post('/api/audit-dashboard', async (req, res) => {
|
|
27
|
+
try {
|
|
28
|
+
const args = req.body || {};
|
|
29
|
+
// Run the audit using shared handler
|
|
30
|
+
const auditResult = await ToolHandlers.handleAudit(args);
|
|
31
|
+
// Create session-specific data storage key
|
|
32
|
+
const sessionKey = randomUUID();
|
|
33
|
+
// Store audit results for dashboard access
|
|
34
|
+
global.auditSessions = global.auditSessions || new Map();
|
|
35
|
+
global.auditSessions.set(sessionKey, {
|
|
36
|
+
auditResult,
|
|
37
|
+
timestamp: new Date().toISOString(),
|
|
38
|
+
path: args.path || '.'
|
|
39
|
+
});
|
|
40
|
+
// Generate UI resource pointing to dashboard
|
|
41
|
+
const uiResource = createUIResource({
|
|
42
|
+
uri: `ui://code-auditor/dashboard/${sessionKey}`,
|
|
43
|
+
content: {
|
|
44
|
+
type: 'externalUrl',
|
|
45
|
+
iframeUrl: `http://localhost:${PORT}/dashboard/${sessionKey}`
|
|
46
|
+
},
|
|
47
|
+
encoding: 'text'
|
|
48
|
+
});
|
|
49
|
+
res.json({
|
|
50
|
+
success: true,
|
|
51
|
+
uiResource,
|
|
52
|
+
sessionKey,
|
|
53
|
+
summary: auditResult.summary
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(chalk.red('[API ERROR]'), 'Audit dashboard failed:', error);
|
|
58
|
+
res.status(500).json({
|
|
59
|
+
success: false,
|
|
60
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* API endpoint to run code map and return UI resource
|
|
66
|
+
*/
|
|
67
|
+
app.post('/api/code-map-viewer', async (req, res) => {
|
|
68
|
+
try {
|
|
69
|
+
const args = req.body || {};
|
|
70
|
+
// Generate audit result to get code map
|
|
71
|
+
const auditResult = await ToolHandlers.handleAudit({
|
|
72
|
+
...args,
|
|
73
|
+
generateCodeMap: true,
|
|
74
|
+
indexFunctions: true
|
|
75
|
+
});
|
|
76
|
+
const sessionKey = randomUUID();
|
|
77
|
+
global.codeMapSessions = global.codeMapSessions || new Map();
|
|
78
|
+
global.codeMapSessions.set(sessionKey, {
|
|
79
|
+
codeMap: auditResult.codeMap,
|
|
80
|
+
timestamp: new Date().toISOString(),
|
|
81
|
+
path: args.path || '.'
|
|
82
|
+
});
|
|
83
|
+
const uiResource = createUIResource({
|
|
84
|
+
uri: `ui://code-auditor/codemap/${sessionKey}`,
|
|
85
|
+
content: {
|
|
86
|
+
type: 'externalUrl',
|
|
87
|
+
iframeUrl: `http://localhost:${PORT}/codemap/${sessionKey}`
|
|
88
|
+
},
|
|
89
|
+
encoding: 'text'
|
|
90
|
+
});
|
|
91
|
+
res.json({
|
|
92
|
+
success: true,
|
|
93
|
+
uiResource,
|
|
94
|
+
sessionKey,
|
|
95
|
+
codeMap: auditResult.codeMap?.summary
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error(chalk.red('[API ERROR]'), 'Code map viewer failed:', error);
|
|
100
|
+
res.status(500).json({
|
|
101
|
+
success: false,
|
|
102
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Dashboard route - serves the interactive audit dashboard
|
|
108
|
+
*/
|
|
109
|
+
app.get('/dashboard/:sessionKey', (req, res) => {
|
|
110
|
+
const { sessionKey } = req.params;
|
|
111
|
+
const sessionData = global.auditSessions?.get(sessionKey);
|
|
112
|
+
if (!sessionData) {
|
|
113
|
+
return res.status(404).send(`
|
|
114
|
+
<html><body>
|
|
115
|
+
<h1>Audit Session Not Found</h1>
|
|
116
|
+
<p>Session key: ${sessionKey}</p>
|
|
117
|
+
<p>This session may have expired or been cleaned up.</p>
|
|
118
|
+
</body></html>
|
|
119
|
+
`);
|
|
120
|
+
}
|
|
121
|
+
const { auditResult } = sessionData;
|
|
122
|
+
const violations = ToolHandlers.getAllViolations(auditResult).slice(0, 50);
|
|
123
|
+
// Enhanced dashboard HTML
|
|
124
|
+
const dashboardHtml = `
|
|
125
|
+
<!DOCTYPE html>
|
|
126
|
+
<html lang="en">
|
|
127
|
+
<head>
|
|
128
|
+
<meta charset="UTF-8">
|
|
129
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
130
|
+
<title>Code Audit Dashboard</title>
|
|
131
|
+
<style>
|
|
132
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
133
|
+
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f8fafc; color: #2d3748; }
|
|
134
|
+
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
|
|
135
|
+
.header {
|
|
136
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
137
|
+
color: white; padding: 30px; border-radius: 12px; margin-bottom: 30px;
|
|
138
|
+
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
|
|
139
|
+
}
|
|
140
|
+
.header h1 { font-size: 2.5rem; margin-bottom: 10px; }
|
|
141
|
+
.header p { font-size: 1.1rem; opacity: 0.9; }
|
|
142
|
+
.stats-grid {
|
|
143
|
+
display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
144
|
+
gap: 20px; margin-bottom: 30px;
|
|
145
|
+
}
|
|
146
|
+
.stat-card {
|
|
147
|
+
background: white; padding: 25px; border-radius: 12px;
|
|
148
|
+
box-shadow: 0 4px 15px rgba(0,0,0,0.08); border-left: 4px solid #667eea;
|
|
149
|
+
transition: transform 0.2s;
|
|
150
|
+
}
|
|
151
|
+
.stat-card:hover { transform: translateY(-2px); }
|
|
152
|
+
.stat-card h3 { color: #4a5568; margin-bottom: 15px; font-size: 1.1rem; }
|
|
153
|
+
.stat-value { font-size: 2rem; font-weight: bold; color: #2d3748; margin-bottom: 5px; }
|
|
154
|
+
.stat-label { color: #718096; font-size: 0.9rem; }
|
|
155
|
+
.severity-critical { border-left-color: #e53e3e; }
|
|
156
|
+
.severity-warning { border-left-color: #dd6b20; }
|
|
157
|
+
.severity-info { border-left-color: #3182ce; }
|
|
158
|
+
.violations-section {
|
|
159
|
+
background: white; border-radius: 12px;
|
|
160
|
+
box-shadow: 0 4px 15px rgba(0,0,0,0.08); overflow: hidden;
|
|
161
|
+
}
|
|
162
|
+
.section-header {
|
|
163
|
+
background: #f7fafc; padding: 20px; border-bottom: 1px solid #e2e8f0;
|
|
164
|
+
}
|
|
165
|
+
.section-header h2 { color: #2d3748; font-size: 1.5rem; }
|
|
166
|
+
.filters { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }
|
|
167
|
+
.filter-btn {
|
|
168
|
+
padding: 8px 16px; border: 1px solid #e2e8f0; background: white;
|
|
169
|
+
border-radius: 6px; cursor: pointer; transition: all 0.2s;
|
|
170
|
+
}
|
|
171
|
+
.filter-btn:hover, .filter-btn.active {
|
|
172
|
+
background: #667eea; color: white; border-color: #667eea;
|
|
173
|
+
}
|
|
174
|
+
.violations-list { max-height: 600px; overflow-y: auto; }
|
|
175
|
+
.violation {
|
|
176
|
+
padding: 20px; border-bottom: 1px solid #f1f5f9; transition: background 0.2s;
|
|
177
|
+
}
|
|
178
|
+
.violation:hover { background: #f8fafc; }
|
|
179
|
+
.violation:last-child { border-bottom: none; }
|
|
180
|
+
.violation-title {
|
|
181
|
+
font-weight: 600; color: #2d3748; font-size: 1.1rem; margin-bottom: 5px;
|
|
182
|
+
}
|
|
183
|
+
.violation-meta {
|
|
184
|
+
display: flex; gap: 15px; font-size: 0.9rem; color: #718096; margin-bottom: 10px;
|
|
185
|
+
}
|
|
186
|
+
.violation-file {
|
|
187
|
+
font-family: 'Monaco', 'Menlo', monospace; background: #f7fafc;
|
|
188
|
+
padding: 4px 8px; border-radius: 4px;
|
|
189
|
+
}
|
|
190
|
+
.severity-badge {
|
|
191
|
+
padding: 4px 8px; border-radius: 4px; font-size: 0.8rem;
|
|
192
|
+
font-weight: 600; text-transform: uppercase;
|
|
193
|
+
}
|
|
194
|
+
.severity-critical { background: #fed7d7; color: #c53030; }
|
|
195
|
+
.severity-warning { background: #feebc8; color: #c05621; }
|
|
196
|
+
.severity-info { background: #bee3f8; color: #2c5aa0; }
|
|
197
|
+
.recommendation {
|
|
198
|
+
background: #f0fff4; border: 1px solid #9ae6b4; border-radius: 6px;
|
|
199
|
+
padding: 12px; margin-top: 10px;
|
|
200
|
+
}
|
|
201
|
+
.recommendation::before { content: "π‘ "; font-size: 1.2rem; }
|
|
202
|
+
.health-score { text-align: center; padding: 20px; }
|
|
203
|
+
.health-circle {
|
|
204
|
+
width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 15px;
|
|
205
|
+
display: flex; align-items: center; justify-content: center;
|
|
206
|
+
font-size: 2rem; font-weight: bold; color: white;
|
|
207
|
+
}
|
|
208
|
+
.loading { text-align: center; padding: 40px; color: #718096; }
|
|
209
|
+
</style>
|
|
210
|
+
</head>
|
|
211
|
+
<body>
|
|
212
|
+
<div class="container">
|
|
213
|
+
<div class="header">
|
|
214
|
+
<h1>π Code Audit Dashboard</h1>
|
|
215
|
+
<p>Interactive analysis results for ${sessionData.path} β’ ${auditResult.summary?.filesAnalyzed || 0} files analyzed</p>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div class="stats-grid">
|
|
219
|
+
<div class="stat-card">
|
|
220
|
+
<h3>π Health Score</h3>
|
|
221
|
+
<div class="health-score">
|
|
222
|
+
<div class="health-circle" style="background: ${(auditResult.summary?.healthScore || 0) >= 80 ? '#48bb78' : (auditResult.summary?.healthScore || 0) >= 60 ? '#ed8936' : '#f56565'}">
|
|
223
|
+
${auditResult.summary?.healthScore || 0}%
|
|
224
|
+
</div>
|
|
225
|
+
<div class="stat-label">Overall code quality</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<div class="stat-card severity-critical">
|
|
230
|
+
<h3>π¨ Critical Issues</h3>
|
|
231
|
+
<div class="stat-value">${auditResult.summary?.criticalIssues || 0}</div>
|
|
232
|
+
<div class="stat-label">Requires immediate attention</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div class="stat-card severity-warning">
|
|
236
|
+
<h3>β οΈ Warnings</h3>
|
|
237
|
+
<div class="stat-value">${auditResult.summary?.warnings || 0}</div>
|
|
238
|
+
<div class="stat-label">Should be addressed</div>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div class="stat-card severity-info">
|
|
242
|
+
<h3>π‘ Suggestions</h3>
|
|
243
|
+
<div class="stat-value">${auditResult.summary?.suggestions || 0}</div>
|
|
244
|
+
<div class="stat-label">Improvement opportunities</div>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div class="violations-section">
|
|
249
|
+
<div class="section-header">
|
|
250
|
+
<h2>π¨ Violations</h2>
|
|
251
|
+
<div class="filters">
|
|
252
|
+
<button class="filter-btn active" onclick="filterViolations('all')">All</button>
|
|
253
|
+
<button class="filter-btn" onclick="filterViolations('critical')">Critical</button>
|
|
254
|
+
<button class="filter-btn" onclick="filterViolations('warning')">Warnings</button>
|
|
255
|
+
<button class="filter-btn" onclick="filterViolations('info')">Info</button>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div class="violations-list" id="violations-list">
|
|
260
|
+
${violations.length === 0 ? '<div class="loading">No violations found! π</div>' :
|
|
261
|
+
violations.map(violation => `
|
|
262
|
+
<div class="violation" data-severity="${violation.severity}">
|
|
263
|
+
<div class="violation-title">${violation.message}</div>
|
|
264
|
+
<div class="violation-meta">
|
|
265
|
+
<span class="violation-file">${violation.file}:${violation.line}:${violation.column}</span>
|
|
266
|
+
<span class="severity-badge severity-${violation.severity}">${violation.severity}</span>
|
|
267
|
+
<span>Analyzer: ${violation.analyzer}</span>
|
|
268
|
+
</div>
|
|
269
|
+
${violation.recommendation ? `<div class="recommendation">${violation.recommendation}</div>` : ''}
|
|
270
|
+
</div>
|
|
271
|
+
`).join('')}
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<script>
|
|
277
|
+
let allViolations = ${JSON.stringify(violations)};
|
|
278
|
+
|
|
279
|
+
function filterViolations(severity) {
|
|
280
|
+
const buttons = document.querySelectorAll('.filter-btn');
|
|
281
|
+
buttons.forEach(btn => btn.classList.remove('active'));
|
|
282
|
+
event.target.classList.add('active');
|
|
283
|
+
|
|
284
|
+
const violationsList = document.getElementById('violations-list');
|
|
285
|
+
let filteredViolations = severity === 'all' ? allViolations : allViolations.filter(v => v.severity === severity);
|
|
286
|
+
|
|
287
|
+
violationsList.innerHTML = filteredViolations.length === 0
|
|
288
|
+
? '<div class="loading">No violations found for this filter.</div>'
|
|
289
|
+
: filteredViolations.map(violation => createViolationHTML(violation)).join('');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function createViolationHTML(violation) {
|
|
293
|
+
return \`
|
|
294
|
+
<div class="violation" data-severity="\${violation.severity}">
|
|
295
|
+
<div class="violation-title">\${violation.message}</div>
|
|
296
|
+
<div class="violation-meta">
|
|
297
|
+
<span class="violation-file">\${violation.file}:\${violation.line}:\${violation.column}</span>
|
|
298
|
+
<span class="severity-badge severity-\${violation.severity}">\${violation.severity}</span>
|
|
299
|
+
<span>Analyzer: \${violation.analyzer}</span>
|
|
300
|
+
</div>
|
|
301
|
+
\${violation.recommendation ? \`<div class="recommendation">\${violation.recommendation}</div>\` : ''}
|
|
302
|
+
</div>
|
|
303
|
+
\`;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
console.log('π― Interactive Audit Dashboard Loaded');
|
|
307
|
+
console.log('π Audit Data:', {
|
|
308
|
+
totalViolations: ${auditResult.summary?.totalViolations || 0},
|
|
309
|
+
healthScore: ${auditResult.summary?.healthScore || 0},
|
|
310
|
+
filesAnalyzed: ${auditResult.summary?.filesAnalyzed || 0}
|
|
311
|
+
});
|
|
312
|
+
</script>
|
|
313
|
+
</body>
|
|
314
|
+
</html>
|
|
315
|
+
`;
|
|
316
|
+
res.send(dashboardHtml);
|
|
317
|
+
});
|
|
318
|
+
/**
|
|
319
|
+
* Code map viewer route
|
|
320
|
+
*/
|
|
321
|
+
app.get('/codemap/:sessionKey', (req, res) => {
|
|
322
|
+
const { sessionKey } = req.params;
|
|
323
|
+
const sessionData = global.codeMapSessions?.get(sessionKey);
|
|
324
|
+
if (!sessionData) {
|
|
325
|
+
return res.status(404).send(`
|
|
326
|
+
<html><body>
|
|
327
|
+
<h1>Code Map Session Not Found</h1>
|
|
328
|
+
<p>Session key: ${sessionKey}</p>
|
|
329
|
+
</body></html>
|
|
330
|
+
`);
|
|
331
|
+
}
|
|
332
|
+
const { codeMap } = sessionData;
|
|
333
|
+
const codeMapHtml = `
|
|
334
|
+
<!DOCTYPE html>
|
|
335
|
+
<html lang="en">
|
|
336
|
+
<head>
|
|
337
|
+
<meta charset="UTF-8">
|
|
338
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
339
|
+
<title>Interactive Code Map</title>
|
|
340
|
+
<style>
|
|
341
|
+
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
|
|
342
|
+
.header { background: #059669; color: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
|
|
343
|
+
.content { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
344
|
+
pre { background: #f8f9fa; padding: 15px; border-radius: 4px; overflow-x: auto; }
|
|
345
|
+
</style>
|
|
346
|
+
</head>
|
|
347
|
+
<body>
|
|
348
|
+
<div class="header">
|
|
349
|
+
<h1>πΊοΈ Interactive Code Map</h1>
|
|
350
|
+
<p>Navigable codebase structure and analysis</p>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
<div class="content">
|
|
354
|
+
<h2>π Map Summary</h2>
|
|
355
|
+
<p><strong>Map ID:</strong> ${codeMap?.mapId || 'N/A'}</p>
|
|
356
|
+
<p><strong>Total Sections:</strong> ${codeMap?.summary?.totalSections || 0}</p>
|
|
357
|
+
|
|
358
|
+
<h2>π Quick Preview</h2>
|
|
359
|
+
<pre>${codeMap?.quickPreview || 'No preview available'}</pre>
|
|
360
|
+
|
|
361
|
+
${codeMap?.summary?.sectionsAvailable ? `
|
|
362
|
+
<h2>π Available Sections</h2>
|
|
363
|
+
${codeMap.summary.sectionsAvailable.map(section => `
|
|
364
|
+
<div style="margin: 10px 0; padding: 10px; background: #f8f9fa; border-radius: 4px;">
|
|
365
|
+
<strong>${section.type}</strong> (${section.size} characters)<br>
|
|
366
|
+
<em>${section.description}</em>
|
|
367
|
+
</div>
|
|
368
|
+
`).join('')}
|
|
369
|
+
` : ''}
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
<script>
|
|
373
|
+
console.log('πΊοΈ Code Map Viewer Loaded');
|
|
374
|
+
</script>
|
|
375
|
+
</body>
|
|
376
|
+
</html>
|
|
377
|
+
`;
|
|
378
|
+
res.send(codeMapHtml);
|
|
379
|
+
});
|
|
380
|
+
/**
|
|
381
|
+
* Health check endpoint
|
|
382
|
+
*/
|
|
383
|
+
app.get('/health', (req, res) => {
|
|
384
|
+
res.json({
|
|
385
|
+
status: 'healthy',
|
|
386
|
+
timestamp: new Date().toISOString(),
|
|
387
|
+
version: '1.0.0',
|
|
388
|
+
mode: 'ui-server'
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
/**
|
|
392
|
+
* API endpoint to get audit data as JSON
|
|
393
|
+
*/
|
|
394
|
+
app.get('/api/audit/:sessionKey', (req, res) => {
|
|
395
|
+
const { sessionKey } = req.params;
|
|
396
|
+
const sessionData = global.auditSessions?.get(sessionKey);
|
|
397
|
+
if (!sessionData) {
|
|
398
|
+
return res.status(404).json({ error: 'Audit session not found' });
|
|
399
|
+
}
|
|
400
|
+
res.json(sessionData);
|
|
401
|
+
});
|
|
402
|
+
/**
|
|
403
|
+
* Start the MCP-UI HTTP server
|
|
404
|
+
*/
|
|
405
|
+
export function startMcpUIServer() {
|
|
406
|
+
app.listen(PORT, () => {
|
|
407
|
+
console.error(chalk.green('π MCP-UI Code Auditor Server running on'), chalk.cyan(`http://localhost:${PORT}`));
|
|
408
|
+
console.error(chalk.blue('π‘ API endpoints:'));
|
|
409
|
+
console.error(chalk.blue(' POST'), chalk.cyan(`http://localhost:${PORT}/api/audit-dashboard`));
|
|
410
|
+
console.error(chalk.blue(' POST'), chalk.cyan(`http://localhost:${PORT}/api/code-map-viewer`));
|
|
411
|
+
console.error(chalk.blue('β€οΈ Health check:'), chalk.cyan(`http://localhost:${PORT}/health`));
|
|
412
|
+
console.error(chalk.gray('Ready to serve interactive audit interfaces...'));
|
|
413
|
+
});
|
|
414
|
+
// Graceful shutdown
|
|
415
|
+
process.on('SIGINT', () => {
|
|
416
|
+
console.error(chalk.yellow('\nπ Shutting down MCP-UI server...'));
|
|
417
|
+
process.exit(0);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
// Start the server if this file is run directly
|
|
421
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
422
|
+
startMcpUIServer();
|
|
423
|
+
}
|
|
424
|
+
export { app };
|
|
425
|
+
//# sourceMappingURL=mcp-ui-simple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-ui-simple.js","sourceRoot":"","sources":["../src/mcp-ui-simple.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAkB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,GAAG,GAAwB,OAAO,EAAE,CAAC;AAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;AAE7C,aAAa;AACb,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACxB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;IACX,MAAM,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