date-tool-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
date-tool-mcp
一个基于 MCP (Model Context Protocol) 与 LangChain 的最小示例:用 MCP Server 暴露一个「获取今天日期」的工具,再让大模型通过自然语言调用它。
项目同时演示 MCP 的三种传输方式:
传输方式 | Server | 客户端连接地址 |
stdio |
| 由客户端以子进程方式启动 |
SSE |
|
|
Streamable HTTP |
|
|
项目结构
.
├── mcp_client.py # LangChain Agent 客户端(含三种传输的配置示例)
├── mcp_demo.py # 使用官方 mcp-server-time 的示例(依赖 uv / uvx)
├── mcp_server_stdio.py # stdio 传输的 MCP Server
├── mcp_server_sse.py # SSE 传输的 MCP Server
├── mcp_server_streamable.py # Streamable HTTP 传输的 MCP Server
├── requirements.txt
├── .env.example
└── LICENSERelated MCP server: DateTime-LocalMCPServer
环境要求
Python 3.10+(实测 3.12)
可选:
uv(仅mcp_demo.py需要,用于uvx启动官方 time server)
安装
pip install -r requirements.txt配置
客户端通过环境变量读取 API Key:
$env:DASHSCOPE_API_KEY="你的 DashScope API Key"也可以复制 .env.example 为 .env 后填写。注意当前代码是直接用 os.getenv 读取环境变量;若想让 .env 自动生效,请自行安装 python-dotenv 并在入口处调用 load_dotenv()。
使用
mcp_client.py 中的三种连接配置默认以注释形式给出,按需取消注释其中一种即可。
1) stdio
客户端会自动以子进程方式启动 mcp_server_stdio.py,直接运行:
python mcp_client.py请把配置里
"args"的路径改成你本机mcp_server_stdio.py的绝对路径。
2) SSE
先启动 Server:
python mcp_server_sse.py再在客户端启用 date-tool-sse 配置并运行:
python mcp_client.py3) Streamable HTTP
先启动 Server:
python mcp_server_streamable.py再在客户端启用 date-tool-streamable 配置并运行:
python mcp_client.pySSE 与 Streamable HTTP 默认都监听
127.0.0.1:8000,请勿同时启动。
附加示例:官方 time server
python mcp_demo.py需要已安装 uv。
自定义
get_today 工具定义在各 mcp_server_*.py 中,使用 @mcp.tool() 装饰普通函数即可新增工具:
@mcp.tool()
def get_today() -> str:
"""返回当前的年月日,格式 YYYY-MM-DD。"""
return datetime.now().strftime("%Y-%m-%d")License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Current time, timezone conversion & date math for AI agents. On Cloudflare Workers.
Time and date math for AI agents: Unix timestamp conversion, DST-correct time zone conversion, durations, epoch arithmetic, cron schedules, and holiday countdowns. Eight tools, no key.
Deterministic calendars and cosmic date JSON for AI agents via MCP (Gregorian 1900-2100).
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Related MCP Servers
- FlicenseAqualityDmaintenanceA general-purpose MCP server providing time-related utilities such as fetching current time, Unix timestamps, and formatting services. It supports both local stdio and remote SSE communication modes for versatile AI client integration.3-
- AlicenseAqualityDmaintenanceA Model Context Protocol server built with FastMCP that provides tools for retrieving the current local date and time. It allows LLMs to access precise temporal information directly from the host environment.9MIT
- AlicenseDqualityCmaintenanceA lightweight MCP server that provides date and time tools, including the ability to retrieve current timestamps and parse date strings with IANA timezone support. It enables AI models to interact with the host OS clock and perform temporal calculations via stdio transport.36 npm7MIT
- AlicenseAqualityDmaintenanceMCP server providing various date/time functions including current time, timezone conversion, and relative time calculations. Supports both local stdio and remote HTTP access via Cloudflare Workers.6265 npm2MIT