MCP refactor

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Jokob @NetAlertX
2025-12-07 08:37:55 +00:00
committed by GitHub
parent 8c982cd476
commit 5d1c63375b
3 changed files with 4 additions and 6 deletions

View File

@@ -418,7 +418,7 @@ def api_devices_search():
if is_mac(query):
device_data = get_device_data(query)
if device_data:
if device_data.status_code == 200:
return jsonify({"success": True, "devices": [device_data.get_json()]})
else:
return jsonify({"success": False, "error": "Device not found"}), 404
@@ -574,7 +574,7 @@ def api_trigger_scan():
@app.route('/mcp/sse/openapi.json', methods=['GET'])
def api_openapi_spec():
if not is_authorized():
return jsonify({"Success": False, "error": "Unauthorized"}), 401
return jsonify({"success": False, "error": "Unauthorized"}), 401
return openapi_spec()

View File

@@ -57,16 +57,13 @@ def openapi_spec():
# Sessions for SSE
_sessions = {}
_sessions_lock = __import__('threading').Lock()
_openapi_spec_cache = None
API_BASE_URL = f"http://localhost:{get_setting_value('GRAPHQL_PORT')}"
def get_openapi_spec():
global _openapi_spec_cache
# Clear cache on each call for now to ensure fresh spec
_openapi_spec_cache = None
if _openapi_spec_cache:
return _openapi_spec_cache
try:

View File

@@ -32,6 +32,7 @@ class EventInstance:
ORDER BY eve_DateTime DESC
LIMIT ?
""", (n,)).fetchall()
conn.close()
return self._rows_to_list(rows)
# --- Specific helper for last 10 ---