* 发送 JSON 响应,并附带 MCP 所需的基础 CORS 头。
(res: ServerResponse, statusCode: number, body: unknown)
| 181 | * 发送 JSON 响应,并附带 MCP 所需的基础 CORS 头。 |
| 182 | */ |
| 183 | private sendRawJson(res: ServerResponse, statusCode: number, body: unknown): void { |
| 184 | res.writeHead(statusCode, { |
| 185 | 'Content-Type': 'application/json; charset=utf-8', |
| 186 | 'Access-Control-Allow-Origin': '*', |
| 187 | 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', |
| 188 | 'Access-Control-Allow-Headers': 'Content-Type, Authorization' |
| 189 | }) |
| 190 | res.end(JSON.stringify(body)) |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * 返回空响应,主要用于 OPTIONS 和 JSON-RPC notification。 |
no test coverage detected