mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-07 00:41:55 +00:00
mcp nice loading
This commit is contained in:
parent
08f69c1012
commit
01d1002dfb
4 changed files with 61 additions and 36 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import time
|
||||
from python.helpers.api import ApiHandler
|
||||
from flask import Request, Response
|
||||
|
||||
from typing import Any
|
||||
|
||||
# from python.helpers.mcp_handler import MCPConfig
|
||||
from python.helpers.mcp_handler import MCPConfig
|
||||
from python.helpers.settings import set_settings_delta
|
||||
|
||||
|
||||
|
|
@ -14,6 +15,9 @@ class McpServersApply(ApiHandler):
|
|||
# MCPConfig.update(mcp_servers) # done in settings automatically
|
||||
set_settings_delta({"mcp_servers": "[]"}) # to force reinitialization
|
||||
set_settings_delta({"mcp_servers": mcp_servers})
|
||||
|
||||
time.sleep(1) # wait at least a second
|
||||
MCPConfig.wait_for_lock() # wait until config lock is released
|
||||
|
||||
except Exception as e:
|
||||
return {"success": False, "error": str(e)}
|
||||
|
|
|
|||
|
|
@ -377,6 +377,11 @@ class MCPConfig(BaseModel):
|
|||
cls.__instance = cls(servers_list=[])
|
||||
return cls.__instance
|
||||
|
||||
@classmethod
|
||||
def wait_for_lock(cls):
|
||||
with cls.__lock:
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def update(cls, config_str: str) -> Any:
|
||||
with cls.__lock:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue