Skip to main content
Glama

Beijing Time MCP Server

by archerlliu
MIT License
test_mcp.py2.21 kB
#!/usr/bin/env python3 """ 测试北京时间MCP服务器的脚本 """ import asyncio import json import sys from beijing_time_mcp.server import BeijingTimeServer async def test_server(): """测试服务器功能""" print("🚀 测试北京时间MCP服务器...") server = BeijingTimeServer() # 测试1: 获取默认格式的时间 print("\n📅 测试1: 获取默认格式时间") result = await server._get_beijing_time({}) data = json.loads(result.content[0].text) print(f"时间: {data['time']}") print(f"时区: {data['timezone']}") print(f"星期: {data['day_of_week_cn']}") # 测试2: 获取中文格式时间 print("\n🈳 测试2: 获取中文格式时间") result = await server._get_beijing_time({"format": "%Y年%m月%d日 %H时%M分%S秒"}) data = json.loads(result.content[0].text) print(f"中文时间: {data['time']}") # 测试3: 只获取日期 print("\n📆 测试3: 只获取日期") result = await server._get_beijing_time({"format": "%Y-%m-%d"}) data = json.loads(result.content[0].text) print(f"日期: {data['time']}") # 测试4: 只获取时间 print("\n⏰ 测试4: 只获取时间") result = await server._get_beijing_time({"format": "%H:%M:%S"}) data = json.loads(result.content[0].text) print(f"时间: {data['time']}") # 测试5: 获取完整信息 print("\n📊 测试5: 获取完整信息") result = await server._get_beijing_time({}) data = json.loads(result.content[0].text) print(f"年份: {data['year']}") print(f"月份: {data['month']}") print(f"日期: {data['day']}") print(f"小时: {data['hour']}") print(f"分钟: {data['minute']}") print(f"秒数: {data['second']}") print(f"时间戳: {data['timestamp']}") print(f"ISO格式: {data['iso_format']}") print(f"UTC偏移: {data['utc_offset']}") print("\n✅ 所有测试通过!") if __name__ == "__main__": try: # 运行测试 asyncio.run(test_server()) print("\n🎉 北京时间MCP服务器测试完成!") except Exception as e: print(f"❌ 测试失败: {e}") sys.exit(1)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/archerlliu/time-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server