Get current time and calculate time differences with an easy-to-use JavaScript MCP server for Windows and macOS
The MCP Time Server is an essential component of the Model Context Protocol (MCP) infrastructure, designed to provide real-time date and time functionalities to AI applications such as Claude Desktop, Continue, Cursor, and other MCP clients. By implementing a standardized protocol, this server ensures seamless integration between these applications and data sources or tools that require accurate time information.
The getCurrentTime
command is central to the core functionality of the MCP Time Server. It returns the current time in an ISO format (YYYY-MM-DD HH:mm:ss), enabling users and developers to access precise date and time values as needed.
{
"method": "getCurrentTime",
"parameters": [],
"returns": {
"time": "2024-02-08 11:04:33",
"success": true
},
"examples": [
{
"request": {
"jsonrpc": "2.0",
"id": 1,
"method": "getCurrentTime"
},
"response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"time": "2024-02-08 11:04:33",
"success": true
}
}
}
]
}
The getTimeDifference
command further expands the capabilities of the server, allowing for the calculation of time differences between given timestamps and the current time. This feature is crucial in various AI applications requiring temporal analysis.
{
"method": "getTimeDifference",
"parameters": [
{
"name": "timestamp",
"description": "ISO format timestamp (YYYY-MM-DD HH:mm:ss)",
"required": true
},
{
"name": "interval",
"description": "Optional, default 'minutes', options are 'minutes' or 'seconds'",
"default": "minutes"
}
],
"returns": {
"difference": -30,
"interval": "minutes",
"inputTimestamp": "2024-02-08 12:30:00",
"currentTime": "2024-02-08 13:00:00"
},
"examples": [
{
"request": {
"jsonrpc": "2.0",
"id": 1,
"method": "getTimeDifference",
"params": {
"timestamp": "2024-02-08 12:30:00",
"interval": "minutes"
}
},
"response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"difference": -30,
"interval": "minutes",
"inputTimestamp": "2024-02-08 12:30:00",
"currentTime": "2024-02-08 13:00:00"
}
},
"request2": {
"jsonrpc": "2.0",
"id": 1,
"method": "getTimeDifference",
"params": {
"timestamp": "2024-02-08 13:45:00",
"interval": "minutes"
}
},
"response2": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"difference": 45,
"interval": "minutes",
"inputTimestamp": "2024-02-08 13:45:00",
"currentTime": "2024-02-08 13:00:00"
}
}
}
]
}
The MCP protocol flow ensures that data is transmitted securely and efficiently between the AI applications, MCP clients, and the server. The following diagram illustrates this interaction:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
The compatibility matrix ensures that the MCP Time Server works seamlessly with various MCP clients. The following table details the supported clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
To install and use the MCP Time Server, follow these steps:
Clone the Repository:
git clone https://github.com/dandeliongold/mcp-time.git
Install Dependencies:
npm install
Run Tests to Ensure Everything Is Working Correctly:
npm test
Start the Development Server:
npm run dev
The MCP Time Server can be integrated into a complex data processing system, where real-time date and time information is crucial for aggregating data from various sources. This use case showcases how the server provides accurate timestamps to ensure that all data points are aligned correctly.
// Example Implementation in AI Application Code
const { getCurrentTime } = require('@dandeliongold/mcp-time');
async function processData() {
const currentTime = await getCurrentTime();
// Use 'currentTime' for processing latest data points.
}
In scheduling applications, accurate time information is essential for setting up events and sending notifications. The getTimeDifference
method can be used to calculate the time difference between the scheduled event time and the current server time.
// Example Implementation in AI Application Code
const { getTimeDifference } = require('@dandeliongold/mcp-time');
async function scheduleEvent() {
const timestamp = '2024-02-15T16:30:00';
const interval = 'minutes';
const timeDifference = await getTimeDifference(timestamp, interval);
console.log(`Time to event in ${timeDifference} minutes`);
}
The MCP Time Server's simple JSON-RPC interface ensures compatibility with various AI applications that support the Model Context Protocol (MCP). Developers can easily integrate this server into their applications by following the provided configuration example.
{
"mcpServers": {
"time": {
"command": "npx",
"args": [
"@dandeliongold/mcp-time"
]
}
}
}
The performance and compatibility of the MCP Time Server are paramount, ensuring that it can handle various use cases while maintaining robustness across different platforms.
To ensure the security of communication between the AI application and the MCP Time Server, secure communication channels are established. Developers can configure additional environment variables to enhance security.
{
"env": {
"API_KEY": "your-api-key",
"SECURITY_TOKEN": "token_value"
}
}
getCurrentTime
command work?The getCurrentTime
command returns the current time in ISO format, which can be used to sync with other timestamped data.
getTimeDifference
method?Yes, you can specify either 'minutes' or 'seconds' as the interval. The server will return a signed difference value based on the selected interval.
Cursor does not support all MCP client features; therefore, it only supports tool integration and not resource management.
It is recommended to stay updated by checking for version updates regularly. The repository should provide clear guidelines on how often to refresh your installation.
Yes, multiple AI applications can connect and use this time server concurrently without performance degradation or conflicts.
Contributions are welcome from the broader developer community. To contribute, please:
git checkout -b feature-branch-name
.npm test
.Once your changes are ready, submit a pull request for review.
The Model Context Protocol (MCP) ecosystem comprises various components and tools designed to enhance AI application development. For more information and resources related to MCP and its clients, visit the official Model Context Protocol documentation and community forums.
graph TD
A[Sub-second Response Time] -->|High Concurrency | B[Scalable]
This completes the comprehensive technical documentation for the MCP Time Server. This guide ensures that developers understand the server's capabilities, integration process, and real-world use cases, positioning it as a vital component in AI application development.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods