You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 91f1ab7
Browse filesBrowse the repository at this point in the historyBrowse files
-`get_current_time` - Get current time in a specific timezone or system timezone.
14
-
-Required arguments:
15
-
-`timezone` (string): IANA timezone name (e.g., 'America/New_York', 'Europe/London')
14
+
-Optional arguments:
15
+
-`timezone` (string): IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Defaults to the server's local timezone.
16
16
17
17
-`convert_time` - Convert time between timezones.
18
18
- Required arguments:
19
-
-`source_timezone` (string): Source IANA timezone name
20
19
-`time` (string): Time in 24-hour format (HH:MM)
21
-
-`target_timezone` (string): Target IANA timezone name
20
+
- Optional arguments:
21
+
-`source_timezone` (string): Source IANA timezone name. Defaults to the server's local timezone.
22
+
-`target_timezone` (string): Target IANA timezone name. Defaults to the server's local timezone.
22
23
23
24
A timezone name, here and in `--local-timezone`, must be an exact IANA key, case included: `Europe/Warsaw` is accepted and `europe/warsaw` is rejected on every platform, including macOS, whose case-insensitive filesystem would otherwise resolve it.
24
25
@@ -208,7 +209,7 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
208
209
209
210
### Customization - System Timezone
210
211
211
-
By default, the server automatically detects your system's timezone. You can override this by adding the argument `--local-timezone` to the `args` list in the configuration.
212
+
By default, the server automatically detects your system's timezone. You can override this by adding the argument `--local-timezone` to the `args` list in the configuration. This local timezone is also what a tool uses for a timezone argument the call omits, and each tool's input schema names it as that argument's `default`. An explicitly empty timezone is still an error.
212
213
213
214
Example:
214
215
```json
@@ -288,7 +289,7 @@ npx @modelcontextprotocol/inspector uv run mcp-server-time
288
289
289
290
## Examples of Questions for Claude
290
291
291
-
1. "What time is it now?" (will use system timezone)
292
+
1. "What time is it now?" (the timezone can be omitted: the server uses its local timezone)
292
293
2. "What time is it in Tokyo?"
293
294
3. "When it's 4 PM in New York, what time is it in London?"
Copy file name to clipboardExpand all lines: src/time/src/mcp_server_time/server.py
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -230,9 +230,9 @@ def get_current_time(
230
230
timezone: Annotated[
231
231
str,
232
232
Field(
233
-
description=f"IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use '{local_tz}' as local timezone if no timezone provided by the user."
233
+
description=f"IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Optional: defaults to the server's local timezone, '{local_tz}', when omitted."
234
234
),
235
-
],
235
+
]=local_tz,
236
236
) ->TimeResult:
237
237
require("timezone", timezone)
238
238
returntime_server.get_current_time(timezone)
@@ -243,21 +243,24 @@ def get_current_time(
243
243
annotations=READ_ONLY,
244
244
)
245
245
defconvert_time(
246
+
# Keyword-only, so the required `time` can keep its place between the
247
+
# two optional timezones and the schema keeps its property order.
248
+
*,
246
249
source_timezone: Annotated[
247
250
str,
248
251
Field(
249
-
description=f"Source IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use '{local_tz}' as local timezone if no source timezone provided by the user."
252
+
description=f"Source IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Optional: defaults to the server's local timezone, '{local_tz}', when omitted."
250
253
),
251
-
],
254
+
]=local_tz,
252
255
time: Annotated[
253
256
str, Field(description="Time to convert in 24-hour format (HH:MM)")
254
257
],
255
258
target_timezone: Annotated[
256
259
str,
257
260
Field(
258
-
description=f"Target IANA timezone name (e.g., 'Asia/Tokyo', 'America/San_Francisco'). Use '{local_tz}' as local timezone if no target timezone provided by the user."
261
+
description=f"Target IANA timezone name (e.g., 'Asia/Tokyo', 'America/San_Francisco'). Optional: defaults to the server's local timezone, '{local_tz}', when omitted."
0 commit comments