* 处理 Stdio 连接
()
| 132 | * 处理 Stdio 连接 |
| 133 | */ |
| 134 | private handleStdioConnection(): void { |
| 135 | process.stdin.on('data', async data => { |
| 136 | try { |
| 137 | const lines = data.toString().trim().split('\n'); |
| 138 | for (const line of lines) { |
| 139 | if (line.trim()) { |
| 140 | const message = JSON.parse(line); |
| 141 | await this.handleMessage('stdio', message); |
| 142 | } |
| 143 | } |
| 144 | } catch (error) { |
| 145 | this.sendErrorToStdio(-32700, 'Parse error', error); |
| 146 | } |
| 147 | }); |
| 148 | |
| 149 | console.log('MCP Server listening on stdio'); |
| 150 | this.emit('started', { transport: 'stdio' }); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * 处理消息 |
no test coverage detected