| 258 | } |
| 259 | |
| 260 | void MCPServer::_server_loop() { |
| 261 | should_stop = false; |
| 262 | bridge_thread.start(_bridge_thread_func, this); |
| 263 | fprintf(stderr, "[MCP] Redot MCP Server started\n"); |
| 264 | fflush(stderr); |
| 265 | |
| 266 | while (!should_stop) { |
| 267 | String line = _read_line(); |
| 268 | if (line.is_empty()) { |
| 269 | if (should_stop) { |
| 270 | break; |
| 271 | } |
| 272 | continue; |
| 273 | } |
| 274 | line = line.strip_edges(); |
| 275 | if (line.is_empty()) { |
| 276 | continue; |
| 277 | } |
| 278 | |
| 279 | if (protocol && !should_stop) { |
| 280 | String response = protocol->process_string(line); |
| 281 | if (!response.is_empty()) { |
| 282 | _write_line(response); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | should_stop = true; |
| 288 | bridge_thread.wait_to_finish(); |
| 289 | fprintf(stderr, "[MCP] Redot MCP Server stopped\n"); |
| 290 | fflush(stderr); |
| 291 | } |
| 292 | |
| 293 | void MCPServer::start() { |
| 294 | bool expected = false; |
nothing calls this directly
no test coverage detected