MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _server_loop

Method _server_loop

modules/mcp/mcp_server.cpp:260–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void 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
293void MCPServer::start() {
294 bool expected = false;

Callers

nothing calls this directly

Calls 5

strip_edgesMethod · 0.80
process_stringMethod · 0.80
startMethod · 0.45
is_emptyMethod · 0.45
wait_to_finishMethod · 0.45

Tested by

no test coverage detected