-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-interface.html
More file actions
456 lines (377 loc) · 15.2 KB
/
web-interface.html
File metadata and controls
456 lines (377 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MCP Vale</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
}
.tool-section {
margin-bottom: 30px;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fafafa;
}
.tool-section h3 {
color: #2c5282;
margin-top: 0;
}
textarea {
width: 100%;
min-height: 120px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-family: monospace;
margin-bottom: 10px;
resize: vertical;
transition: border-color 0.2s ease, background-color 0.2s ease;
}
textarea.drag-over {
border-color: #4299e1;
background-color: #ebf8ff;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 10px;
}
button {
background-color: #4299e1;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
margin-bottom: 10px;
}
button:hover {
background-color: #3182ce;
}
button:disabled {
background-color: #a0aec0;
cursor: not-allowed;
}
.file-upload-section {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 15px;
padding: 15px;
background-color: #f8f9fa;
border: 2px dashed #d1d5db;
border-radius: 8px;
transition: border-color 0.2s ease;
}
.file-upload-section:hover {
border-color: #4299e1;
}
.file-info {
flex: 1;
min-width: 200px;
font-size: 0.9em;
color: #666;
}
input[type="file"] {
display: none;
}
.result {
background-color: #f7fafc;
border: 1px solid #e2e8f0;
border-radius: 4px;
padding: 15px;
margin-top: 15px;
white-space: pre-wrap;
font-family: monospace;
max-height: 400px;
overflow-y: auto;
}
.error {
background-color: #fed7d7;
border-color: #fc8181;
color: #c53030;
}
.success {
background-color: #c6f6d5;
border-color: #68d391;
color: #2d7738;
}
.loading {
color: #4299e1;
font-style: italic;
}
.status-indicator {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
margin-right: 8px;
}
.status-online {
background-color: #48bb78;
}
.status-offline {
background-color: #f56565;
}
</style>
</head>
<body>
<div class="container">
<h1>🚀 MCP Vale Interface</h1>
<div class="tool-section">
<h3>📊 Status do Sistema</h3>
<button onclick="checkStatus()">Verificar Status</button>
<button onclick="checkValeStatus()">Status do Vale</button>
<div id="status-result" class="result" style="display:none;"></div>
</div>
<div class="tool-section">
<h3>🔍 Lint de Texto com Vale</h3>
<div class="file-upload-section">
<input type="file" id="file-upload" accept=".md,.mdx,.txt" onchange="handleFileUpload(event)">
<button onclick="document.getElementById('file-upload').click()" style="background-color: #38a169;">
📁 Carregar Arquivo MD/MDX
</button>
<button onclick="clearText()" style="background-color: #e53e3e;">
🗑️ Limpar Texto
</button>
<div id="file-info" class="file-info">
Formatos suportados: .md, .mdx, .txt (máximo 1MB)
</div>
</div>
<textarea id="lint-text" placeholder="Cole seu texto aqui para verificar com Vale, carregue um arquivo MD/MDX usando o botão acima, ou arraste um arquivo para esta área...">Este é um exemplo de texto para testar o Vale.
Você pode utilizar esta ferramenta para verificar a qualidade do seu texto. É muito útil para garantir que o conteúdo esteja bem escrito.
Algumas palavras podem estar repetidas repetidas para testar o sistema.</textarea>
<input type="text" id="lint-filename" placeholder="Nome do arquivo (opcional, ex: documento.md)" value="documento.md">
<button onclick="lintText()">🔍 Fazer Lint</button>
<div id="lint-result" class="result" style="display:none;"></div>
</div>
</div>
<script>
// URL do servidor HTTP MCP (quando estiver rodando)
const MCP_SERVER_URL = 'http://localhost:3000';
let serverRunning = false;
// Verificar se o servidor está rodando
async function checkServerStatus() {
try {
const response = await fetch(MCP_SERVER_URL);
serverRunning = response.ok;
return serverRunning;
} catch (error) {
serverRunning = false;
return false;
}
}
function showResult(elementId, content, isError = false) {
const element = document.getElementById(elementId);
element.style.display = 'block';
element.className = `result ${isError ? 'error' : 'success'}`;
element.textContent = content;
}
function showLoading(elementId) {
const element = document.getElementById(elementId);
element.style.display = 'block';
element.className = 'result loading';
element.textContent = '⏳ Processando...';
}
async function makeAPIRequest(endpoint, method = 'GET', body = null) {
const isServerRunning = await checkServerStatus();
if (!isServerRunning) {
return {
error: true,
message: `❌ Servidor MCP não está rodando!
Para usar com dados reais:
1. Abra um novo terminal
2. Execute: cd /Users/paulogpd/Documents/GitHub/mcp-server-docs/mcp-google-docs
3. Execute: npm run http
4. Aguarde aparecer "🚀 Servidor HTTP rodando na porta 3000"
5. Recarregue esta página e teste novamente
Ou use o CLI: npm run cli`
};
}
try {
const options = {
method: method,
headers: {
'Content-Type': 'application/json',
}
};
if (body) {
options.body = JSON.stringify(body);
}
const response = await fetch(MCP_SERVER_URL + endpoint, options);
const data = await response.json();
if (data.result && data.result.content) {
return {
error: false,
content: data.result.content[0].text
};
} else if (data.error) {
return {
error: true,
message: data.error
};
} else {
return {
error: false,
content: JSON.stringify(data, null, 2)
};
}
} catch (error) {
return {
error: true,
message: `Erro na requisição: ${error.message}`
};
}
}
async function checkStatus() {
showLoading('status-result');
const isServerRunning = await checkServerStatus();
if (isServerRunning) {
showResult('status-result', `✅ Status do Sistema:
🚀 Servidor MCP HTTP: Online (porta 3000)
🔗 Interface Web: Conectada
📡 Comunicação: Funcionando
✅ Sistema totalmente operacional!
Agora você pode testar as funcionalidades reais.`);
} else {
showResult('status-result', `❌ Status do Sistema:
🚀 Servidor MCP HTTP: Offline
🔗 Interface Web: Modo demonstração
📡 Comunicação: Indisponível
Para ativar o servidor real:
1. Abra terminal: cd /Users/paulogpd/Documents/GitHub/mcp-server-docs/mcp-google-docs
2. Execute: npm run http
3. Recarregue esta página`, true);
}
}
async function checkValeStatus() {
showLoading('status-result');
const result = await makeAPIRequest('/vale/status');
if (result.error) {
showResult('status-result', result.message, true);
} else {
showResult('status-result', result.content);
}
}
async function handleFileUpload(event) {
const file = event.target.files[0];
if (!file) return;
// Verificar se é um arquivo suportado
const supportedExtensions = ['.md', '.mdx', '.txt'];
const fileExtension = '.' + file.name.split('.').pop().toLowerCase();
if (!supportedExtensions.includes(fileExtension)) {
showResult('lint-result', `❌ Formato de arquivo não suportado: ${fileExtension}
Formatos aceitos: .md, .mdx, .txt`, true);
return;
}
// Verificar tamanho do arquivo (máximo 1MB)
if (file.size > 1024 * 1024) {
showResult('lint-result', '❌ Arquivo muito grande. Tamanho máximo: 1MB', true);
return;
}
try {
const text = await file.text();
document.getElementById('lint-text').value = text;
document.getElementById('lint-filename').value = file.name;
// Mostrar informações do arquivo
const fileInfo = document.getElementById('file-info');
fileInfo.innerHTML = `✅ <strong>Arquivo carregado:</strong> ${file.name} <span style="color: #666;">(${(file.size / 1024).toFixed(1)} KB)</span>`;
fileInfo.style.color = '#38a169';
// Limpar resultados anteriores
document.getElementById('lint-result').style.display = 'none';
} catch (error) {
showResult('lint-result', `❌ Erro ao ler o arquivo: ${error.message}`, true);
}
}
function clearText() {
document.getElementById('lint-text').value = '';
document.getElementById('lint-filename').value = 'documento.md';
// Resetar informações do arquivo
const fileInfo = document.getElementById('file-info');
fileInfo.innerHTML = 'Formatos suportados: .md, .mdx, .txt (máximo 1MB)';
fileInfo.style.color = '#666';
document.getElementById('lint-result').style.display = 'none';
// Limpar o input de arquivo
document.getElementById('file-upload').value = '';
}
async function lintText() {
const text = document.getElementById('lint-text').value;
const fileName = document.getElementById('lint-filename').value || 'documento.md';
if (!text.trim()) {
showResult('lint-result', 'Por favor, insira um texto para fazer lint ou carregue um arquivo.', true);
return;
}
showLoading('lint-result');
const result = await makeAPIRequest('/vale/lint', 'POST', {
text: text,
fileName: fileName
});
if (result.error) {
showResult('lint-result', result.message, true);
} else {
showResult('lint-result', result.content);
}
}
// Funções para drag-and-drop
function setupDragAndDrop() {
const textarea = document.getElementById('lint-text');
textarea.addEventListener('dragover', function(e) {
e.preventDefault();
textarea.classList.add('drag-over');
});
textarea.addEventListener('dragleave', function(e) {
e.preventDefault();
textarea.classList.remove('drag-over');
});
textarea.addEventListener('drop', function(e) {
e.preventDefault();
textarea.classList.remove('drag-over');
const files = e.dataTransfer.files;
if (files.length > 0) {
// Simular o evento de upload de arquivo
const event = { target: { files: [files[0]] } };
handleFileUpload(event);
}
});
}
// Inicializar a página
document.addEventListener('DOMContentLoaded', async function() {
console.log('🚀 MCP Vale Interface carregada');
// Configurar drag-and-drop
setupDragAndDrop();
// Verificar status do servidor automaticamente
const isRunning = await checkServerStatus();
if (isRunning) {
console.log('✅ Servidor MCP detectado - modo operacional');
document.querySelector('h1').innerHTML = '🚀 MCP Vale Interface <span style="color: #48bb78;">●</span>';
} else {
console.log('⚠️ Servidor MCP não detectado - modo demonstração');
document.querySelector('h1').innerHTML = '🚀 MCP Vale Interface <span style="color: #f56565;">●</span>';
}
});
</script>
</body>
</html>