server-simple.js•2.87 kB
import express from 'express';
import cors from 'cors';
/**
* 🏕️ TreePod Glamping - Agente Financiero Simple
* Servidor HTTP simple para pruebas con Claude Web
*/
const app = express();
const PORT = process.env.PORT || 3000;
// Middleware
app.use(cors({
origin: '*',
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization']
}));
app.use(express.json());
// Endpoint principal para MCP
app.post('/mcp', async (req, res) => {
try {
console.log('📞 Solicitud MCP recibida:', req.body);
res.json({
jsonrpc: '2.0',
id: req.body.id || 1,
result: {
name: 'treepod-financial-simple',
version: '1.0.0',
protocol: 'http',
status: 'connected',
message: '🏕️ TreePod Financial MCP - Conexión exitosa!',
tools: [
{
name: 'test_connection',
description: 'Prueba la conexión con TreePod Financial'
},
{
name: 'analyze_finances',
description: 'Analiza las finanzas del negocio'
},
{
name: 'calculate_rates',
description: 'Calcula tarifas óptimas'
},
{
name: 'check_occupancy',
description: 'Verifica estado de ocupación'
}
]
}
});
} catch (error) {
console.error('❌ Error en MCP:', error);
res.status(500).json({
jsonrpc: '2.0',
id: req.body.id || 1,
error: {
code: -32603,
message: 'Internal error',
data: error.message
}
});
}
});
// Endpoint de salud
app.get('/health', (req, res) => {
res.json({
status: 'healthy',
service: 'TreePod Financial MCP Simple',
version: '1.0.0',
protocol: 'http',
timestamp: new Date().toISOString(),
message: '🏕️ Servidor funcionando correctamente'
});
});
// Endpoint de información
app.get('/', (req, res) => {
res.json({
name: '🏕️ TreePod Financial MCP Simple Server',
description: 'Servidor MCP simple para pruebas con Claude Web',
version: '1.0.0',
protocol: 'http',
endpoints: {
mcp: '/mcp',
health: '/health'
},
status: 'running'
});
});
// Manejar todas las rutas OPTIONS para CORS
app.options('*', (req, res) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.sendStatus(200);
});
app.listen(PORT, () => {
console.log(`🏕️ TreePod Financial MCP Simple Server running on http://localhost:${PORT}`);
console.log(`📊 Health check: http://localhost:${PORT}/health`);
console.log(`🔗 MCP endpoint: http://localhost:${PORT}/mcp`);
console.log(`🌐 Listo para conectar con Claude Web`);
});