A Model Context Protocol (MCP) time server that provides current time information
Project description
MCP Time Server
A Model Context Protocol (MCP) time server that provides current time information. This server implements the MCP protocol and offers a tool to get the current time with optional timezone support.
Features
- Provides current time information via MCP protocol
- Supports optional timezone parameter
- Easy to install and use
- Lightweight implementation
Installation
You can install MCP Time Server using pip:
pip install mcp-time-server
Usage
Running the Server
To start the MCP Time Server, simply run:
python -m time_server
Or use the command-line entry point:
mcp-time-server
Using the Server
The server provides a tool called get_current_time that can be called via the MCP protocol.
Example using an MCP client:
import requests
import json
# Example using JSON-RPC over HTTP
url = "http://localhost:8000"
# Request without timezone
payload = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_current_time",
"arguments": {}
},
"id": 1
}
response = requests.post(url, json=payload)
print(response.json())
# Request with timezone
payload_with_tz = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_current_time",
"arguments": {
"timezone": "Asia/Shanghai"
}
},
"id": 1
}
response = requests.post(url, json=payload_with_tz)
print(response.json())
API Reference
get_current_time(timezone: Optional[str] = None)
Get the current time.
-
Parameters:
timezone(Optional[str]): Timezone string (e.g., "Asia/Shanghai", "America/New_York"). If not provided, uses system default timezone.
-
Returns:
- Formatted time string in the format: "YYYY-MM-DD HH:MM:SS.SSSSSS TIMEZONE"
-
Example:
get_current_time()→ "2023-06-15 14:30:45.123456 UTC"get_current_time("Asia/Shanghai")→ "2023-06-15 22:30:45.123456 CST"
Configuration
The server can be configured using command-line arguments or environment variables. Refer to the documentation for more details.
Requirements
- Python 3.7+
- pytz
- fastmcp
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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
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 cuc_mcp_time_server-0.1.0.tar.gz.
File metadata
- Download URL: cuc_mcp_time_server-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9efade869c17012a793c857010bb84ec13cfc86d2e8cbca3160f576c34ad73
|
|
| MD5 |
d70ecef82a72ce698929382913045042
|
|
| BLAKE2b-256 |
739007443670226e3f9b593e30eb75540a3c6ec7180ee6520a96528f2007adb4
|
File details
Details for the file cuc_mcp_time_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cuc_mcp_time_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e1d46cb6582ca5470ad1bf3d7864b62be7e9dc1e4b493e1f44c49271b7e5044
|
|
| MD5 |
f5ad6a0409b7600b57c229d44471e9c2
|
|
| BLAKE2b-256 |
9a0252fe09b0b2bfdf42d083e2825b650a2afe9ebdecdeb631c96d28151be7fd
|