io.github.mcpcentral-io/mcp-time

平台与服务

by mcpcentral-io

通过 HTTP 提供时间能力的轻量级 MCP server,可用于获取当前时间、时区等相关信息。

什么是 io.github.mcpcentral-io/mcp-time

通过 HTTP 提供时间能力的轻量级 MCP server,可用于获取当前时间、时区等相关信息。

README

MCP Time Server

A Model Context Protocol (MCP) server providing time-related tools with dual-mode support:

  • Stdio transport for local MCP clients (via npm)
  • Streamable HTTP transport for remote access (via Cloudflare Workers)

This server allows LLMs to access various date/time functions through multiple connection methods.

MCP Central Server Card: https://guide-gen.mcpcentral.io/servers/io-github-mcpcentral-io-mcp-time

Features

Provides the following MCP tools:

  • current_time: Get the current date and time in specified formats and timezones.
  • relative_time: Get a human-readable relative time string (e.g., "in 5 minutes", "2 hours ago").
  • days_in_month: Get the number of days in a specific month.
  • get_timestamp: Get the Unix timestamp (milliseconds) for a given time.
  • convert_time: Convert a time between different IANA timezones.
  • get_week_year: Get the week number and ISO week number for a given date.

Project Structure

code
mcp-time/
├── src/
│   └── index.ts      # Cloudflare Worker entry point & MCP logic
├── package.json      # Project dependencies and scripts
├── tsconfig.json     # TypeScript configuration
└── wrangler.toml     # Cloudflare Worker configuration

Installation

Option 1: Install from npm (Stdio Mode)

Install the package globally or use with npx:

bash
# Global installation
npm install -g @mcpcentral/mcp-time

# Or use directly with npx
npx @mcpcentral/mcp-time

Option 2: Use Remote Server (HTTP Mode)

Connect directly to the deployed Cloudflare Worker:

Example:

code
https://mcp.time.mcpcentral.io

Usage

Stdio Transport (Local)

Configure your MCP client (e.g., Claude Desktop) to use the stdio transport:

json
{
  "mcpServers": {
    "time-server": {
      "command": "npx",
      "args": ["@mcpcentral/mcp-time"]
    }
  }
}

Or with global installation:

json
{
  "mcpServers": {
    "time-server": {
      "command": "/path/to/node/bin/mcp-time"
    }
  }
}

Streamable HTTP Transport (Remote)

Configure your MCP client to use the remote HTTP endpoint:

json
{
  "mcpServers": {
    "time-server": {
      "url": "https://mcp.time.mcpcentral.io",
      "transport": "streamable-http"
    }
  }
}

Development

  1. Clone the Repository:

    bash
    git clone https://github.com/mcpcentral-io/mcp-time.git
    cd mcp-time
    
  2. Install Dependencies:

    bash
    npm install
    
  3. Build: Compile the TypeScript code:

    bash
    npm run build
    

    (This compiles src/index.ts to dist/index.js)

  4. Test Locally:

    Test Stdio Mode:

    bash
    echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | node dist/index.js
    

    Test HTTP Mode (via Wrangler):

    bash
    npx wrangler dev
    

    This will start the server on http://localhost:8787. You can then test with curl or point your MCP client to this local endpoint.

Deployment

Deploy to Cloudflare Workers (HTTP Mode)

  1. Configure Cloudflare:

    bash
    cp wrangler.toml.example wrangler.toml
    

    Edit wrangler.toml to configure your domain (optional).

  2. Login and Deploy:

    bash
    wrangler login
    npx wrangler deploy
    

Publish to npm (Stdio Mode)

  1. Build the package:

    bash
    npm run build
    
  2. Publish:

    bash
    npm publish --access public
    

Connectors for Streamable HTTP Servers

NEW: Major providers have adopted the Model Context Protocol and now support Streamable HTTP servers directly. Anthropic, OpenAI, and Microsoft have all adopted this modern transport protocol.

📋 Protocol Note: Streamable HTTP is the modern replacement for the deprecated HTTP+SSE transport.

Anthropic MCP Connector

Anthropic's MCP Connector allows you to use Streamable HTTP servers directly through the Messages API without needing a separate MCP client.

The MCP Connector is perfect for this server since it uses the Streamable HTTP architecture. Simply include the server in your API requests:

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: mcp-client-2025-04-04" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1000,
    "messages": [{
      "role": "user", 
      "content": "What time is it in Tokyo?"
    }],
    "mcp_servers": [{
      "type": "url",
      "url": "https://your.worker.url.workers.dev",
      "name": "http-time-server"
    }]
  }'

Anthropic MCP Connector Benefits:

  • No client setup required - Connect directly through the API
  • Native Streamable HTTP support - Designed for servers like this one

OpenAI Agents SDK

OpenAI also supports Streamable HTTP servers through their Agents SDK using the MCPServerStreamableHttp class:

python
from agents.mcp.server import MCPServerStreamableHttp

# Connect to this Streamable HTTP server
server = MCPServerStreamableHttp({
    "url": "https://your.worker.url.workers.dev",
    "headers": {"Authorization": "Bearer your-token"},  # if needed
})

# Use the server in your OpenAI agent
await server.connect()
tools = await server.list_tools()
result = await server.call_tool("current_time", {"timezone": "Asia/Tokyo"})

Microsoft Copilot Studio

Microsoft Copilot Studio now supports Streamable HTTP servers with MCP integration generally available. You can connect this server to Copilot Studio by:

  1. Building a custom connector that links your MCP server to Copilot Studio
  2. Adding the tool in Copilot Studio by selecting 'Add a Tool' and searching for your MCP server
  3. Using the server directly in your agents with generative orchestration enabled

More MCP Clients Coming Soon

Keep an eye out as more MCP clients adopt support for Streamable HTTP. Here are a few resources that maintain lists of MCP clients and their capabilities:

Testing and Validation

MCP Inspector Tools (HTTP Mode)

Test your server using these web-based inspection tools:

MCPCentral Tools (Recommended)

Official MCP Inspector

The official MCP Inspector is also available:

Testing Steps

  1. Start your server:

    bash
    # Local HTTP server
    npx wrangler dev
    
    # Or use deployed URL: https://mcp.time.mcpcentral.io
    
  2. Connect with an inspector:

    • Transport: Streamable HTTP
    • URL: http://localhost:8787 or https://mcp.time.mcpcentral.io
    • Click Connect

Command Line Testing (Stdio Mode)

Test the stdio transport directly:

bash
# Test initialization
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | npx @mcpcentral/mcp-time

# Test tool call
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"current_time","arguments":{"timezone":"America/New_York"}}}' | npx @mcpcentral/mcp-time

Available Tools to Test

The inspector will show all six time-related tools:

  • current_time: Test with different timezones (e.g., "America/New_York", "Europe/London")
  • relative_time: Test with various time strings (e.g., "2024-12-25T00:00:00Z")
  • days_in_month: Test with different months and years
  • get_timestamp: Convert date-time strings to Unix timestamps
  • convert_time: Convert between different timezones
  • get_week_year: Get week numbers for specific dates

Example Test Cases

Try these test cases in the inspector:

json
// current_time
{"timezone": "Asia/Tokyo", "format": "iso"}

// relative_time  
{"time": "2024-12-25T00:00:00Z"}

// days_in_month
{"month": 2, "year": 2024}

// get_timestamp
{"time": "2024-06-15T12:00:00Z"}

// convert_time
{"time": "2024-06-15T12:00:00", "from": "UTC", "to": "America/Los_Angeles"}

// get_week_year
{"date": "2024-06-15"}

Validation Checklist

Use the inspector to verify:

  • ✅ Server connects successfully
  • ✅ All 6 tools are listed
  • ✅ Tool schemas are properly defined
  • ✅ Tools execute without errors
  • ✅ Results are formatted correctly
  • ✅ Error handling works for invalid inputs

The MCP Inspector provides the most comprehensive way to test your server before integrating it with AI clients.


Authentication & Security Considerations

⚠️ IMPORTANT: This example server has NO authentication or security measures implemented.

常见问题

io.github.mcpcentral-io/mcp-time 是什么?

通过 HTTP 提供时间能力的轻量级 MCP server,可用于获取当前时间、时区等相关信息。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描114.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描114.1k

MCP服务构建器

by alirezarezvani

Universal
热门

从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。

帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。

平台与服务
未扫描10.2k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
83.4k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.4k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
35.4k

评论