MCP (Model Context Protocol) 时间服务器,提供当前时间获取功能
Project description
MCP Time Server
一个基于 MCP (Model Context Protocol) 的时间服务器,提供当前时间获取功能。
特性
- 🎯 基于 MCP 协议的时间服务
- 🌍 支持全球时区查询
- 🚀 基于 FastMCP 的高性能实现
- 📦 易于安装和集成
- 🔧 支持命令行和编程接口
安装
使用 pip 安装
pip install mcp-time-server
开发环境安装
git clone https://github.com/example/mcp-time-server.git
cd mcp-time-server
pip install -e .
快速开始
命令行使用
# 启动服务器(使用默认时区)
mcp-time-server
# 服务器将通过 stdio 启动,等待 MCP 客户端连接
Python 编程接口
from mcp_time_server import get_current_time
# 获取当前时间(使用系统默认时区)
current_time = get_current_time()
print(current_time)
# 获取指定时区的当前时间
beijing_time = get_current_time("Asia/Shanghai")
print(beijing_time)
# 获取纽约时间
ny_time = get_current_time("America/New_York")
print(ny_time)
MCP 工具
get_current_time
获取当前时间的 MCP 工具函数。
参数:
timezone(可选): 时区字符串,例如 "Asia/Shanghai"、"America/New_York"- 如果不提供,将使用系统默认时区
返回值:
- 格式化的当前时间字符串,格式:YYYY-MM-DD HH:MM:SS.SSSSSS 时区名称
支持的时区示例:
Asia/Shanghai- 中国标准时间America/New_York- 纽约时间Europe/London- 伦敦时间UTC- 协调世界时Asia/Tokyo- 日本标准时间
示例输出
2025-12-30 19:54:32.123456 CST
2025-12-30 07:54:32.123456 EST
2025-12-30 12:54:32.123456 UTC
依赖项
pytz- 时区处理库mcp- Model Context Protocol 库
兼容性
- Python 3.8+
- 支持所有主要操作系统(Windows、macOS、Linux)
开发
本地开发设置
# 克隆仓库
git clone https://github.com/example/mcp-time-server.git
cd mcp-time-server
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
python -m pytest
构建包
# 构建分发包
python -m build
# 检查构建结果
python -m twine check dist/*
贡献
欢迎贡献!请阅读 CONTRIBUTING.md 了解详情。
许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
更新日志
v0.1.0
- 初始版本发布
- 支持基本的时间获取功能
- 支持时区参数
- MCP 协议集成
Project details
Release history Release notifications | RSS feed
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_myx-0.1.0.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_cuc_myx-0.1.0.tar.gz.
File metadata
- Download URL: mcp_cuc_myx-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc36d0003fc23b12535d28db8186ec5689fc9b91b8760b74e5805b11019c602
|
|
| MD5 |
1382d75bf52107e7d21288bd60967cb3
|
|
| BLAKE2b-256 |
45cc9eb8b56ebf614880ae7c9e3fa54321184c7c6a4ebc14d97650d705653af9
|
File details
Details for the file mcp_cuc_myx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_cuc_myx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
addef72b1250d3addfa3f4d54d4845c23b09e85c1e4fd45f425060adcdd0d505
|
|
| MD5 |
933f86506ac27e807366e489cc6f27d7
|
|
| BLAKE2b-256 |
39982377c663d51b6c8f137fe28975843688385956b76840b7e23279f59ab0c7
|