mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-09 17:08:29 +00:00
Add project-scoped MCP server configuration with global/project merge semantics, a richer settings UI, and chat composer access. Introduce MCP config scanning plus project-aware status/detail/log/apply APIs while preserving the raw JSON editor. Strengthen MCP runtime handling for dotted tool names, timeouts, status accuracy, and project-aware tool execution, with focused regression coverage.
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
import time
|
|
from helpers.api import ApiHandler, Request, Response
|
|
|
|
from typing import Any
|
|
|
|
from helpers.mcp_handler import MCPConfig
|
|
from helpers.settings import set_settings_delta
|
|
from helpers import projects
|
|
|
|
|
|
class McpServersApply(ApiHandler):
|
|
async def process(self, input: dict[Any, Any], request: Request) -> dict[Any, Any] | Response:
|
|
mcp_servers = input["mcp_servers"]
|
|
project_name = str(input.get("project_name", "") or "").strip()
|
|
try:
|
|
if project_name:
|
|
projects.save_project_mcp_servers(project_name, mcp_servers)
|
|
config = MCPConfig.refresh_project(project_name)
|
|
else:
|
|
# 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
|
|
config = MCPConfig.get_instance()
|
|
status = config.get_servers_status()
|
|
return {"success": True, "status": status, "mcp_servers": mcp_servers, "project_name": project_name}
|
|
|
|
except Exception as e:
|
|
return {"success": False, "error": str(e)}
|