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.2.0.tar.gz (4.9 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.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_cuc_kkn-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 fef0e7a1fad5865e994b448f6315bce5e9c8a33bcf6f80e7af8dbd7acd6f80ab
MD5 5d917e96f143e767dcc05db15044a1fd
BLAKE2b-256 5cccc720ca3e3ff9e07e4299bc0af44388d3bb9bccfaf165192f0ae3e0263f3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcp_cuc_kkn-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dafa9ea08a48e3300b11b2234d7020fabf2101e487b56002fc4e466a210843a
MD5 2bf0c3c8a45f033506f9e6f58744911f
BLAKE2b-256 15bdfb11d0b9e48fd14459a6422f825e353c22ee461a2d63881c04becf15f314

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