MCP ExplorerExplorer

Datetime Remote Mcp

@ajoton 16 days ago
1 MIT
FreeCommunity
AI Systems
A FastMCP server providing current date and time in specified timezones.

Overview

What is Datetime Remote Mcp

datetime-remote-mcp is a FastMCP server that provides a tool to return the current date and time in a specified timezone, built using Python and FastMCP.

Use cases

Use cases include integrating with chatbots to provide current time information, developing scheduling applications that adjust for user timezones, and creating APIs that deliver date and time data for various applications.

How to use

To use datetime-remote-mcp, clone the repository, set up a virtual environment, install the required dependencies, and run the server locally. You can call the ‘current_datetime’ tool with an optional timezone parameter.

Key features

Key features include the ability to return the current date and time as a string, support for different timezones, exposure via the MCP protocol for LLMs and other clients, and running as a streamable HTTP server.

Where to use

datetime-remote-mcp can be used in applications requiring real-time date and time information, such as scheduling tools, event management systems, and any software needing timezone-aware timestamps.

Content

Current Date and Time MCP Server

This project is a simple FastMCP server that exposes a tool to return the current date and time in a specified timezone. It demonstrates how to build and run a Model Context Protocol (MCP) server using Python and FastMCP.

Features

  • Current Date and Time Tool: Returns the current date and time as a string, with optional timezone support (defaults to America/New_York).
  • MCP Protocol: Exposes the tool via the MCP protocol for use by LLMs and other MCP clients.
  • Streamable HTTP: Runs as a web server on a configurable port (default: 8000).

Requirements

Setup

  1. Clone the repository

    git clone <your-repo-url>
    cd datetime-remote-mcp
    
  2. Create a virtual environment (recommended)

    python3 -m venv .venv
    source .venv/bin/activate
    
  3. Install dependencies

    pip install -r requirements.txt
    

Usage

Run the MCP server locally:

python server.py
  • The server will start on 0.0.0.0:8000 by default. You can override the port by setting the PORT environment variable:

    PORT=8080 python server.py
    
  • The server exposes a single tool:

    • current_datetime(timezone: str = “America/New_York”) -> str
      • Returns the current date and time as a string in the specified timezone.
      • Example: 2024-06-05 14:23:45 EDT
      • If an invalid timezone is provided, returns an error message.

Example Tool Call

from fastmcp import Client
import asyncio

async def main():
    async with Client("http://localhost:8000/mcp") as client:
        result = await client.call_tool("current_datetime", {"timezone": "UTC"})
        print(result.text)

asyncio.run(main())

FastMCP Resources

License

This project is provided under the Apache-2.0 license (see FastMCP for details).

Tools

No tools

Comments