Skip to main content

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_time tool to retrieve the current time
  • Supports optional timezone parameter
  • Returns time in ISO 8601 format
  • Handles unknown timezone errors gracefully

Requirements

  • Python 3.7+
  • mcp Python SDK
  • pytz library (for timezone support)

Installation

pip install mcp-time-server

Usage

  1. Run the server:
mcp-time-server
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_time_servercuclsy-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_time_servercuclsy-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for mcp_time_servercuclsy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8eeb7f85b94718d0e1344b67b7e065688e3240dd95f8d94002024bb0bbca6bbc
MD5 9bb6bcf67491987fa3edb8e0640ef9d8
BLAKE2b-256 e10b82c3aca9dccd6030cdf37d28b23ff0ebdcffaaf65265ffab618d4b4b9d38

See more details on using hashes here.

File details

Details for the file mcp_time_servercuclsy-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_time_servercuclsy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff1eaab8be310f649a3fe6850d0bc4ffaa4b8b1cb828c7a9909f4ac23b9d57f9
MD5 b7498a6f324f28d7153056b4877cb958
BLAKE2b-256 bc1530b836ed9b394de0405dbdd7eaa154e5db1ef26da32dc02732d698e74904

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page