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

Method sendError

src/mcp/server/MCPServer.ts:425–443  ·  view source on GitHub ↗

* 发送错误

(clientId: string, code: number, message: string, data?: any)

Source from the content-addressed store, hash-verified

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

Callers 4

handleConnectionMethod · 0.95
handleMessageMethod · 0.95
handleReadResourceMethod · 0.95
sendErrorToStdioMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected