MakiAi commited on
Commit
226328e
·
verified ·
1 Parent(s): 289a833

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datetime import datetime, timedelta, timezone
3
+
4
+ def get_jp_time() -> str:
5
+ """
6
+ 現在の日本標準時 (JST) をISO 8601形式の文字列で取得します。
7
+
8
+ Args:
9
+ (なし)
10
+
11
+ Returns:
12
+ str: 現在の日本時間を示す文字列。
13
+ """
14
+ jst_timezone = timezone(timedelta(hours=+9), 'JST')
15
+ current_time_jst = datetime.now(jst_timezone).isoformat()
16
+ return f"現在の日本時間は {current_time_jst} です。"
17
+
18
+ # Gradioインターフェースを作成
19
+ # 関数名、docstring(関数の説明文)、型ヒントが自動的にMCPツールの情報になる
20
+ demo = gr.Interface(
21
+ fn=get_jp_time,
22
+ inputs=[], # 入力はなし
23
+ outputs="text",
24
+ title="日本時間 MCPサーバー",
25
+ description="現在の日本時間を返すツールを公開しています。"
26
+ )
27
+
28
+ if __name__ == "__main__":
29
+ # mcp_server=True を追加するだけでMCPサーバーが有効化される
30
+ # share=True で外部公開用のURLを生成
31
+ demo.launch(mcp_server=True, share=True)