A simple MCP (Model Context Protocol) Server that provides a tool to get the current time with optional timezone support.
Project description
MCP Time Server
This is a simple MCP (Model Context Protocol) Server that provides a tool to get the current time with optional timezone support.
Features
- Provides a
get_current_timetool to retrieve the current time - Supports optional timezone parameter
- Returns time in ISO 8601 format
- Handles unknown timezone errors gracefully
Requirements
- Python 3.7+
mcpPython SDKpytzlibrary (for timezone support)
Installation
pip install mcp-time-server
Usage
- Run the server:
mcp-time-server
- The server will start and listen for requests
Tool Usage
The server provides a single tool called get_current_time with the following parameters:
timezone(optional): A string representing the timezone (e.g., "Asia/Shanghai", "America/New_York")
Example Requests
Without timezone:
{
"jsonrpc": "2.0",
"id": "1",
"method": "callTool",
"params": {
"toolCall": {
"name": "get_current_time",
"arguments": {}
}
}
}
With timezone:
{
"jsonrpc": "2.0",
"id": "2",
"method": "callTool",
"params": {
"toolCall": {
"name": "get_current_time",
"arguments": {
"timezone": "Asia/Shanghai"
}
}
}
}
Example Responses
Without timezone:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"toolResult": {
"content": "2024-01-30T12:34:56.789012"
}
}
}
With timezone:
{
"jsonrpc": "2.0",
"id": "2",
"result": {
"toolResult": {
"content": "2024-01-30T20:34:56.789012+08:00"
}
}
}
Error response (unknown timezone):
{
"jsonrpc": "2.0",
"id": "3",
"result": {
"toolResult": {
"content": "Error: Unknown timezone 'Invalid/Timezone'"
}
}
}
Configuration
The server runs with default configuration using the streamable-http transport, which is suitable for local development and testing.
For production deployment, you may want to configure additional options such as HTTP transport or authentication.
License
This project is licensed under the MIT License.
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 mcp_time_servercuclsy-0.1.0.tar.gz.
File metadata
- Download URL: mcp_time_servercuclsy-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8eeb7f85b94718d0e1344b67b7e065688e3240dd95f8d94002024bb0bbca6bbc
|
|
| MD5 |
9bb6bcf67491987fa3edb8e0640ef9d8
|
|
| BLAKE2b-256 |
e10b82c3aca9dccd6030cdf37d28b23ff0ebdcffaaf65265ffab618d4b4b9d38
|
File details
Details for the file mcp_time_servercuclsy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_time_servercuclsy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.13.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff1eaab8be310f649a3fe6850d0bc4ffaa4b8b1cb828c7a9909f4ac23b9d57f9
|
|
| MD5 |
b7498a6f324f28d7153056b4877cb958
|
|
| BLAKE2b-256 |
bc1530b836ed9b394de0405dbdd7eaa154e5db1ef26da32dc02732d698e74904
|