ntp-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ntp-mcp-serverwhat's the current time in Tokyo?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NTP MCP Server π
A Model Context Protocol (MCP) server that provides accurate time information from Network Time Protocol (NTP) servers with timezone support and structured output formatting.
Add NTP MCP Server to LM Studio
Add NTP MCP Server Docker to LM Studio
β¨ Features
π Multiple NTP Server Support: Connect to any NTP server worldwide
π°οΈ Timezone Conversion: Automatic timezone conversion with pytz
π Structured Output Format: Clean, parseable time format with separate date, time, and timezone components
π Fallback Mechanism: Falls back to local time if NTP is unavailable
π³ Ultra-Lightweight Docker: Alpine Linux base image (~50MB) for minimal footprint
β‘ Retry Logic: Automatic retry with exponential backoff
π§ Configurable: Environment variable configuration
π MCP Compatible: Works with Claude Desktop and other MCP clients
π§ͺ Comprehensive Testing: Full test suite with format validation
Related MCP server: chuk-mcp-time
π Time Output Format
The NTP server now outputs time in a structured, easy-to-parse format:
Date:YYYY-MM-DD
Time:HH:mm:ss
Timezone:timezone_nameExample Outputs
Successful NTP Response:
Date:2025-07-25
Time:14:30:25
Timezone:UTCFallback Response (when NTP unavailable):
Date:2025-07-25
Time:14:30:25
Timezone:UTC (local fallback)Benefits of the New Format
β More structured and easier to parse
β Separate date and time components
β Clear timezone information
β Consistent formatting across all responses
β Machine-readable and human-friendly
π Quick Start
Using Docker (Recommended)
# Build the Docker image
docker build -t ntp-mcp-server .
# Run with default settings
docker run --rm -i ntp-mcp-server
# Run with custom NTP server and timezone
docker run --rm -i \
-e NTP_SERVER=time.google.com \
-e TZ=America/New_York \
ntp-mcp-serverUsing Docker Compose
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose downDirect Python Installation
# Install dependencies
pip install -r requirements.txt
# Run the server
python app.pyπ¦ Installation
Prerequisites
Docker (recommended) or Python 3.11+
MCP Client (Claude Desktop, etc.)
Method 1: Docker Installation
Clone the repository:
git clone <your-repo-url> cd ntp-mcp-serverBuild the Docker image:
docker build -t ntp-mcp-server .Configure your MCP client using
mcp-docker.json
Method 2: Python Installation
Clone and setup:
git clone <your-repo-url> cd ntp-mcp-server pip install -r requirements.txtConfigure your MCP client using
mcp.json
βοΈ Configuration
Environment Variables
Variable | Default | Description |
|
| NTP server hostname |
| System local | Target timezone (e.g., |
Supported NTP Servers
pool.ntp.org(default)time.google.comtime.cloudflare.comtime.apple.comtime.nist.govAny RFC 5905 compliant NTP server
Supported Timezones
Any timezone supported by the pytz library:
UTCAmerica/New_YorkEurope/LondonAsia/TokyoAustralia/SydneyAnd many more...
π§ MCP Client Configuration
For Claude Desktop
Add to your Claude Desktop configuration:
Docker Version (Recommended)
{
"mcpServers": {
"ntp-server-docker": {
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "NTP_SERVER", "-e", "TZ", "ntp-mcp-server"],
"env": {
"NTP_SERVER": "pool.ntp.org",
"TZ": "UTC"
}
}
}
}Python Version
{
"mcpServers": {
"ntp-server": {
"command": "python",
"args": ["app.py"],
"cwd": "/path/to/your/ntp/project",
"env": {
"NTP_SERVER": "pool.ntp.org",
"TZ": "UTC"
}
}
}
}π οΈ Available Tools
get_current_time
Retrieves the current time from the configured NTP server in structured format.
Parameters: None
Returns: Current time in structured format with separate date, time, and timezone components
Example Response:
Date:2025-07-25
Time:14:30:25
Timezone:UTCFallback Behavior:
If NTP server is unreachable, falls back to local system time
Fallback responses include "(local fallback)" indicator
Returns error message if all time sources fail
π§ͺ Testing
The project includes a comprehensive test suite with format validation:
Available Test Scripts
test/simple_test.py- Windows-compatible direct testingtest/test_mcp.py- Basic MCP protocol testing with format validationtest/test_mcp_proper.py- Advanced MCP protocol testingtest/test_mcp_docker.py- Comprehensive Docker testingtest/test_direct_docker.py- Direct Docker container testingtest/run_all_tests.py- Comprehensive test runner
Run All Tests
# Run comprehensive test suite
python test/run_all_tests.py
# Run individual tests
python test/simple_test.py # Simple direct testing
python test/test_mcp_docker.py # Docker functionality
python test/test_mcp_proper.py # MCP protocol testing
python test/test_mcp.py # Basic functionalityTest Coverage
The test suite validates:
β Time format structure (Date:YYYY-MM-DD, Time:HH:mm:ss, Timezone:name)
β Multiple NTP servers (pool.ntp.org, time.google.com, time.cloudflare.com)
β Different timezones (UTC, America/New_York, Europe/London, Asia/Tokyo)
β Docker containerization with full MCP protocol
β Environment variable configuration
β Fallback behavior when NTP is unavailable
β MCP protocol compliance (initialization, tools list, tool calls)
Manual Testing
# Test direct function call
python -c "import app, asyncio; result = asyncio.run(app.handle_call_tool('get_current_time', {})); print(result[0].text)"
# Start a container for testing
docker run --rm -i -e NTP_SERVER=time.google.com -e TZ=America/New_York ntp-mcp-server
# Send MCP requests (in another terminal)
echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | docker exec -i <container-id> catπ³ Docker Details
Image Information
Base Image:
python:3.11-alpineSize: ~50MB (significantly reduced from previous slim image)
Architecture: Multi-platform support
Benefits: Ultra-lightweight Alpine Linux base for minimal footprint
Build Arguments
# Build with custom tag
docker build -t my-ntp-server .
# Build for specific platform
docker build --platform linux/amd64 -t ntp-mcp-server .
# Build for ARM64 architecture
docker build --platform linux/arm64 -t ntp-mcp-server:arm64 .
# Build for multiple architectures (requires Docker Buildx)
docker buildx create --name multiarch-builder --use
docker buildx build --platform linux/amd64,linux/arm64 -t username/ntp-mcp-server:latest --push .Volume Mounts
No persistent volumes required - this is a stateless service.
π Project Structure
ntp-mcp-server/
βββ app.py # Main MCP server implementation
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker build configuration
βββ docker-compose.yml # Docker Compose setup
βββ .dockerignore # Docker build optimization
βββ .gitignore # Git ignore configuration
βββ LICENSE # License information
βββ config/
β βββ mcp.json # MCP client config (Python)
β βββ mcp-docker.json # MCP client config (Docker)
βββ test/
β βββ simple_test.py # Windows-compatible direct testing
β βββ test_mcp.py # Basic functionality tests with format validation
β βββ test_mcp_proper.py # Advanced MCP protocol tests
β βββ test_mcp_docker.py # Comprehensive Docker tests
β βββ test_direct_docker.py # Direct container tests
β βββ run_all_tests.py # Comprehensive test runner
βββ README.md # This fileπ Troubleshooting
Common Issues
"Processing request of type ListToolsRequest" Error
This is NOT an error! This is normal debug logging. The message:
[ERROR] [Plugin(mcp/ntp-server-docker)] stderr: INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequestMeans your server is working correctly. The INFO: indicates it's just debug information.
Container Exits Immediately
MCP servers are designed to run as stdio servers. They exit when stdin is closed, which is normal behavior.
NTP Server Unreachable
The server will automatically fall back to local time if the NTP server is unreachable. Check your network connectivity and firewall settings.
Timezone Not Found
Ensure you're using a valid timezone identifier from the pytz documentation.
Time Format Issues
The new structured format should always return:
Date:YYYY-MM-DD
Time:HH:mm:ss
Timezone:timezone_nameIf you see different formatting, run the test suite to validate:
python test/simple_test.pyDebug Commands
# Check if container is running
docker ps --filter ancestor=ntp-mcp-server
# View container logs
docker logs <container-id>
# Test container responsiveness with new format
python test/test_direct_docker.py
# Run comprehensive test suite
python test/run_all_tests.py
# Check NTP connectivity
docker run --rm ntp-mcp-server python -c "import ntplib; print(ntplib.NTPClient().request('pool.ntp.org'))"
# Validate time format directly
python -c "import app, asyncio; result = asyncio.run(app.handle_call_tool('get_current_time', {})); print('Format:', repr(result[0].text))"π€ Contributing
Fork the repository
Create a feature branch:
git checkout -b feature-nameMake your changes
Add tests for new functionality
Ensure all tests pass:
python test/run_all_tests.pyValidate time format:
python test/simple_test.pyCommit your changes:
git commit -m "Add feature"Push to the branch:
git push origin feature-nameSubmit a pull request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Related Links
π Support
If you encounter issues:
Check the Troubleshooting section
Run the test suite to verify functionality:
python test/run_all_tests.pyValidate time format:
python test/simple_test.pyCheck that your MCP client configuration is correct
Ensure Docker is running (for Docker deployment)
π·οΈ Version History
v2.1.0 - DOCKER OPTIMIZATION
π³ Switched to Alpine Linux base image (
python:3.11-alpine)π¦ Significantly reduced image size from ~151MB to ~50MB (67% reduction)
β‘ Improved container startup time and resource efficiency
π Enhanced security with minimal attack surface
ποΈ Better for CI/CD pipelines due to faster pull times
v2.0.0 - NEW STRUCTURED TIME FORMAT
β¨ New structured output format:
Date:YYYY-MM-DD\nTime:HH:mm:ss\nTimezone:timezoneπ§ͺ Enhanced test suite with comprehensive format validation
π§ Improved Windows compatibility with dedicated test scripts
π Better error handling and fallback behavior
π³ Updated Docker tests with full MCP protocol validation
v1.0.0 - Initial release with NTP support and Docker containerization
Full timezone support with pytz
Comprehensive test suite
Docker and Python deployment options
MCP protocol compliance
Made with β€οΈ for the MCP community
This server cannot be deployed
Maintenance
Related MCP Connectors
A real clock for AI agents: current time, timezone conversion, and DST facts from the IANA tzdb.
Current time in any IANA time zone, plus the full time-zone list. Via timeapi.io.
Current time, timezone conversion & date math for AI agents. On Cloudflare Workers.
Get the current time in any timezone and quickly look up common timezone info. Set a default timezβ¦
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides accurate time information from Network Time Protocol (NTP) servers with timezone support and security filtering. Features whitelist-based server approval, blocks unauthorized sources, and delivers structured time output with fallback mechanisms.MIT
- AlicenseAqualityCmaintenanceProvides high-accuracy time information by querying multiple NTP servers for consensus time, and comprehensive timezone support using IANA tzdata for conversions, DST handling, and clock drift detection independent of system time.73Apache 2.0
- AlicenseBqualityDmaintenanceProvides current time information and timezone conversion capabilities using IANA timezone names with automatic system detection. It enables LLMs to fetch local or global times and convert specific timestamps between different regions.22MIT
- AlicenseNot gradedqualityDmaintenanceProvides current time information and timezone conversion capabilities using IANA timezone names and automatic system detection. It enables LLMs to fetch current times across different regions and convert specific times between timezones.MIT