Time MCP Server

Time MCP Server

Provides current time and date information with timezone support and multiple formatting options. Enables AI assistants to answer time-related queries in different timezones with detailed temporal information.

Category
访问服务器

README

Time MCP Server

A Model Context Protocol (MCP) server that provides time and date information for AI assistants like Claude in VSCode.

Features

  • Current Time: Get the current time in various formats
  • Timezone Support: Query time in different timezones
  • Detailed Info: Get comprehensive time information including day of week, timestamp, etc.
  • Multiple Formats: Support for 12-hour, 24-hour, and ISO formats

Available Tools

get_current_time

Get the current date and time with formatting options.

Parameters:

  • timezone (optional): Timezone identifier (e.g., "America/New_York", "Europe/London", "Asia/Tokyo")
  • format (optional): Time format - "12hour" (default), "24hour", or "iso"

Examples:

  • "What time is it?"
  • "Get current time in Tokyo"
  • "Show me the time in 24-hour format"

get_time_info

Get detailed time information including timezone data, day of week, and timestamps.

Parameters:

  • timezone (optional): Timezone identifier

Examples:

  • "Give me detailed time information"
  • "Show time info for London timezone"

Prerequisites

  • Node.js (v18 or higher)
  • npm
  • Docker Desktop (for Docker builds)
    • Install via: brew install --cask docker
    • Or download from https://www.docker.com/products/docker-desktop/
    • Important: You need Docker Desktop (full app), not just Docker CLI

Installation

Local Development

  1. Clone or create the project:

    mkdir time-mcp-server
    cd time-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Docker Deployment

Prerequisites: Ensure Docker Desktop is running

# Check Docker is running
docker ps

# If not running, start Docker Desktop
open -a Docker  # or open -a "Docker Desktop"
  1. Build and run with Docker Compose:

    docker-compose up -d
    
  2. Or build manually:

    docker build -t time-mcp-server .
    docker run -d --name time-mcp-server time-mcp-server
    
  3. View logs:

    docker-compose logs -f time-mcp-server
    

Configuration

Configuration

Local Development - Claude in VSCode

For local Node.js execution:

{
  "servers": {
    "time-server": {
      "command": "node",
      "args": ["dist/index.js"],
      "env": {},
      "cwd": "."
    }
  }
}

Docker Deployment - Claude in VSCode

Option 1: Docker Exec (Recommended)

For a running Docker container:

{
  "servers": {
    "time-server": {
      "command": "docker",
      "args": ["exec", "-i", "time-mcp-server", "node", "dist/index.js"],
      "env": {}
    }
  }
}

Option 2: Docker Run (Creates new container each time)

{
  "servers": {
    "time-server": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "time-mcp-server"],
      "env": {}
    }
  }
}

Combined Configuration (Both Docker and Local)

Use this configuration to have both options available simultaneously:

{
  "servers": {
    "time-server-docker": {
      "command": "docker",
      "args": ["exec", "-i", "time-mcp-server", "node", "dist/index.js"],
      "env": {}
    },
    "time-server-local": {
      "command": "node",
      "args": ["dist/index.js"],
      "env": {},
      "cwd": "."
    }
  }
}

Benefits of combined configuration:

  • Fallback options - If Docker is down, local still works
  • Performance testing - Compare Docker vs local performance
  • Development flexibility - Switch between deployment methods
  • Redundancy - Multiple servers provide the same functionality

Note: Place your mcp.json file in the project root directory (same level as package.json) for relative paths to work correctly.

Configuration Steps

For Docker Setup:

  1. Start your Docker container:

    docker-compose up -d
    
  2. Verify container is running:

    docker ps | grep time-mcp-server
    
  3. Update mcp.json with Docker configuration

For Local Setup:

  1. Build the project:

    npm run build
    # or
    ./ci.sh
    
  2. Place mcp.json in project root (same directory as package.json)

  3. Test it works:

    npm test
    

For Combined Setup:

  1. Ensure both are working (Docker container running + local build exists)
  2. Place the mcp.json in your project root directory
  3. Use the combined mcp.json configuration above

Testing Your Configuration

Test Docker version:

echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | docker exec -i time-mcp-server node dist/index.js

