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!
链接
Metadata
Release files for mcp-time-server-HR 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_time_server_hr-0.1.7.tar.gz | 1.9 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_time_server_hr-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.8 MB
Release files / mcp_time_server_hr-0.1.7.tar.gz
| Download URL | mcp_time_server_hr-0.1.7.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eeb898f0c623d1c26a90e664fafa4ec1ec5485326ac8852a7ed18b186b256436
|
|
BLAKE2b-256 checksum How to use checksums |
096f59aff56c75048fb98435d0ce1e27ff80094c39dd6ca53b29051965e7202c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.13.0 Windows/11
|
Release files / mcp_time_server_hr-0.1.7-py3-none-any.whl
| Download URL | mcp_time_server_hr-0.1.7-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cce09fe39620805e8263d3d63324cac27134a689bc156f8ab8de488e971a8a3
|
|
BLAKE2b-256 checksum How to use checksums |
2928a5e52e16daf5f2f1562e1470aee3b4a648597677c407f4aecdc42524f0e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.13.0 Windows/11
|
Security for mcp-time-server-HR 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.