MCPcopy Create free account
hub / github.com/echoVic/blade-code / start

Method start

src/mcp/server/MCPServer.ts:67–86  ·  view source on GitHub ↗

* 启动服务器

()

Source from the content-addressed store, hash-verified

65 * 启动服务器
66 */
67 async start(): Promise<void> {
68 const port = this.config.port || 3001;
69 const host = this.config.host || 'localhost';
70
71 if (this.config.transport === 'ws') {
72 this.server = createServer();
73 this.wsServer = new WebSocketServer({ server: this.server });
74
75 this.wsServer.on('connection', (ws, request) => {
76 this.handleConnection(ws, request);
77 });
78
79 this.server.listen(port, host, () => {
80 console.log(`MCP Server listening on ws://${host}:${port}`);
81 this.emit('started', { host, port });
82 });
83 } else if (this.config.transport === 'stdio') {
84 this.handleStdioConnection();
85 }
86 }
87
88 /**
89 * 停止服务器

Callers 3

mcpCommandFunction · 0.95
toolsCommandFunction · 0.45
configCommandFunction · 0.45

Calls 5

handleConnectionMethod · 0.95
handleStdioConnectionMethod · 0.95
onMethod · 0.45
logMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected