Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
demo.queue()
|
| 16 |
|
| 17 |
if __name__ == "__main__":
|
| 18 |
-
#
|
| 19 |
-
demo.launch(mcp_server=True
|
|
|
|
| 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)
|