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.1.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.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_cuc_kkn-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.13.5 Windows/11

File hashes

Hashes for mcp_cuc_kkn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 adbc79ea45198223c0f69b19105d49b4f53f53286b0085322787527bd5512d20
MD5 c7686e9d33064c73cd9666517b80353c
BLAKE2b-256 79db32726d2b3243b56bd95f5fac73ffd830ffeb7bda59d42299b528b74c27d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcp_cuc_kkn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.13.5 Windows/11

File hashes

Hashes for mcp_cuc_kkn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35f130750379736b7dbb0b58d9b02a831a0197d49fa5b7d63e82772ffc31b22d
MD5 1c28254f9cf7de8fcb83141672f39a95
BLAKE2b-256 a4285712bdb8c7a7513c9ae76a50b045d5bcb870965648e67d9c7b56564e37e8

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