Files
Momento/mcp-server/test/server-start-test.js
Antigravity 0784c94242
Some checks failed
CI / Lint, Test & Build (push) Failing after 57s
CI / Deploy production (on server) (push) Has been skipped
feat(notes): vues structurées tableau/kanban, flashcards et MCP robuste
Ajoute la base organisable par carnet (schéma, champs partagés, valeurs par note)
avec activation guidée, tableau éditable, kanban et suppression de colonnes.
Corrige le multiselect en vue tableau et enrichit sidebar, grille et i18n FR/EN.
Inclut aussi les améliorations flashcards SM-2, l'audit consentement IA et la
robustesse du serveur MCP (config, validation, rate-limit, métriques).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-24 23:03:16 +00:00

101 lines
2.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Quick Server Start Test
* Tests that the server starts and responds to health checks
*/
import { spawn } from 'child_process';
import { request } from 'http';
const DATABASE_URL = process.env.DATABASE_URL || 'postgresql://memento:memento@localhost:5433/memento?schema=public';
const PORT = process.env.MCP_TEST_PORT || 3010;
console.log('═══════════════════════════════════════════════════');
console.log(' Memento MCP Server - Start Test');
console.log('═══════════════════════════════════════════════════\n');
const env = {
...process.env,
DATABASE_URL,
PORT: PORT.toString(),
MCP_REQUIRE_AUTH: 'false',
MCP_LOG_LEVEL: 'error',
};
console.log(`Starting server on port ${PORT}...`);
const server = spawn('node', ['index-sse.js'], {
cwd: new URL('..', import.meta.url).pathname,
env,
stdio: ['ignore', 'pipe', 'pipe'],
});
let output = '';
server.stdout.on('data', (data) => {
output += data.toString();
});
server.stderr.on('data', (data) => {
output += data.toString();
});
server.on('error', (err) => {
console.error('❌ Failed to start server:', err.message);
process.exit(1);
});
// Wait for server to start
setTimeout(() => {
console.log('Testing health endpoint...');
const options = {
hostname: 'localhost',
port: PORT,
path: '/health',
method: 'GET',
};
const req = request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
console.log('✅ Health check passed!');
console.log('Response:', data);
// Test metrics endpoint
request({ ...options, path: '/metrics' }, (mRes) => {
if (mRes.statusCode === 200) {
console.log('✅ Metrics endpoint available!');
}
shutdown();
}).on('error', shutdown);
} else {
console.error(`❌ Health check failed: ${res.statusCode}`);
console.error('Response:', data);
shutdown(1);
}
});
});
req.on('error', (err) => {
console.error('❌ Request failed:', err.message);
console.error('Server output:');
console.error(output);
shutdown(1);
});
req.end();
}, 2000);
function shutdown(code = 0) {
server.kill('SIGTERM');
setTimeout(() => {
server.kill('SIGKILL');
process.exit(code);
}, 2000);
}