File size: 2,975 Bytes
be7261c
 
 
 
 
 
 
b0547d6
be7261c
 
 
 
c23f78d
5aa3cbc
c23f78d
5aa3cbc
c23f78d
5aa3cbc
c23f78d
 
 
 
 
5aa3cbc
c23f78d
 
 
 
 
 
 
 
 
5aa3cbc
 
 
 
 
 
c23f78d
 
 
5aa3cbc
 
c23f78d
 
 
 
 
 
 
5aa3cbc
 
c23f78d
 
 
5aa3cbc
c23f78d
5aa3cbc
 
c23f78d
 
5aa3cbc
c23f78d
5aa3cbc
c23f78d
 
5aa3cbc
c23f78d
 
 
 
 
 
 
 
 
 
 
 
 
5aa3cbc
c23f78d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aa3cbc
c23f78d
5aa3cbc
c23f78d
5aa3cbc
c23f78d
 
 
 
5aa3cbc
 
 
c23f78d
 
 
5aa3cbc
c23f78d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
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 `city` parameter (e.g., "Tokyo", "New York").
- **Port:** 7860 (when deployed) / 7861 (local dev).
- **Best for:** Demonstrating tool arguments and dynamic responses.

---

## πŸš€ Local Testing

1. Install dependencies:
```bash
pip install -r requirements.txt
```

2. Run the server of your choice:

**Option A: Berlin Time**
```bash
python app_time_mcp_server.py
# Runs on http://localhost:7860
```

**Option B: World Time**
```bash
python app_world_time_mcp_server.py
# Runs on http://localhost:7861 (to avoid conflict)
```

3. Open the URL in your browser to test the UI manually.

---

## ☁️ Deploying to HuggingFace Spaces

1. Create a new Space at [huggingface.co/spaces](https://huggingface.co/spaces)
2. Choose **Gradio** as the SDK.
3. 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`, **change `server_port=7861` to `server_port=7860`** in 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`:

```python
servers["berlin_time"] = {
    "url": "https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME/gradio_api/mcp/",
    "transport": "sse"
}
```

---

## πŸ“š Documentation

- [Step-by-Step Guide](STEP_BY_STEP_GUIDE.md): Detailed teaching guide.
- [MCP Connection Flow](../.gemini/antigravity/brain/26cb67ea-9995-44cc-8251-52a912873dc8/mcp_connection_flow.md): Visual diagram of how it works.