-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·46 lines (35 loc) · 1.32 KB
/
server.js
File metadata and controls
executable file
·46 lines (35 loc) · 1.32 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
#!/usr/bin/env node
/**
* Modular MCP Server - Zero Dependencies
*
* A config-driven MCP server that loads plugins/tools from a JSON config file.
* Implements the Model Context Protocol (JSON-RPC 2.0 over stdio).
*/
import { readFileSync } from 'fs';
import { resolve } from 'path';
import PluginManager from './core/plugin-manager.js';
import { createServer } from './core/mcp-protocol.js';
import { logger } from './core/logger.js';
const CONFIG_FILE = process.argv[2] || 'config.json';
async function main() {
try {
// Load configuration
const configPath = resolve(CONFIG_FILE);
logger.info(`Loading configuration from: ${configPath}`);
const configData = readFileSync(configPath, 'utf8');
const config = JSON.parse(configData);
// Initialize plugin manager
const pluginManager = new PluginManager(config);
await pluginManager.loadPlugins();
logger.info(`Loaded ${pluginManager.getToolCount()} tools from ${pluginManager.getPluginCount()} plugins`);
// Create and start MCP server
const server = createServer(pluginManager, config);
logger.info('MCP Server started - waiting for requests on stdin/stdout');
// Start listening on stdin/stdout
server.listen();
} catch (err) {
logger.error('Failed to start MCP server:', err.message);
process.exit(1);
}
}
main();