Skip to main content

An MCP service providing time information and time calculations

Project description

Bouse MCP Time Service

一个基于MCP(Model Context Protocol)的时间服务,为AI助手和LLM应用提供强大的时间处理功能。

🚀 功能特性

  • 获取当前时间 - 支持本地时间和指定时区的时间获取
  • 时区转换 - 在不同时区之间转换时间
  • 时间格式化 - 自定义时间格式输出
  • 时间计算 - 添加天数、小时、分钟到指定时间
  • 时间差计算 - 计算两个时间点之间的差值
  • 时区查询 - 查询特定国家的所有时区信息

📦 安装

使用 pip 安装

pip install bouse-mcp-time

从源码安装

git clone https://github.com/your-username/bouse-mcp-time.git
cd bouse-mcp-time
pip install -e .

🔧 使用方法

作为MCP服务运行

1. STDIO 模式(默认)

bouse-mcp-time

2. HTTP SSE 模式

bouse-mcp-time --transport sse --host 0.0.0.0 --port 9000

3. HTTP Streamable 模式

bouse-mcp-time --transport streamable-http --host 127.0.0.1 --port 9000

命令行参数

参数 说明 默认值
--transport 传输模式:stdio, sse, streamable-http stdio
--host 主机地址 127.0.0.1
--port 端口号 9000
--path HTTP路径 /sse (sse模式) /mcp (streamable-http模式)

🛠️ 可用工具

1. 获取本地时间

get_local_time() -> str

返回当前本地时间,格式:YYYY-MM-DD HH:MM:SS

2. 获取指定时区时间

get_current_time(timezone_name: str = "Asia/Shanghai") -> str

返回指定时区的当前时间,默认时区为亚洲/上海

3. 时区转换

convert_timezone(time_str: str, from_tz: str, to_tz: str) -> str

将时间从一个时区转换到另一个时区

参数:

  • time_str: 时间字符串,格式:YYYY-MM-DD HH:MM:SS
  • from_tz: 源时区名称
  • to_tz: 目标时区名称

4. 时间格式化

format_time(time_str: str, format_str: str = "%Y-%m-%d %H:%M:%S") -> str

将时间字符串格式化为指定格式

5. 时间加法

add_time(time_str: str, days: int = 0, hours: int = 0, minutes: int = 0) -> str

在指定时间基础上添加天数、小时、分钟

6. 时间差计算

get_time_difference(time1: str, time2: str) -> str

计算两个时间点之间的差值

7. 查询国家时区

list_country_timezones(country_name: str) -> str

列出指定国家的所有时区信息

📝 使用示例

在AI助手中的应用

当AI助手需要处理时间相关任务时,可以调用这些工具:

  1. 获取当前时间

    • 用户:"现在几点了?"
    • 助手调用 get_current_time("Asia/Shanghai")
  2. 时区转换

    • 用户:"纽约现在是几点?"
    • 助手调用 get_current_time("America/New_York")
  3. 时间计算

    • 用户:"3天后是几号?"
    • 助手调用 add_time("2024-01-15 10:30:00", days=3)
  4. 会议时间安排

    • 用户:"北京时间下午2点开会,纽约时间是几点?"
    • 助手调用 convert_timezone("2024-01-15 14:00:00", "Asia/Shanghai", "America/New_York")

🌍 支持的时区

支持所有标准时区,常用时区示例:

  • Asia/Shanghai - 中国标准时间
  • America/New_York - 美国东部时间
  • Europe/London - 英国时间
  • Asia/Tokyo - 日本时间
  • UTC - 协调世界时

🔗 集成到MCP客户端

配置示例

在MCP客户端配置文件中添加:

{
  "mcpServers": {
    "time": {
      "command": "bouse-mcp-time",
      "args": ["--transport", "stdio"]
    }
  }
}

🤝 贡献

欢迎提交Issue和Pull Request!

📄 许可证

本项目采用MIT许可证 - 详见 LICENSE 文件

🆘 支持

如果您遇到问题或有建议,请:

  1. 查看 Issues
  2. 创建新的Issue
  3. 联系维护者

注意: 本服务需要Python 3.10或更高版本。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bouse_mcp_time-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bouse_mcp_time-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file bouse_mcp_time-0.1.0.tar.gz.

File metadata

  • Download URL: bouse_mcp_time-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for bouse_mcp_time-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b33cd486f6728e8b24d2f245a62b5126a83e4add4740a4d96cfb5d38c91f7603
MD5 e3c9cd628d5de9aff53aaea1720ba546
BLAKE2b-256 2a9d689833b53f8823a040751b49b681450565c7283132ed936ddd5f0731cd10

See more details on using hashes here.

File details

Details for the file bouse_mcp_time-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bouse_mcp_time-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d8962a1689cc17bc63fcea10b36a83d09d2e673bd44d0bf43db5dd547cdb8f
MD5 ae0d1c048d963c9149d3f7c2982183dc
BLAKE2b-256 d2cf1ede9e03b690256d2f2055574d3afcb2d22fbb08387d60fec026b7f01c2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page