MCPTimeServer

by mekanixms

273 downloads
Not rated
GitHub

Description

# MCP Time Server A Model Context Protocol (MCP) server that provides current time from internet time servers with timezone support. ## Features - Fetches accurate time from NTP servers (pool.ntp.org) - Supports custom timezone configuration via environment variable - Graceful…

About

# MCP Time Server A Model Context Protocol (MCP) server that provides current time from internet time servers with timezone support. ## Features - Fetches accurate time from NTP servers (pool.ntp.org) - Supports custom timezone configuration via environment variable - Graceful error handling for network issues and…

Details

Author
mekanixms
Downloads
273
Categories
Other

- Fetches accurate time from NTP servers (pool.ntp.org)
- Supports custom timezone via TIMEZONE environment variable
- Graceful error handling for network issues
- Graceful handling of invalid timezones (falls back to UTC)
- Compatible with Claude Desktop

Install dependencies with pip install mcp ntplib pytz, then register the server with your preferred timezone using mcp install timeserver.py -e TIMEZONE=America/New_York or by adding it to claude_desktop_config.json. Once installed, ask Claude to use the get_current_time tool to display the current time in your configured timezone.

MCP Time Server

A Model Context Protocol (MCP) server that provides current time from internet time servers with timezone support.

Features

- Fetches accurate time from NTP servers (pool.ntp.org)
- Supports custom timezone configuration via environment variable
- Graceful error handling for network issues and invalid timezones
- Compatible with Claude Desktop

Installation

1. Install the required dependencies:

pip install mcp ntplib pytz

2. Install the server in Claude Desktop with your preferred timezone:

mcp install timeserver.py -e TIMEZONE=America/New_York

Locate the claude_desktop_config.json and add (or change as mcp command generates it) to "mcpServers" the "Time Server":

{
"mcpServers": {
"Time Server": {
"command": "/path/to/python",
"args": [
"/path/to/timeserver.py"
],
"env": {
"TIMEZONE": "America/New_York"
}
}
}
}

You can set any valid timezone name from the IANA Time Zone Database. Some common examples:
- 'America/New_York'
- 'Europe/London'
- 'Asia/Tokyo'
- 'US/Pacific'
- 'UTC' (default if no timezone is specified)

Usage

Once installed, you can ask Claude to use the get_current_time tool to fetch and display the current time in your configured timezone. The tool will:
- Connect to pool.ntp.org to get the accurate current time
- Convert the time to your specified timezone (or UTC if none specified)
- Return a formatted string with the current date, time, and timezone

Error Handling

The server handles several types of errors gracefully:
- Network connectivity issues when reaching the NTP server
- Invalid timezone specifications (falls back to UTC)
- General exceptions with informative error messages

Dependencies

- mcp: Model Context Protocol SDK
- ntplib: NTP client library
- pytz: Timezone database and utilities

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.