TimezoneToolkit MCP Server
An advanced MCP (Model Context Protocol) server providing comprehensive time and timezone tools with enhanced features beyond basic conversion.
可用工具
| 工具 | 说明 |
|---|---|
| convert_time | 将时间从一个时区转换为另一个时区 |
| get_current_time | 获取指定时区的当前时间 |
| calculate_sunrise_sunset | 计算特定位置和日期的日出、日落和黄昏时间 |
| calculate_moon_phase | 计算特定日期的月相 |
| calculate_timezone_difference | 计算两个时区之间的时差 |
| list_timezones | 列出可用的IANA时区,可选择按地区筛选 |
| calculate_countdown | 计算直到特定日期/事件的剩余时间 |
| calculate_business_days | 计算两个日期之间的工作日(不包括周末) |
| format_date | 以各种样式设置日期格式 |
🌟 特性
🕒 基本时区转换
- 在任何IANA时区之间转换时间
- 获取任何时区的当前时间
- 以各种风格(短、中、全)格式化时间
- 以小时/分钟为单位计算时差
- 列出可用的IANA时区
🌅 日出/日落和天文计算
- 计算任何地点的日出和日落时间
- 包括黄昏时间(民用、航海、天文)
- 计算任何地点/日期的日长
- 计算任何日期的月相
📅 日期和时间实用程序
- 设置各种样式的日期格式(短、中、全、ISO、相对)
- 计算日期之间的工作日
- 为未来事件创建倒计时器
- 支持多个地区和时区
💻 安装
先决条件
- Node.js 18.x或更高版本-TimezoneToolkit MCP服务器需要Node.js 18+才能正常运行。
设置
要使用Node.js npx运行TimezoneToolkit MCP服务器,请使用以下命令:
npx -y @cicatriz/timezone-toolkit@latest客户端特定安装
光标
要将此服务器添加到Cursor IDE,请执行以下操作:
- 转到光标设置>MCP
- 单击+添加新的全局MCP服务器
- 将以下配置添加到全局
.cursor/mcp.json文件:
{
"mcpServers": {
"timezone-toolkit": {
"command": "npx",
"args": [
"-y",
"@cicatriz/timezone-toolkit"
]
}
}
}请参阅 光标文档 了解更多详情。
帆板运动
要使用Cascade设置MCP,请导航到Windsurf-设置>高级设置或命令面板>打开Windsurf设置页面。
向下滚动到Cascade部分,并将TimezoneToolkit MCP服务器直接添加到 mcp_config.json:
{
"mcpServers": {
"timezone-toolkit": {
"command": "npx",
"args": [
"-y",
"@cicatriz/timezone-toolkit"
]
}
}
}克莱恩
手动将以下JSON添加到您的 cline_mcp_settings.json 通过临床MCP服务器设置:
{
"mcpServers": {
"timezone-toolkit": {
"command": "npx",
"args": [
"-y",
"@cicatriz/timezone-toolkit"
]
}
}
}Roo代码
通过单击Roo Code设置中的Edit MCP settings或使用VS Code命令面板中的Roo Code:Open MCP Config命令来访问MCP设置:
{
"mcpServers": {
"timezone-toolkit": {
"command": "npx",
"args": [
"-y",
"@cicatriz/timezone-toolkit"
]
}
}
}克劳德
将以下内容添加到您的 claude_desktop_config.json 文件:
{
"mcpServers": {
"timezone-toolkit": {
"command": "npx",
"args": [
"-y",
"@cicatriz/timezone-toolkit"
]
}
}
}请参阅 Claude桌面文档 了解更多详情。
命令行界面
您还可以通过运行以下命令将其作为CLI运行:
npx -y @cicatriz/timezone-toolkit@latest替代安装方法
从npm安装
# Install globally from npm
npm install -g @cicatriz/timezone-toolkit
# Run the server
timezone-toolkit手动安装
# Clone the repository
git clone https://github.com/Cicatriiz/timezone-toolkit.git
cd timezone-toolkit
# Install dependencies
npm install
# Build the project
npm run build
# Run the server
node dist/index.js💬 使用Claude Desktop
安装后,您可以将TimezoneToolkit与Claude Desktop一起使用:
- 打开克劳德桌面
- 开始新的对话
- 点击锤子图标查看可用工具
- 选择任何TimezoneToolkit工具
🔗 API访问
TimezoneToolkit还提供了一个RESTful API,用于在没有Claude Desktop的情况下访问其功能:
启动API服务器
# Using npm
npm install -g @cicatriz/timezone-toolkit
node server.jsAPI服务器将在http://localhost:3000
API终点
GET /api/tools-列出所有可用工具POST /api/convert-time-在时区之间转换时间POST /api/current-time-获取时区中的当前时间POST /api/sunrise-sunset-计算日出/日落时间POST /api/moon-phase-计算月相POST /api/timezone-difference-计算时区差异POST /api/list-timezones-列出可用时区POST /api/countdown-计算日期倒计时POST /api/business-days-计算日期之间的工作日POST /api/format-date-设置日期格式
有关API的详细文档,请参阅 API自述.
查询示例
- “东京现在几点了?”
- “将纽约时间下午3:00转换为伦敦时间”
- “旧金山明天几点日出?”
- “今天巴黎的日落是什么时候?”
- “现在的月相是什么?”
- “纽约和东京的时差是多少?”
- “显示欧洲时区列表”
- “3月1日至4月15日有多少个工作日?”
- “在法语区域设置今天的日期格式”
- “离除夕还有多少时间?”
🔧 可用工具
1.转换时间
将时间从一个时区转换为另一个时区。
参数:
time(可选):转换时间(ISO字符串或自然语言)。如果未提供,则默认为当前时间。fromTimezone:来源IANA时区名称(例如,“美国/纽约”)toTimezone:目标IANA时区名称(例如,“欧洲/伦敦”)format(可选):输出格式(“短”、“中”、“全”)。默认为“中等”
例子:
{
"time": "2023-12-25T14:30:00",
"fromTimezone": "America/New_York",
"toTimezone": "Asia/Tokyo",
"format": "full"
}答复:
{
"originalTime": "2023-12-25T14:30:00.000-05:00",
"convertedTime": "Tuesday, December 26, 2023, 4:30:00 AM Japan Standard Time",
"fromTimezone": "America/New_York",
"toTimezone": "Asia/Tokyo",
"timeDifference": "+14 hours"
}2.get_current_time
获取指定时区的当前时间。
参数:
timezone:IANA时区名称(例如,“亚洲/东京”)format(可选):输出格式(“短”、“中”、“全”)。默认为“中等”
例子:
{
"timezone": "Europe/London",
"format": "full"
}答复:
{
"currentTime": "Monday, March 25, 2025, 10:15:30 PM British Summer Time",
"timezone": "Europe/London",
"utcOffset": "+01:00"
}3.计算_未运行_未设置
计算特定位置和日期的日出、日落和黄昏时间。
参数:
date(可选):计算日期(ISO字符串或自然语言)。默认为当前日期。latitude:位置纬度(-90到90)longitude:位置经度(-180至180)timezone(可选):IANA时区名称(例如,“欧洲/巴黎”)。默认为UTC。
例子:
{
"date": "2023-06-21",
"latitude": 37.7749,
"longitude": -122.4194,
"timezone": "America/Los_Angeles"
}答复:
{
"date": "2023-06-21",
"sunrise": "05:48:11 AM",
"sunset": "08:35:13 PM",
"civilTwilight": {
"dawn": "05:17:22 AM",
"dusk": "09:06:02 PM"
},
"nauticalTwilight": {
"dawn": "04:38:43 AM",
"dusk": "09:44:41 PM"
},
"astronomicalTwilight": {
"dawn": "03:52:50 AM",
"dusk": "10:30:34 PM"
},
"dayLength": "14 hours 47 minutes",
"timezone": "America/Los_Angeles"
}4.计算月相
计算特定日期的月相。
参数:
date(可选):计算日期(ISO字符串或自然语言)。默认为当前日期。timezone(可选):IANA时区名称(例如,“欧洲/巴黎”)。默认为UTC。
例子:
{
"date": "2023-01-06",
"timezone": "UTC"
}答复:
{
"date": "2023-01-06",
"phase": 0.998,
"phaseName": "Full Moon",
"illumination": 0.997,
"timezone": "UTC"
}5.计算时区差异
计算两个时区之间的时差。
参数:
fromTimezone:来源IANA时区名称(例如,“美国/纽约”)toTimezone:目标IANA时区名称(例如,“欧洲/伦敦”)
例子:
{
"fromTimezone": "America/New_York",
"toTimezone": "Asia/Tokyo"
}答复:
{
"fromTimezone": "America/New_York",
"toTimezone": "Asia/Tokyo",
"timeDifference": "+14 hours",
"currentTimeFrom": "3/25/2025, 6:15 PM",
"currentTimeTo": "3/26/2025, 8:15 AM",
"hoursDifference": 14,
"minutesDifference": 0,
"totalMinutesDifference": 840,
"direction": "ahead"
}6.列出时区
列出可用的IANA时区,可选择按地区过滤。
参数:
region(可选):按地区过滤时区(例如,“美洲”、“欧洲”、“亚洲”)
例子:
{
"region": "Europe"
}答复:
{
"timezones": [
{
"timezone": "Europe/Amsterdam",
"currentTime": "3/25/2025, 11:15 PM",
"offset": "+02:00"
},
{
"timezone": "Europe/Berlin",
"currentTime": "3/25/2025, 11:15 PM",
"offset": "+02:00"
},
// Additional European timezones...
],
"count": 7,
"region": "Europe"
}7.计算_倒计时
计算直到特定日期/事件的剩余时间。
参数:
targetDate:目标日期/时间(ISO字符串或自然语言)timezone(可选):IANA时区名称(例如,“美国/纽约”)。默认为系统时区。title(可选):事件的标题或名称
例子:
{
"targetDate": "2025-12-31T23:59:59",
"timezone": "UTC",
"title": "New Year's Eve"
}答复:
{
"title": "New Year's Eve",
"targetDate": "2025-12-31T23:59:59.000Z",
"formattedTargetDate": "Wednesday, December 31, 2025, 11:59:59 PM GMT",
"currentDate": "2025-03-25T18:15:30.000Z",
"timezone": "UTC",
"isPast": false,
"countdown": "9 months, 6 days, 5 hours, 44 minutes, 29 seconds",
"remaining": {
"years": 0,
"months": 9,
"days": 6,
"hours": 5,
"minutes": 44,
"seconds": 29,
"totalDays": 281,
"totalHours": 6749,
"totalMinutes": 404969,
"totalSeconds": 24298169
}
}8.计算营业日
计算两个日期之间的工作日(不包括周末)。
参数:
startDate:开始日期(ISO字符串或自然语言)endDate:结束日期(ISO字符串或自然语言)timezone(可选):IANA时区名称(例如,“美国/纽约”)。默认为系统时区。excludeHolidays(可选):是否排除公共假日(仅限美国假日)。默认为false。
例子:
{
"startDate": "2023-05-01",
"endDate": "2023-05-31",
"timezone": "UTC",
"excludeHolidays": true
}答复:
{
"startDate": "2023-05-01",
"endDate": "2023-05-31",
"businessDays": 22,
"calendarDays": 31,
"weekendDays": 8,
"holidaysExcluded": 1,
"timezone": "UTC",
"businessDatesIncluded": ["2023-05-01", "2023-05-02", "2023-05-03", "2023-05-04", "2023-05-05", "2023-05-08", "2023-05-09", "2023-05-10", "2023-05-11", "2023-05-12", "2023-05-15", "2023-05-16", "2023-05-17", "2023-05-18", "2023-05-19", "2023-05-22", "2023-05-23", "2023-05-24", "2023-05-25", "2023-05-26", "2023-05-30", "2023-05-31"]
}9.格式日期
以各种样式设置日期格式。
参数:
date:格式化日期(ISO字符串或自然语言)。默认为当前日期。timezone(可选):IANA时区名称(例如,“美国/纽约”)。默认为系统时区。format(可选):输出格式(“短”、“中”、“全”、“iso”、“相对”)。默认为“中等”。locale(可选):用于格式化的区域设置(例如,“en-US”、“fr”、“de”)。默认为“en-US”。
例子:
{
"date": "2023-12-25",
"timezone": "Europe/Paris",
"format": "full",
"locale": "fr"
}答复:
{
"originalDate": "2023-12-25",
"parsedDate": "2023-12-25T00:00:00.000+01:00",
"formattedDate": "lundi 25 décembre 2023",
"formattedTime": "00:00:00 heure normale d'Europe centrale",
"formattedDateTime": "lundi 25 décembre 2023 à 00:00:00 heure normale d'Europe centrale",
"dayOfWeek": "lundi",
"dayOfMonth": 25,
"month": "décembre",
"year": 2023,
"timezone": "Europe/Paris",
"locale": "fr",
"format": "full"
}💬 Claude Desktop中的查询示例
- “东京现在几点了?”
- “将纽约时间下午3:00转换为伦敦时间”
- “旧金山明天几点日出?”
- “今天巴黎的日落是什么时候?”
- “现在的月相是什么?”
- “纽约和东京的时差是多少?”
- “显示欧洲时区列表”
- “3月1日至4月15日有多少个工作日?”
- “在法语区域设置今天的日期格式”
- “离除夕还有多少时间?”
💻 技术细节
建筑
TimezoneToolkit是使用模型上下文协议(MCP)规范构建的,它允许它与Claude Desktop无缝集成。服务器使用TypeScript实现,并使用以下架构:
- 核心服务:实现时区转换、天文计算和日期格式化
- MCP服务器:处理来自Claude Desktop的JSON-RPC请求
- 工具函数:为日期/时间操作提供辅助函数
- 测试框架:包括用于验证功能的全面测试脚本
依赖项
- 卢克森 -适用于所有日期/时间处理和时区操作
- SunCalc -用于日出/日落和天文计算
- @模型上下文协议/sdk -用于MCP服务器实施
需求
- Node.js 18.x或更高版本
- npm 9.x或更高版本
- 克劳德桌面(最新版本)
📝 贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
🧪 测试
TimezoneToolkit包含一个全面的测试脚本,可用于验证MCP服务器的功能。测试脚本可用于测试本地构建、版本标志、列出所有可用工具、测试特定工具,以及在发布后测试npm包。
运行测试
# Test the local build (default)
node test-server.js
# Test a specific tool
node test-server.js --tool=calculate_sunrise_sunset
# List all available tools
node test-server.js --list
# Test the version flag
node test-server.js --test-version
# Test the published npm package (after publishing)
node test-server.js --npm测试脚本将输出有关测试结果的详细信息,包括响应格式是否正确以及内容是否为有效的JSON。
输出示例
Testing local build...
Running: node /path/to/timezone-toolkit/dist/index.js
Sending request: {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_current_time",
"arguments": {
"timezone": "America/New_York"
}
}
}
Response: {
"result": {
"content": [
{
"type": "text",
"text": "{\n \"currentTime\": \"Mar 25, 2025, 9:54 PM\",\n \"timezone\": \"America/New_York\",\n \"utcOffset\": \"-04:00\"\n}"
}
]
},
"jsonrpc": "2.0",
"id": 1
}
✅ Response format is correct (has content array)
✅ Content is valid JSON: {
currentTime: 'Mar 25, 2025, 9:54 PM',
timezone: 'America/New_York',
utcOffset: '-04:00'
}
✅ Test completed successfully!🐛 故障排除
常见问题
- 工具未显示在Claude Desktop中
- 确保在Claude Desktop设置中正确配置了服务器 - 检查index.js文件的路径是否正确 - 重新启动克劳德桌面
- 时区计算不正确
- 验证您使用的是有效的IANA时区名称(例如,“America/New_York”,而不是“EST”) - 检查可能影响计算的夏令时转换
- 日出/日落计算不起作用
- 确保纬度和经度值有效(纬度-90到90,经度-180到180) - 一些极端的北部/南部地区可能有没有日出/日落的时期
🔒 隐私和安全
TimezoneToolkit在本地处理所有数据,不向外部服务器发送任何信息。您的时区数据和查询在您的设备上保持私密。
📃 许可证
国际协调委员会
👨💻 作者
疤痕
