Temporal Context & Datetime Resolution
5 tools for temporal orientation and datetime computation. All tools execute locally within the compiled MCP server binary — no external API calls, no network access at runtime, no credential files. The binary is installed once via npm (or built from source with Docker) and all subsequent executions are fully offline. No OAuth or credentials required. Timezone and week-start preferences are stored in config.json. Unset fields default to system timezone and Monday week-start.
Source & Provenance
Tools
| Tool | When to Use |
|---|
| INLINECODE1 | First call in any session. Returns current time, timezone, UTC offset, DST status, DST prediction, day of week. |
| INLINECODE2 |
Convert human expressions to RFC 3339. Supports 60+ patterns:
"next Tuesday at 2pm",
"tomorrow morning",
"+2h",
"start of next week",
"third Friday of March". |
|
convert_timezone | Convert RFC 3339 datetime between IANA timezones. |
|
compute_duration | Duration between two timestamps (days, hours, minutes). |
|
adjust_timestamp | DST-aware timestamp adjustment.
"+1d" across spring-forward = same wall-clock time. |
Runtime
These tools run inside the Temporal Cortex MCP server (@temporal-cortex/cortex-mcp), a compiled Rust binary distributed as an npm package.
Install and startup lifecycle:
- 1.
npx resolves @temporal-cortex/cortex-mcp from the npm registry (one-time, cached locally after first download) - The postinstall script downloads the platform-specific binary from the GitHub Release and verifies its SHA256 checksum against the embedded
checksums.json — installation halts on mismatch - The MCP server starts as a local process communicating over stdio (no listening ports)
- All 5 datetime tools execute locally — zero network access, zero filesystem writes, no credentials
Network access: Only during the initial npm download. Once cached, subsequent launches are fully offline. The 5 datetime tools make zero network requests — all computation is local.
File access: The binary reads ~/.config/temporal-cortex/config.json for timezone and week-start preferences. Unset or missing fields default to system values. No filesystem writes. No credential files accessed.
No credentials required. Unlike the scheduling skill, this skill needs no OAuth tokens or API keys.
Pre-run verification (recommended before first use):
- 1. Inspect the npm package without executing: INLINECODE17
- Verify checksums independently against the GitHub Release (see verification pipeline below)
- For full containment, run in Docker instead of npx (see Docker containment below)
Verification pipeline: Checksums are published independently at each GitHub Release as SHA256SUMS.txt — verify the binary before first use:
CODEBLOCK0
As defense-in-depth, the npm package also embeds checksums.json and the postinstall script compares SHA256 hashes during install — installation halts on mismatch (the binary is deleted, not executed). This automated check supplements, but does not replace, independent verification above.
Build provenance: Binaries are cross-compiled from auditable Rust source in GitHub Actions across 5 platforms (darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64). Source: github.com/temporal-cortex/mcp (MIT-licensed). The CI workflow, build artifacts, and release checksums are all publicly inspectable.
Docker containment (recommended for maximum isolation — zero Node.js dependency, zero host filesystem access, zero network after build):
CODEBLOCK1
Build: docker build -t cortex-mcp https://github.com/temporal-cortex/mcp.git — No volume mount needed since the datetime skill requires no OAuth tokens or credential files. The --network=none flag enforces the zero-network guarantee at the OS level.
Critical Rules
- 1. Always call
get_temporal_context before time-dependent work — never assume the time or timezone. - Resolve before querying — convert
"next Tuesday at 2pm" to RFC 3339 with resolve_datetime before passing to calendar tools. - Timezone awareness — all datetime tools produce RFC 3339 with timezone offsets.
resolve_datetime Expression Patterns
The expression parser supports 60+ patterns across 10 categories:
| Category | Examples |
|---|
| Relative | INLINECODE25 , "today", "tomorrow", INLINECODE28 |
| Named days |
"next Monday",
"this Friday",
"last Wednesday" |
| Time of day |
"morning" (09:00),
"noon",
"evening" (18:00),
"eob" (17:00) |
| Clock time |
"2pm",
"14:00",
"3:30pm" |
| Offsets |
"+2h",
"-30m",
"in 2 hours",
"3 days ago" |
| Compound |
"next Tuesday at 2pm",
"tomorrow morning",
"this Friday at noon" |
| Period boundaries |
"start of week",
"end of month",
"start of next week",
"end of last month" |
| Ordinal weekday |
"first Monday of March",
"third Friday of next month" |
| RFC 3339 passthrough |
"2026-03-15T14:00:00-04:00" (returned as-is) |
| Week start aware | Uses configured
WEEK_START (Monday default, Sunday option) |
Common Patterns
Get Current Time Context
CODEBLOCK2
Resolve a Meeting Time
CODEBLOCK3
Convert Across Timezones
CODEBLOCK4
Calculate Duration
CODEBLOCK5
DST-Aware Adjustment
CODEBLOCK6
Additional References
时间上下文与日期时间解析
用于时间定位和日期时间计算的5个工具。所有工具均在编译后的MCP服务器二进制文件中本地执行——无需外部API调用,运行时无需网络访问,无需凭证文件。该二进制文件通过npm一次性安装(或通过Docker从源码构建),后续所有执行完全离线。无需OAuth或凭证。时区和周起始偏好存储在config.json中。未设置的字段默认为系统时区和周一作为周起始。
来源与出处
工具
| 工具 | 使用时机 |
|---|
| gettemporalcontext | 任何会话中的首次调用。返回当前时间、时区、UTC偏移量、夏令时状态、夏令时预测、星期几。 |
| resolve_datetime |
将人类语言表达式转换为RFC 3339格式。支持60多种模式:下周二下午2点、明天早上、+2h、下周开始、三月的第三个星期五。 |
| convert_timezone | 在IANA时区之间转换RFC 3339日期时间。 |
| compute_duration | 两个时间戳之间的持续时间(天、小时、分钟)。 |
| adjust_timestamp | 支持夏令时感知的时间戳调整。跨越春令时的+1d = 相同的挂钟时间。 |
运行时
这些工具运行在Temporal Cortex MCP服务器(@temporal-cortex/cortex-mcp)内,这是一个编译后的Rust二进制文件,以npm包形式分发。
安装和启动生命周期:
- 1. npx从npm注册表解析@temporal-cortex/cortex-mcp(一次性,首次下载后本地缓存)
- postinstall脚本从GitHub Release下载平台特定二进制文件,并对照嵌入的checksums.json验证其SHA256校验和——校验和不匹配则安装终止
- MCP服务器作为本地进程启动,通过stdio通信(无监听端口)
- 所有5个日期时间工具均在本地执行——零网络访问、零文件系统写入、无凭证
网络访问: 仅在初始npm下载期间。一旦缓存,后续启动完全离线。5个日期时间工具零网络请求——所有计算均在本地进行。
文件访问: 二进制文件读取~/.config/temporal-cortex/config.json以获取时区和周起始偏好。未设置或缺失的字段默认为系统值。无文件系统写入。无凭证文件访问。
无需凭证。 与调度技能不同,此技能无需OAuth令牌或API密钥。
运行前验证(建议首次使用前执行):
- 1. 在不执行的情况下检查npm包:npm pack @temporal-cortex/cortex-mcp --dry-run
- 对照GitHub Release独立验证校验和(见下方验证流程)
- 为完全隔离,使用Docker而非npx运行(见下方Docker隔离)
验证流程: 校验和在每个GitHub Release中作为SHA256SUMS.txt独立发布——首次使用前验证二进制文件:
bash
1. 从GitHub获取校验和(独立于npm包)
curl -sL https://github.com/temporal-cortex/mcp/releases/download/mcp-v0.9.1/SHA256SUMS.txt
2. 与npm安装的二进制文件进行比较
shasum -a 256 $(npm root -g)/@temporal-cortex/cortex-mcp/bin/cortex-mcp
作为纵深防御,npm包还嵌入了checksums.json,postinstall脚本在安装期间比较SHA256哈希——校验和不匹配则安装终止(二进制文件被删除,不执行)。此自动检查补充但不替代上述独立验证。
构建出处: 二进制文件在GitHub Actions中从可审计的Rust源代码跨5个平台交叉编译(darwin-arm64、darwin-x64、linux-x64、linux-arm64、win32-x64)。源代码:github.com/temporal-cortex/mcp(MIT许可)。CI工作流、构建产物和发布校验和均可公开检查。
Docker隔离(建议用于最大隔离——零Node.js依赖、零主机文件系统访问、构建后零网络):
json
{
mcpServers: {
temporal-cortex: {
command: docker,
args: [run, --rm, -i, --network=none, cortex-mcp]
}
}
}
构建:docker build -t cortex-mcp https://github.com/temporal-cortex/mcp.git——无需挂载卷,因为日期时间技能不需要OAuth令牌或凭证文件。--network=none标志在操作系统级别强制执行零网络保证。
关键规则
- 1. 始终在时间相关工作前调用gettemporalcontext——切勿假设时间或时区。
- 查询前先解析——在传递给日历工具前,使用resolve_datetime将下周二下午2点转换为RFC 3339格式。
- 时区感知——所有日期时间工具生成带时区偏移的RFC 3339格式。
resolve_datetime表达式模式
表达式解析器支持10个类别的60多种模式:
下周一、这周五、上周三 |
| 一天中的时间 | 早上(09:00)、中午、晚上(18:00)、下班(17:00) |
| 时钟时间 | 下午2点、14:00、3:30pm |
| 偏移 | +2h、-30m、2小时后、3天前 |
| 复合 | 下周二下午2点、明天早上、这周五中午 |
| 周期边界 | 周开始、月末、下周开始、上月末 |
| 序数工作日 | 三月的第一个星期一、下个月的第三个星期五 |
| RFC 3339直通 | 2026-03-15T14:00:00-04:00(原样返回) |
| 周起始感知 | 使用配置的WEEK_START(默认为周一,可选周日) |
常见模式
获取当前时间上下文
gettemporalcontext()
→ utc, local, timezone, utcoffset, dstactive, dstnexttransition,
dayofweek, isoweek, isweekday, dayofyear, week_start
解析会议时间
resolve_datetime(下周二下午2点)
→ resolvedutc, resolvedlocal, timezone, interpretation
跨时区转换
- 1. gettemporalcontext → 用户的时区
- converttimezone(datetime: 2026-03-15T14:00:00-04:00, targettimezone: Asia/Tokyo)
→ 东京时间的同一时刻,包含夏令时和偏移信息
计算持续时间
compute_duration(start: 2026-03-15T09:00:00-04:00, end: 2026-03-15T17:30:00-04:00)
→ totalseconds: 30600, hours: 8, minutes: 30, humanreadable: 8小时30分钟
夏令时感知调整
adjust_timestamp(
datetime: 2026-03-07T23:00:00-05:00,
adjustment: +1d,
timezone: America/