diff --git a/src/araxiaonline/mcp/AraxiaMCPServer.cpp b/src/araxiaonline/mcp/AraxiaMCPServer.cpp index 908cb07cf1..3137ed75d1 100644 --- a/src/araxiaonline/mcp/AraxiaMCPServer.cpp +++ b/src/araxiaonline/mcp/AraxiaMCPServer.cpp @@ -30,14 +30,18 @@ MCPServer::MCPServer() : _impl(std::make_unique()) MCPServer::~MCPServer() { // Note: During static destruction, other singletons may already be destroyed. - // We need to be careful not to access them. - try + // Shutdown() should have been called from World::~World() already. + // Just ensure the thread is properly cleaned up. + if (_serverThread) { - Shutdown(); - } - catch (...) - { - // Swallow any exceptions during destruction + if (_serverThread->joinable()) + { + // Thread still running - try to stop it + if (_impl) + _impl->server.stop(); + _serverThread->join(); + } + _serverThread.reset(); } }