fix mcp list
This commit is contained in:
@@ -275,10 +275,16 @@ def serve_dashboard(host: str, port: int, status_file: str, *, image_dir: str |
|
|||||||
content = result.get("result", {}).get("content", [])
|
content = result.get("result", {}).get("content", [])
|
||||||
text = next((item.get("text", "") for item in content if isinstance(item, dict)), "")
|
text = next((item.get("text", "") for item in content if isinstance(item, dict)), "")
|
||||||
if isinstance(result.get("result"), dict) and result["result"].get("isError"):
|
if isinstance(result.get("result"), dict) and result["result"].get("isError"):
|
||||||
raise RuntimeError(str(text or "Graylog list_streams failed"))
|
fallback = client.call_tool("list_resource", {"resource_type": "stream"})
|
||||||
if not text:
|
resources = fallback.get("result", {}).get("structuredContent", {}).get("resources", [])
|
||||||
raise RuntimeError("Graylog list_streams returned no text content")
|
streams = [
|
||||||
streams = json.loads(text)
|
{"id": str(item.get("uri", "")).rsplit(":", 1)[-1], "title": item.get("title", item.get("name", "")), "description": item.get("description", "")}
|
||||||
|
for item in resources if isinstance(item, dict) and item.get("uri")
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
if not text:
|
||||||
|
raise RuntimeError("Graylog list_streams returned no text content")
|
||||||
|
streams = json.loads(text)
|
||||||
body = {"streams": streams, "selected": config.get("graylog_streams", [])}
|
body = {"streams": streams, "selected": config.get("graylog_streams", [])}
|
||||||
self._send(200, "application/json", json.dumps(body).encode("utf-8"))
|
self._send(200, "application/json", json.dumps(body).encode("utf-8"))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|||||||
Reference in New Issue
Block a user