Skip to main content

A simple MCP Server that provides time query functionality

Project description

MCP Time Server

一个简单易用的 MCP (Model Context Protocol) 服务器,提供时间查询功能。

功能特性

  • 🕐 获取当前本地时间
  • 🌍 支持任意时区的时间查询
  • 🚀 简洁的 API 设计
  • 📦 易于安装和使用

安装

pip install mcp-time-server

使用方法

作为 MCP Server 运行

mcp-time-server

服务器将在 http://127.0.0.1:8000/sse 启动。

在代码中使用

from mcp_time_server import mcp

# 启动服务器
mcp.run(transport="sse")

工具说明

get_current_time

获取当前时间,支持可选的时区参数。

参数:

  • timezone (可选): 时区名称,如 "Asia/Shanghai", "UTC", "America/New_York"

返回:

  • 格式化的时间字符串

示例:

# 获取本地时间
get_current_time()
# 返回: "2026-01-29 14:30:45"

# 获取 UTC 时间
get_current_time("UTC")
# 返回: "2026-01-29 06:30:45 UTC"

# 获取上海时间
get_current_time("Asia/Shanghai")
# 返回: "2026-01-29 14:30:45 CST"

支持的时区

常用时区列表:

  • UTC - 世界标准时间
  • Asia/Shanghai - 上海时间
  • Asia/Tokyo - 东京时间
  • America/New_York - 纽约时间
  • Europe/London - 伦敦时间
  • Europe/Paris - 巴黎时间
  • Australia/Sydney - 悉尼时间

更多时区请参考 IANA 时区数据库

在 Cherry Studio 中使用

  1. 启动服务器:

    mcp-time-server
    
  2. 在 Cherry Studio 中配置:

    • 名称: time-server
    • 类型: SSE
    • URL: http://127.0.0.1:8000/sse
  3. 在对话中询问时间:

    • "现在几点了?"
    • "UTC 时间是多少?"
    • "纽约现在几点?"

开发

安装开发依赖

pip install -e ".[dev]"

运行测试

pytest

代码格式化

black mcp_time_server/

类型检查

mypy mcp_time_server/

依赖

  • mcp>=1.0.0 - Model Context Protocol SDK
  • pytz>=2024.0 - 时区支持

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

作者

Your Name - your.email@example.com

链接

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

mcp_cuc_kkn-0.3.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

mcp_cuc_kkn-0.3.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_cuc_kkn-0.3.0.tar.gz.

File metadata

  • Download URL: mcp_cuc_kkn-0.3.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mcp_cuc_kkn-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b0ddc7d74d7790787a3c7c508605c41ea3015ced97e6872793e2164619603c32
MD5 48ecfbc14e469acdd11832a8689b36e6
BLAKE2b-256 0eb2740ca60c375c7879c6004a1c0abd0e0115f648a635317e3cb869b45b27c0

See more details on using hashes here.

File details

Details for the file mcp_cuc_kkn-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_cuc_kkn-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mcp_cuc_kkn-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 395c2ce7c5bdcbe04005a781ff05444ec3c36b842982efc4372976053c8b5e98
MD5 dd49eb5d604532862e49fc329a8130cf
BLAKE2b-256 ad260738cba8d6aa040d52f1e3ea7fced828bfaf23d182912ca228043e2d977a

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