* 发送错误
(clientId: string, code: number, message: string, data?: any)
| 423 | * 发送错误 |
| 424 | */ |
| 425 | private sendError(clientId: string, code: number, message: string, data?: any): void { |
| 426 | const response: MCPMessage = { |
| 427 | jsonrpc: '2.0', |
| 428 | error: { |
| 429 | code, |
| 430 | message, |
| 431 | data, |
| 432 | }, |
| 433 | }; |
| 434 | |
| 435 | if (clientId === 'stdio') { |
| 436 | process.stdout.write(JSON.stringify(response) + '\n'); |
| 437 | } else { |
| 438 | const client = this.clients.get(clientId); |
| 439 | if (client) { |
| 440 | client.send(JSON.stringify(response)); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * 发送错误到 Stdio |
no test coverage detected