File size: 2,230 Bytes
69c7d0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# app.py
<html>
<head>
<meta charset="utf-8">
<title>Sequential Thinking MCP - Status</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body { font-family: Inter, Arial, sans-serif; background:#0f172a; color:#e6eef8; display:flex;align-items:center;justify-content:center;min-height:100vh; }
.card { background:linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)); padding:24px; border-radius:12px; width:720px; box-shadow:0 6px 24px rgba(2,6,23,0.6); }
a { color: #60a5fa }
pre { background: #071029; padding:12px; border-radius:8px; overflow:auto }
</style>
</head>
<body>
<div class="card">
<h2>Sequential Thinking MCP Server</h2>
<p>حالة الخادم: <strong>{{status}}</strong></p>
<p>عنوان الخادم الداخلي: <code>http://127.0.0.1:{{mcp_port}}</code></p>
<p>روابط مفيدة:</p>
<ul>
<li><a href="/health" target="_blank">/health</a> — تحقق من استجابة MCP server</li>
<li><a href="/tools" target="_blank">/tools</a> — وصف الأدوات المكتشفة (إن وُجدت)</li>
</ul>
<hr>
<h4>ملاحظات التشغيل</h4>
<pre>لتشغيل محليًا:
docker build -t hf-seqthink .
docker run -p 7860:7860 -p 8080:8080 hf-seqthink
</pre>
</div>
</body>
</html>
"""


@app.route('/')
def index():
try:
r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5)
status = 'UP' if r.status_code == 200 else f'DEGRADED ({r.status_code})'
except Exception as e:
status = f'DOWN ({e})'
return render_template_string(HTML, status=status, mcp_port=MCP_PORT)


@app.route('/health')
def health():
try:
r = requests.get(f"http://127.0.0.1:{MCP_PORT}/health", timeout=1.5)
return (r.text, r.status_code, {'Content-Type': 'text/plain'})
except Exception as e:
return jsonify({'status':'down','error':str(e)}), 503


@app.route('/tools')
def tools():
# بعض خوادم MCP تكشف endpoints أخرى؛ نحاول قراءة root JSON إن وُجد
try:
r = requests.get(f"http://127.0.0.1:{MCP_PORT}/", timeout=1.5)
return (r.text, r.status_code, {'Content-Type': 'text/html'})
except Exception as e:
return jsonify({'status':'down','error':str(e)}), 503


if __name__ == '__main__':
app.run(host='0.0.0.0', port=7860)