mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
feat: Add initial MCP Server support
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#include <fmt/chrono.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <romfs/romfs.hpp>
|
||||
#include <toasts/toast_notification.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
@@ -103,6 +105,16 @@ namespace hex::plugin::builtin {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
void handleMCPServer() {
|
||||
if (!ContentRegistry::MCP::isEnabled()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
ContentRegistry::MCP::impl::getMcpServerInstance().disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
ContentRegistry::MCP::impl::getMcpServerInstance().listen();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void registerBackgroundServices() {
|
||||
@@ -110,12 +122,17 @@ namespace hex::plugin::builtin {
|
||||
s_networkInterfaceServiceEnabled = value.get<bool>(false);
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::onChange("hex.builtin.setting.general", "hex.builtin.setting.general.mcp_server", [](const ContentRegistry::Settings::SettingsValue &value) {
|
||||
ContentRegistry::MCP::impl::setEnabled(value.get<bool>(false));
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::onChange("hex.builtin.setting.general", "hex.builtin.setting.general.backups.auto_backup_time", [](const ContentRegistry::Settings::SettingsValue &value) {
|
||||
s_autoBackupTime = value.get<int>(0) * 30;
|
||||
});
|
||||
|
||||
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface", handleNetworkInterfaceService);
|
||||
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup", handleAutoBackup);
|
||||
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.mcp", handleMCPServer);
|
||||
|
||||
EventProviderDirtied::subscribe([](prv::Provider *) {
|
||||
s_dataDirty = true;
|
||||
|
||||
Reference in New Issue
Block a user