Date-MCP Server

Date-MCP Server

A Model Context Protocol service that handles date and time conversions for China's timezone (UTC+8), supporting current date retrieval, timestamp conversions, and date-time formatting.

Category
Visit Server

README

Date-MCP 服务

一个基于Model Context Protocol (MCP)的日期时间处理服务,专注于处理东八区(中国)时间与时间戳的转换。

功能特点

  • 获取当前日期:返回东八区(中国)当前日期
  • 时间戳转换:将13位毫秒级时间戳转换为东八区日期时间
  • 日期转时间戳:将东八区日期时间字符串转换为13位毫秒级时间戳
  • 问候资源:提供简单的问候功能

系统要求

  • Python >= 3.13
  • 依赖包:mcp[cli] >= 1.9.1, pytz

安装说明

  1. 克隆仓库
git clone <仓库地址>
cd date_mcp
  1. 安装依赖
pip install -e .

或使用 uv 安装(推荐):

uv pip install -e .

使用方法

启动服务

python main.py

或使用 MCP CLI 工具:

mcp dev main.py

可用工具

  1. 获取当前日期
# 工具名: get_date
# 返回格式: YYYY-MM-DD
response = await client.call_tool("get_date")
# 示例输出: "2024-05-28"
  1. 时间戳转日期时间
# 工具名: timestamp_to_china_date
# 参数: millis_timestamp (int) - 13位毫秒级时间戳
response = await client.call_tool("timestamp_to_china_date", {"millis_timestamp": 1746773348432})
# 示例输出: "2025-05-09 12:35:48.432"
  1. 日期时间转时间戳
# 工具名: china_date_to_timestamp
# 参数: date_str (str) - 东八区时间字符串
response = await client.call_tool("china_date_to_timestamp", {"date_str": "2025-05-09 12:35:48.432"})
# 示例输出: 1746773348432

可用资源

问候资源

# 资源URI: greeting://{name}
# 参数: name (str) - 要问候的名称
response = await client.get_resource(f"greeting://World")
# 示例输出: "Hello, World!"

客户端示例

from mcp.client import Client
from mcp.transport import StdioClientTransport

async def main():
    # 创建客户端
    transport = StdioClientTransport("python main.py")
    client = Client(transport)
    
    # 连接到服务器
    await client.connect()
    
    # 调用工具示例
    current_date = await client.call_tool("get_date")
    print(f"当前日期: {current_date}")
    
    # 时间戳转日期
    timestamp = 1746773348432
    date_time = await client.call_tool("timestamp_to_china_date", {"millis_timestamp": timestamp})
    print(f"时间戳 {timestamp} 对应的日期时间: {date_time}")
    
    # 日期转时间戳
    date_str = "2025-05-09 12:35:48.432"
    new_timestamp = await client.call_tool("china_date_to_timestamp", {"date_str": date_str})
    print(f"日期时间 {date_str} 对应的时间戳: {new_timestamp}")
    
    # 获取问候资源
    greeting = await client.get_resource("greeting://World")
    print(greeting)
    
    # 断开连接
    await client.disconnect()

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

许可证

贡献指南

欢迎提交问题和拉取请求,共同改进这个项目。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured