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 718e8d1
Browse filesBrowse the repository at this point in the historyBrowse files
-`source_timezone` (string): Source IANA timezone name. Defaults to the server's local timezone.
22
22
-`target_timezone` (string): Target IANA timezone name. Defaults to the server's local timezone.
23
23
24
+
-`get_time_ago` - Get the time a given number of days, hours, minutes and seconds ago in a specific timezone, for questions such as "what happened in the last 5 hours?".
25
+
- Optional arguments:
26
+
-`timezone` (string): IANA timezone name; defaults to the server's local timezone
27
+
-`days_ago`, `hours_ago`, `minutes_ago`, `seconds_ago` (non-negative JSON integers, default 0; a fraction, numeric string or boolean is rejected): how far back to go. They add up, so two and a half hours ago is `hours_ago: 2, minutes_ago: 30`.
28
+
- The offset is elapsed time, counted back from the current instant, so across a daylight-saving change "a day ago" is exactly 24 hours ago and its wall-clock reading can differ from now by an hour. An offset reaching before year 1 is an error.
29
+
24
30
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.
25
31
26
32
### Protocol versions
@@ -274,6 +280,27 @@ Response (`structuredContent`, and the same JSON as text):
274
280
}
275
281
```
276
282
283
+
3. Get a past time:
284
+
```json
285
+
{
286
+
"name": "get_time_ago",
287
+
"arguments": {
288
+
"timezone": "Europe/Warsaw",
289
+
"hours_ago": 2,
290
+
"minutes_ago": 30
291
+
}
292
+
}
293
+
```
294
+
Response (`structuredContent`, and the same JSON as text):
295
+
```json
296
+
{
297
+
"timezone": "Europe/Warsaw",
298
+
"datetime": "2024-01-01T10:30:00+01:00",
299
+
"day_of_week": "Monday",
300
+
"is_dst": false
301
+
}
302
+
```
303
+
277
304
## Debugging
278
305
279
306
You can use the MCP inspector to debug the server. For uvx installations:
@@ -295,6 +322,7 @@ npx @modelcontextprotocol/inspector uv run mcp-server-time
295
322
2. "What time is it in Tokyo?"
296
323
3. "When it's 4 PM in New York, what time is it in London?"
returntime_server.convert_time(source_timezone, time, target_timezone)
320
352
353
+
@server.tool(
354
+
name=TimeTools.GET_TIME_AGO.value,
355
+
description=(
356
+
"Get the time a given number of days, hours, minutes and seconds "
357
+
"ago in a specific timezone"
358
+
),
359
+
annotations=READ_ONLY,
360
+
)
361
+
defget_time_ago(
362
+
timezone: Annotated[
363
+
str,
364
+
Field(
365
+
description=f"IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Optional: defaults to the server's local timezone, '{local_tz}', when omitted."
366
+
),
367
+
] =local_tz,
368
+
days_ago: Annotated[
369
+
int, Field(description="Whole days before now", ge=0, strict=True)
370
+
] =0,
371
+
hours_ago: Annotated[
372
+
int, Field(description="Whole hours before now", ge=0, strict=True)
373
+
] =0,
374
+
minutes_ago: Annotated[
375
+
int, Field(description="Whole minutes before now", ge=0, strict=True)
376
+
] =0,
377
+
seconds_ago: Annotated[
378
+
int, Field(description="Whole seconds before now", ge=0, strict=True)
0 commit comments