feat: add group management functionality (#12)

This commit is contained in:
samanhappy
2025-04-17 18:55:04 +08:00
committed by GitHub
parent 6a065ca2f2
commit adef02d3b9
27 changed files with 1953 additions and 446 deletions

View File

@@ -1,6 +1,6 @@
import express from 'express';
import config from './config/index.js';
import { initMcpServer, registerAllTools } from './services/mcpService.js';
import { initMcpServer } from './services/mcpService.js';
import { initMiddlewares } from './middlewares/index.js';
import { initRoutes } from './routes/index.js';
import { handleSseConnection, handleSseMessage } from './services/sseService.js';
@@ -20,17 +20,24 @@ export class AppServer {
try {
// Migrate user data from users.json to mcp_settings.json if needed
migrateUserData();
// Initialize default admin user if no users exist
await initializeDefaultUser();
const mcpServer = await initMcpServer(config.mcpHubName, config.mcpHubVersion);
await registerAllTools(mcpServer, true);
initMiddlewares(this.app);
initRoutes(this.app);
this.app.get('/sse', (req, res) => handleSseConnection(req, res));
this.app.post('/messages', handleSseMessage);
console.log('Server initialized successfully');
initMcpServer(config.mcpHubName, config.mcpHubVersion)
.then(() => {
console.log('MCP server initialized successfully');
this.app.get('/sse/:groupId?', (req, res) => handleSseConnection(req, res));
this.app.post('/messages', handleSseMessage);
})
.catch((error) => {
console.error('Error initializing MCP server:', error);
throw error;
});
} catch (error) {
console.error('Error initializing server:', error);
throw error;