nimo007 commited on
Commit
635b668
·
verified ·
1 Parent(s): 16b048d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -3,17 +3,21 @@ import gradio as gr
3
  from datetime import datetime, timezone
4
 
5
  def now_utc():
 
 
 
 
 
6
  yield datetime.now(timezone.utc).isoformat()
7
 
8
- with gr.Blocks() as demo:
9
- gr.Markdown("# Datetime MCP Server (UTC)")
10
- out = gr.Textbox(label="Current Time (UTC)")
11
- btn = gr.Button("Get Time")
12
- btn.click(now_utc, None, out, stream=True)
13
-
14
- # IMPORTANT: `demo.queue()` is required for SSE streaming in Spaces
15
- demo.queue()
16
 
17
  if __name__ == "__main__":
18
- # We use share=False because Spaces already handles public URL.
19
- demo.launch(mcp_server=True, share=False)
 
3
  from datetime import datetime, timezone
4
 
5
  def now_utc():
6
+ """
7
+ Return the current time in ISO 8601 (UTC).
8
+ No inputs. Useful as a 'time' tool for MCP clients.
9
+ """
10
+ # generator -> streamable over HTTP/SSE (client will see a streamed event)
11
  yield datetime.now(timezone.utc).isoformat()
12
 
13
+ demo = gr.Interface(
14
+ fn=now_utc,
15
+ inputs=None,
16
+ outputs=gr.Textbox(label="UTC datetime (ISO 8601)"),
17
+ title="Datetime MCP Server",
18
+ description="Returns the current UTC datetime."
19
+ )
 
20
 
21
  if __name__ == "__main__":
22
+ # Starts the web UI and an MCP SSE endpoint; no authentication configured.
23
+ demo.launch(mcp_server=True)