holiday-mcp-server 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- holiday_mcp_server-0.1.0/PKG-INFO +7 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/PKG-INFO +7 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/SOURCES.txt +8 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/dependency_links.txt +1 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/entry_points.txt +2 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/requires.txt +1 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.egg-info/top_level.txt +1 -0
- holiday_mcp_server-0.1.0/holiday_mcp_server.py +70 -0
- holiday_mcp_server-0.1.0/pyproject.toml +18 -0
- holiday_mcp_server-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
holiday_mcp_server.py
|
|
2
|
+
pyproject.toml
|
|
3
|
+
holiday_mcp_server.egg-info/PKG-INFO
|
|
4
|
+
holiday_mcp_server.egg-info/SOURCES.txt
|
|
5
|
+
holiday_mcp_server.egg-info/dependency_links.txt
|
|
6
|
+
holiday_mcp_server.egg-info/entry_points.txt
|
|
7
|
+
holiday_mcp_server.egg-info/requires.txt
|
|
8
|
+
holiday_mcp_server.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcp>=1.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
holiday_mcp_server
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
from mcp.server import Server
|
|
4
|
+
from mcp.types import Tool, TextContent
|
|
5
|
+
from datetime import date
|
|
6
|
+
import csv
|
|
7
|
+
from io import StringIO
|
|
8
|
+
|
|
9
|
+
app = Server("holiday-mcp-server")
|
|
10
|
+
|
|
11
|
+
# 内置节假日基础数据,后续可以改成从环境变量读取CSV文本
|
|
12
|
+
HOLIDAY_CSV = """date,holiday_name
|
|
13
|
+
2026-01-01,元旦
|
|
14
|
+
2026-01-02,元旦放假
|
|
15
|
+
2026-01-03,元旦放假
|
|
16
|
+
2026-04-04,清明
|
|
17
|
+
2026-04-05,清明放假
|
|
18
|
+
2026-04-06,清明放假
|
|
19
|
+
2026-05-01,劳动节
|
|
20
|
+
2026-05-02,劳动节放假
|
|
21
|
+
2026-05-03,劳动节放假
|
|
22
|
+
2026-06-19,端午
|
|
23
|
+
2026-10-01,国庆
|
|
24
|
+
2026-10-02,国庆
|
|
25
|
+
2026-10-03,国庆
|
|
26
|
+
2026-10-04,国庆
|
|
27
|
+
2026-10-05,国庆
|
|
28
|
+
2026-10-06,国庆
|
|
29
|
+
2026-10-07,国庆
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
@app.list_tools()
|
|
33
|
+
async def list_tools():
|
|
34
|
+
return [
|
|
35
|
+
Tool(
|
|
36
|
+
name="list_holidays",
|
|
37
|
+
description="输入年份,返回该年节假日列表,输出[{month,day,holiday_name},...],供给加班解析Skill使用",
|
|
38
|
+
inputSchema={
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"year": {"type": "integer", "description": "查询年份,例:2026"}
|
|
42
|
+
},
|
|
43
|
+
"required": ["year"]
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
@app.call_tool()
|
|
49
|
+
async def call_tool(name: str, arguments: dict):
|
|
50
|
+
if name != "list_holidays":
|
|
51
|
+
raise ValueError(f"不支持工具:{name}")
|
|
52
|
+
target_year = int(arguments["year"])
|
|
53
|
+
result = []
|
|
54
|
+
reader = csv.DictReader(StringIO(HOLIDAY_CSV))
|
|
55
|
+
for row in reader:
|
|
56
|
+
dt = date.fromisoformat(row["date"].strip())
|
|
57
|
+
if dt.year == target_year:
|
|
58
|
+
result.append({
|
|
59
|
+
"month": dt.month,
|
|
60
|
+
"day": dt.day,
|
|
61
|
+
"holiday_name": row["holiday_name"]
|
|
62
|
+
})
|
|
63
|
+
return [TextContent(type="text", text=str(result))]
|
|
64
|
+
|
|
65
|
+
def main():
|
|
66
|
+
import asyncio
|
|
67
|
+
asyncio.run(app.run())
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
main()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "holiday-mcp-server"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="dev", email="dev@company.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "MCP server:查询指定年份节假日,返回节假日数组,用于加班核算"
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"mcp>=1.0.0"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
holiday-mcp-server = "holiday_mcp_server:main"
|