Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import gradio as gr
|
| 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)
|