Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.1.0
metadata
title: Date Time Mpc Server Tool
emoji: π
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 6.0.2
app_file: app_world_time_mcp_server.py
pinned: false
short_description: A minimal Gradio MCP server that provides timezone-aware dat
Berlin Time & World Time MCP Servers
This directory contains two example MCP (Model Context Protocol) servers built with Gradio.
π Available Servers
1. Simple Berlin Time (app_time_mcp_server.py)
- Function: Returns current time in Berlin.
- Complexity: Simple, no parameters.
- Port: 7860
- Best for: Learning the basics of MCP.
2. World Time (app_world_time_mcp_server.py)
- Function: Returns current time for 25+ major cities.
- Complexity: Takes a
cityparameter (e.g., "Tokyo", "New York"). - Port: 7860 (when deployed) / 7861 (local dev).
- Best for: Demonstrating tool arguments and dynamic responses.
π Local Testing
- Install dependencies:
pip install -r requirements.txt
- Run the server of your choice:
Option A: Berlin Time
python app_time_mcp_server.py
# Runs on http://localhost:7860
Option B: World Time
python app_world_time_mcp_server.py
# Runs on http://localhost:7861 (to avoid conflict)
- Open the URL in your browser to test the UI manually.
βοΈ Deploying to HuggingFace Spaces
- Create a new Space at huggingface.co/spaces
- Choose Gradio as the SDK.
- Upload your files.
β οΈ IMPORTANT: Deployment Checklist
1. Configure the Entry File (The "Pro" Way)
Instead of renaming your file to app.py, you can tell HuggingFace which file to run by editing the YAML Header at the very top of your README.md in the Space.
For Berlin Time: ```yaml
title: Berlin Time MCP emoji: π colorFrom: blue colorTo: indigo sdk: gradio sdk_version: 5.0.0 app_file: app_time_mcp_server.py <-- CHANGE THIS pinned: false
**For World Time:**
```yaml
---
title: World Time MCP
emoji: π
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.0.0
app_file: app_world_time_mcp_server.py <-- CHANGE THIS
pinned: false
---
2. Check the Port
HuggingFace Spaces REQUIRES the app to run on port 7860.
- If you use
app_world_time_mcp_server.py, changeserver_port=7861toserver_port=7860in the code before deploying. - If you don't do this, you will get an
OSError: Cannot find empty port.
Configuration for Your Agent
Once deployed, update your src/config/settings.py:
servers["berlin_time"] = {
"url": "https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME/gradio_api/mcp/",
"transport": "sse"
}
π Documentation
- Step-by-Step Guide: Detailed teaching guide.
- MCP Connection Flow: Visual diagram of how it works.