MCP Server for getting current time with timezone support
Project description
MCP Time Server
MCP Server for getting current time with timezone support.
Features
- Get current time
- Support custom timezone (optional parameter)
- Default timezone is UTC
Installation
pip install mcp-time-server
Usage
CLI
mcp-time-server
As a Python module
from mcp.server.fastmcp import FastMCP
from datetime import datetime
import pytz
mcp = FastMCP("time_server")
@mcp.tool()
def get_current_time(timezone: str = "UTC") -> str:
"""获取当前时间,支持指定时区。"""
try:
if timezone.upper() == "UTC":
current_time = datetime.now(pytz.UTC)
else:
tz = pytz.timezone(timezone)
current_time = datetime.now(tz)
return f"当前时间 ({timezone}): {current_time.strftime('%Y-%m-%d %H:%M:%S %Z')}"
except pytz.UnknownTimeZoneError:
return f"错误: 无效的时区 '{timezone}'"
if __name__ == "__main__":
mcp.run()
Development
# Install development dependencies
pip install -e .
# Run tests
pytest
# Build package
python -m build
# Publish to PyPI
twine upload dist/*
License
MIT
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_king-0.1.0.tar.gz
(27.9 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_king-0.1.0.tar.gz.
File metadata
- Download URL: mcp_cuc_king-0.1.0.tar.gz
- Upload date:
- Size: 27.9 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 |
2bfe399812f9cd4c12cd0dd3757e6ddf656ffe7f72db2474e55c90d0808395ad
|
|
| MD5 |
5b7f39239b37b52d603dace811d26a0e
|
|
| BLAKE2b-256 |
a77274f61dfe217c2d4275194aa5f747977913b281e3c962ed2adea1cdcb62b0
|
File details
Details for the file mcp_cuc_king-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_cuc_king-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 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 |
32d36c62081e5e33a78658ca75ddf8b8ec7f411c25e9c1660bc0ff161d14e1ef
|
|
| MD5 |
8b031b45eed7accdf4b076fdbe361b92
|
|
| BLAKE2b-256 |
0c917ecb4f88fede2be85526e8b7821b6415d47faa95d7b679da732fc964158e
|