MCP Hub
Back to servers

datetime-mcp-server

Provides a tool to retrieve the current date and time with customizable formatting placeholders for year, month, day, hour, minute, and second. It supports both stdio and HTTP transport modes for integration with Model Context Protocol clients.

glama
Updated
Mar 11, 2026

datetime-mcp-server

中文版

Overview

datetime-mcp-server is a Model Context Protocol (MCP) server that provides a tool for getting the current date and time with customizable format.

Features

  • Get current datetime with customizable format
  • Default format: yyyy-MM-dd (e.g., "2026-03-11")
  • Supports various format placeholders: yyyy, MM, dd, HH, mm, ss
  • Supports both stdio and HTTP transport modes

Installation

# Install globally
npm install -g datetime-mcp-server

# Or run directly with npx
npx datetime-mcp-server

Usage

Command Line (stdio)

# Run with stdio (default)
npx datetime-mcp-server

HTTP Server

# Run HTTP server on port 3000
TRANSPORT=http npx datetime-mcp-server

# Custom port
PORT=8080 TRANSPORT=http npx datetime-mcp-server

Claude Code Integration

Add to your ~/.claude.json:

{
  "mcpServers": {
    "datetime": {
      "command": "npx",
      "args": ["-y", "datetime-mcp-server"]
    }
  }
}

Available Tool

get_current_datetime

Get the current date and time with custom format.

Parameters:

ParameterTypeRequiredDefaultDescription
formatstringNoyyyy-MM-ddDate format string

Format Placeholders:

PlaceholderDescriptionExample
yyyy4-digit year2026
MM2-digit month01-12
dd2-digit day01-31
HH24-hour hour00-23
mm2-digit minute00-59
ss2-digit second00-59

Examples:

{
  "name": "get_current_datetime",
  "arguments": {}
}
// Returns: "2026-03-11"

{
  "name": "get_current_datetime",
  "arguments": {
    "format": "yyyy-MM-dd HH:mm:ss"
  }
}
// Returns: "2026-03-11 14:30:45"

{
  "name": "get_current_datetime",
  "arguments": {
    "format": "yyyy/MM/dd HH:mm"
  }
}
// Returns: "2026/03/11 14:30"

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

License

MIT

Reviews

No reviews yet

Sign in to write a review