Skip to main content

一个简单的 MCP Server,提供获取当前时间的工具

Project description

MCP Time Server

一个简单的 MCP (Model Context Protocol) Server,提供获取当前时间的工具。

功能特性

  • 获取当前时间
  • 支持可选的时区参数
  • 简洁易用的 API
  • 完整的错误处理

安装

pip install mcp-time-server

使用方法

作为命令行工具

mcp-time-server

作为 Python 模块使用

from mcp_time_server import get_current_time

# 获取本地时间
print(get_current_time())
# 输出: 2024-01-27 15:30:45

# 获取 UTC 时间
print(get_current_time("UTC"))
# 输出: 2024-01-27 07:30:45 UTC

# 获取上海时间
print(get_current_time("Asia/Shanghai"))
# 输出: 2024-01-27 15:30:45 CST

API 文档

get_current_time(timezone: Optional[str] = None) -> str

获取当前时间。

参数:

  • timezone (可选): 指定时区,例如:'Asia/Shanghai', 'UTC', 'America/New_York'。如果不提供,则使用本地时区。

返回:

  • 格式化的当前时间字符串

示例:

get_current_time()                    # 本地时间
get_current_time("UTC")              # UTC 时间
get_current_time("Asia/Shanghai")    # 上海时间
get_current_time("America/New_York") # 纽约时间

依赖项

  • Python >= 3.8
  • mcp >= 1.0.0
  • pytz >= 2024.1

开发

克隆仓库

git clone https://github.com/yourusername/mcp-time-server.git
cd mcp-time-server

安装开发依赖

pip install -e .

运行测试

python mcp_time_server.py

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

链接

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_time_server_hr-0.1.1.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

mcp_time_server_hr-0.1.1-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file mcp_time_server_hr-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_time_server_hr-0.1.1.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.13.0 Windows/11

File hashes

Hashes for mcp_time_server_hr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d78f7b3c729153048f6c3d9aae1bb20589801c6a35d0a6fc6eeb126bfd3245f1
MD5 4f34c449af39a38fdb343def09768f8e
BLAKE2b-256 6f056a1890a2bcd8405ac66ddf24cca084f2f9ce8e80c3e41761dea99a9fbed4

See more details on using hashes here.

File details

Details for the file mcp_time_server_hr-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_time_server_hr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 371bcb527351aac6786668d6804f46a5aab260b8c5e51a927de3e39db40829cd
MD5 f31812ca85ee24974958e813de0bec6d
BLAKE2b-256 ae6899fec154c4a96b0c76a718f4c4d4e7d312129c69f2bfadc3a46024b0486c

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