Test local version:

echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | node dist/index.js

Check logs:

# Docker logs
docker-compose logs -f time-mcp-server

# Local logs appear in terminal when running

Quick Start Guide

  1. Build everything with CI script:

    chmod +x ci.sh
    ./ci.sh
    
  2. For Docker deployment:

    # Ensure Docker Desktop is running
    docker ps
    
    # Build with Docker
    BUILD_TYPE=docker ./ci.sh
    
    # Start the container
    docker-compose up -d
    
  3. Configure Claude in VSCode with appropriate mcp.json

Usage Examples

Once configured with Claude in VSCode, you can ask natural language questions:

  • "What time is it?" → Returns current time
  • "What time is it in New York?" → Returns time in EST/EDT
  • "Show me the time in 24-hour format" → Returns time in 24-hour format
  • "Get detailed time information" → Returns comprehensive time data
  • "What day is today?" → Uses detailed info to show current day

Development

Project Structure

time-mcp-server/
├── src/
│   └── index.ts          # Main server code
├── dist/                 # Built JavaScript (generated)
├── ci.sh                 # CI/CD build script
├── Dockerfile            # Docker image definition
├── docker-compose.yml    # Docker orchestration
├── .dockerignore         # Docker build exclusions
├── package.json
├── tsconfig.json
├── .gitignore
└── README.md

Local Development Scripts

  • npm run build - Build TypeScript to JavaScript
  • npm run dev - Build and run the server (for MCP clients)
  • npm start - Run the built server (for MCP clients)
  • npm test - Quick test to verify server is working

CI/CD Build Script

Use the included ci.sh script for automated building and testing:

# Make executable (first time only)
chmod +x ci.sh

# Basic build and test
./ci.sh

# Docker build only
BUILD_TYPE=docker ./ci.sh

# Full build (local + Docker)
BUILD_TYPE=all ./ci.sh

# Skip tests
RUN_TESTS=false ./ci.sh

# Custom Docker tag
BUILD_TYPE=docker DOCKER_TAG=v1.0.0 ./ci.sh

# CI environment
CI=true ./ci.sh

CI Script Features:

  • ✅ Prerequisite checking (Node.js, Docker)
  • ✅ Automated building (TypeScript + Docker)
  • ✅ Comprehensive testing (tool listing, function calls)
  • ✅ Cross-platform compatibility (macOS/Linux)
  • ✅ Color-coded output and error handling
  • ✅ Build artifact generation

Testing

Quick Test:

npm test

Manual Testing:

# Test tool listing
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | node dist/index.js

# Test getting current time
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "get_current_time", "arguments": {}}}' | node dist/index.js

Note: npm start and npm run dev will appear to "hang" - this is normal! The server is waiting for MCP protocol messages on stdin. Use the test commands above or configure with Claude to interact with it.

Supported Timezones

The server supports any valid IANA timezone identifier, including:

  • America/New_York
  • Europe/London
  • Asia/Tokyo
  • Australia/Sydney
  • UTC

Dependencies

  • @modelcontextprotocol/sdk - Official MCP SDK
  • typescript - TypeScript compiler
  • @types/node - Node.js type definitions

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Build and test: npm run build
  5. Submit a pull request

Troubleshooting

Common Issues

"No inputs were found" error:

  • Ensure the src/index.ts file exists
  • Run npm run build after creating the file

Docker not working:

  • Ensure Docker Desktop is installed and running: brew install --cask docker
  • Start Docker Desktop: open -a Docker (wait for whale icon in menu bar)
  • Verify with: docker ps (should not show connection errors)
  • Docker Desktop takes 30-60 seconds to fully start after launching

Server appears to hang:

  • This is normal behavior! The server waits for MCP protocol messages on stdin
  • Use npm test for quick verification, or configure with Claude for actual usage
  • The server only responds when it receives proper JSON-RPC messages

TypeScript errors:

  • Make sure all dependencies are installed: npm install
  • Check TypeScript version compatibility

Debug Mode

Add console logging by setting environment variables:

{
  "servers": {
    "time-server": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "env": {
        "DEBUG": "true"
      }
    }
  }
}

Version History

  • 0.1.0 - Initial release with basic time functionality

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选