switch-game-mcp 1.0.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.
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: switch-game-mcp
3
+ Version: 1.0.0
4
+ Summary: Switch游戏折扣与上新查询 MCP Server - 搜游戏、查折扣、查史低价
5
+ License: MIT
6
+ Project-URL: Homepage, https://gitee.com/kkomia/switch-game-mcp
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: fastmcp>=3.0.0
10
+
11
+ # Switch Game MCP Server
12
+
13
+ Switch游戏折扣与上新查询 MCP Server,基于 MCP (Model Context Protocol) 协议。
14
+
15
+ 数据来源:[eshop-prices.com](https://eshop-prices.com)(Nintendo eShop 官方各区服价格数据,实时更新)
16
+
17
+ ## 功能
18
+
19
+ | 工具 | 描述 |
20
+ |------|------|
21
+ | search_switch_games | 搜Switch游戏,返回名字、价格、有没有打折 |
22
+ | get_switch_discounts | 看看现在有啥游戏在打折 |
23
+ | get_new_switch_games | 最近有啥新出的Switch游戏 |
24
+ | get_game_price_info | 查某个游戏的具体价格,划不划算 |
25
+
26
+ ## 安装
27
+
28
+ ```bash
29
+ pip install switch-game-mcp
30
+ ```
31
+
32
+ ## 启动
33
+
34
+ ```bash
35
+ switch-game-mcp
36
+ ```
37
+
38
+ 或者用 uvx(不用装):
39
+
40
+ ```bash
41
+ uvx switch-game-mcp
42
+ ```
43
+
44
+ ## MCP客户端配置
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "switch_game_mcp": {
50
+ "command": "uvx",
51
+ "args": ["switch-game-mcp@latest"],
52
+ "env": {}
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## 环境变量
59
+
60
+ 这个服务不需要配任何环境变量,装好直接用。
61
+
62
+ ## 数据说明
63
+
64
+ 本服务使用 [eshop-prices.com](https://eshop-prices.com) 作为数据源,该网站汇总了 Nintendo Switch eShop 各区域(日服、美服、港服、欧服等)的官方价格数据。
65
+ 价格以人民币(CNY)显示。
66
+
67
+ ## 协议
68
+
69
+ MIT
@@ -0,0 +1,59 @@
1
+ # Switch Game MCP Server
2
+
3
+ Switch游戏折扣与上新查询 MCP Server,基于 MCP (Model Context Protocol) 协议。
4
+
5
+ 数据来源:[eshop-prices.com](https://eshop-prices.com)(Nintendo eShop 官方各区服价格数据,实时更新)
6
+
7
+ ## 功能
8
+
9
+ | 工具 | 描述 |
10
+ |------|------|
11
+ | search_switch_games | 搜Switch游戏,返回名字、价格、有没有打折 |
12
+ | get_switch_discounts | 看看现在有啥游戏在打折 |
13
+ | get_new_switch_games | 最近有啥新出的Switch游戏 |
14
+ | get_game_price_info | 查某个游戏的具体价格,划不划算 |
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ pip install switch-game-mcp
20
+ ```
21
+
22
+ ## 启动
23
+
24
+ ```bash
25
+ switch-game-mcp
26
+ ```
27
+
28
+ 或者用 uvx(不用装):
29
+
30
+ ```bash
31
+ uvx switch-game-mcp
32
+ ```
33
+
34
+ ## MCP客户端配置
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "switch_game_mcp": {
40
+ "command": "uvx",
41
+ "args": ["switch-game-mcp@latest"],
42
+ "env": {}
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## 环境变量
49
+
50
+ 这个服务不需要配任何环境变量,装好直接用。
51
+
52
+ ## 数据说明
53
+
54
+ 本服务使用 [eshop-prices.com](https://eshop-prices.com) 作为数据源,该网站汇总了 Nintendo Switch eShop 各区域(日服、美服、港服、欧服等)的官方价格数据。
55
+ 价格以人民币(CNY)显示。
56
+
57
+ ## 协议
58
+
59
+ MIT
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "switch-game-mcp"
7
+ version = "1.0.0"
8
+ description = "Switch游戏折扣与上新查询 MCP Server - 搜游戏、查折扣、查史低价"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+
13
+ dependencies = [
14
+ "fastmcp>=3.0.0",
15
+ ]
16
+
17
+ [project.urls]
18
+ Homepage = "https://gitee.com/kkomia/switch-game-mcp"
19
+
20
+ [project.scripts]
21
+ switch-game-mcp = "switch_mcp.server:main"
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: switch-game-mcp
3
+ Version: 1.0.0
4
+ Summary: Switch游戏折扣与上新查询 MCP Server - 搜游戏、查折扣、查史低价
5
+ License: MIT
6
+ Project-URL: Homepage, https://gitee.com/kkomia/switch-game-mcp
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: fastmcp>=3.0.0
10
+
11
+ # Switch Game MCP Server
12
+
13
+ Switch游戏折扣与上新查询 MCP Server,基于 MCP (Model Context Protocol) 协议。
14
+
15
+ 数据来源:[eshop-prices.com](https://eshop-prices.com)(Nintendo eShop 官方各区服价格数据,实时更新)
16
+
17
+ ## 功能
18
+
19
+ | 工具 | 描述 |
20
+ |------|------|
21
+ | search_switch_games | 搜Switch游戏,返回名字、价格、有没有打折 |
22
+ | get_switch_discounts | 看看现在有啥游戏在打折 |
23
+ | get_new_switch_games | 最近有啥新出的Switch游戏 |
24
+ | get_game_price_info | 查某个游戏的具体价格,划不划算 |
25
+
26
+ ## 安装
27
+
28
+ ```bash
29
+ pip install switch-game-mcp
30
+ ```
31
+
32
+ ## 启动
33
+
34
+ ```bash
35
+ switch-game-mcp
36
+ ```
37
+
38
+ 或者用 uvx(不用装):
39
+
40
+ ```bash
41
+ uvx switch-game-mcp
42
+ ```
43
+
44
+ ## MCP客户端配置
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "switch_game_mcp": {
50
+ "command": "uvx",
51
+ "args": ["switch-game-mcp@latest"],
52
+ "env": {}
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## 环境变量
59
+
60
+ 这个服务不需要配任何环境变量,装好直接用。
61
+
62
+ ## 数据说明
63
+
64
+ 本服务使用 [eshop-prices.com](https://eshop-prices.com) 作为数据源,该网站汇总了 Nintendo Switch eShop 各区域(日服、美服、港服、欧服等)的官方价格数据。
65
+ 价格以人民币(CNY)显示。
66
+
67
+ ## 协议
68
+
69
+ MIT
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/switch_game_mcp.egg-info/PKG-INFO
4
+ src/switch_game_mcp.egg-info/SOURCES.txt
5
+ src/switch_game_mcp.egg-info/dependency_links.txt
6
+ src/switch_game_mcp.egg-info/entry_points.txt
7
+ src/switch_game_mcp.egg-info/requires.txt
8
+ src/switch_game_mcp.egg-info/top_level.txt
9
+ src/switch_mcp/__init__.py
10
+ src/switch_mcp/server.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ switch-game-mcp = switch_mcp.server:main
@@ -0,0 +1 @@
1
+ fastmcp>=3.0.0
File without changes
@@ -0,0 +1,196 @@
1
+ """
2
+ Switch游戏折扣与上新查询 MCP Server
3
+
4
+ 从 eshop-prices.com 扒Switch游戏价格,数据来源是Nintendo eShop官方,
5
+ 免费公开,不需要Token也不用登录,随便用。
6
+ """
7
+
8
+ import json
9
+ import urllib.request
10
+ import urllib.parse
11
+ import re
12
+ from fastmcp import FastMCP
13
+
14
+ import os
15
+ os.environ["FASTMCP_LOG_LEVEL"] = "ERROR"
16
+
17
+ mcp = FastMCP("switch-game-mcp")
18
+
19
+ # 伪装一下UA,不然会被网站拦
20
+ HEADERS = {
21
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
22
+ "Accept": "text/html",
23
+ }
24
+
25
+
26
+ def _fetch(url: str) -> str:
27
+ """请求网页,拿到HTML"""
28
+ req = urllib.request.Request(url, headers=HEADERS)
29
+ resp = urllib.request.urlopen(req, timeout=15)
30
+ return resp.read().decode("utf-8", errors="replace")
31
+
32
+
33
+ def _parse_games(html: str, limit: int = 15):
34
+ """从eshop-prices.com的页面里抠出游戏列表
35
+
36
+ 这网站的列表页结构还算规矩,每个游戏都在
37
+ <a class="games-list-item"> 里,用正则一把梭就完了
38
+ """
39
+ pattern = r'<a class="games-list-item"[^>]*href="(/games/\d+[^"]*)"[^>]*>(.*?)</a>'
40
+ matches = re.findall(pattern, html, re.DOTALL)
41
+
42
+ games = []
43
+ for href, content in matches:
44
+ # 游戏名在图片的alt属性里
45
+ alt = re.search(r'alt="([^"]+)"', content)
46
+ title = alt.group(1) if alt else "?"
47
+
48
+ # 抠价格(人民币符号¥开头)
49
+ prices = re.findall(r'¥([0-9,]+(?:\.\d{2})?)', content)
50
+
51
+ # 折扣长这样:-80%
52
+ disc = re.findall(r'(-\d+%)', content)
53
+ discount = disc[0] if disc else ""
54
+
55
+ # 描述文字在small标签里
56
+ small = re.search(r'<small[^>]*>(.*?)</small>', content)
57
+ desc = re.sub(r'<[^>]+>', '', small.group(1)).strip() if small else ""
58
+
59
+ game = {
60
+ "title": title,
61
+ "original_price": f"¥{prices[0]}" if len(prices) >= 1 else "",
62
+ "sale_price": f"¥{prices[1]}" if len(prices) >= 2 else "",
63
+ "discount": discount,
64
+ "description": desc[:120] if desc else "",
65
+ "url": f"https://eshop-prices.com{href}",
66
+ }
67
+ games.append(game)
68
+ if len(games) >= limit:
69
+ break
70
+
71
+ return games
72
+
73
+
74
+ @mcp.tool()
75
+ def search_switch_games(keyword: str, limit: int = 10) -> str:
76
+ """搜Switch游戏,返回名字、价格、有没有打折
77
+
78
+ Args:
79
+ keyword: 搜啥(中文英文都行)
80
+ limit: 返回几条,默认10
81
+ """
82
+ q = urllib.parse.quote(keyword)
83
+ url = f"https://eshop-prices.com/games?q={q}&currency=CNY"
84
+
85
+ try:
86
+ html = _fetch(url)
87
+ games = _parse_games(html, limit)
88
+ except Exception as e:
89
+ return f"搜不到,网络可能有问题: {e}"
90
+
91
+ if not games:
92
+ return f"没找到\"{keyword}\"相关的Switch游戏,要不换个英文名试试?"
93
+
94
+ output = f"🎮 搜\"{keyword}\"的结果:\n\n"
95
+ for g in games:
96
+ output += f"📌 {g['title']}\n"
97
+ if g["original_price"]:
98
+ output += f" 原价: {g['original_price']}"
99
+ if g["sale_price"] and g["sale_price"] != g["original_price"]:
100
+ output += f" → 折后: {g['sale_price']} {g['discount']}"
101
+ output += "\n"
102
+ if g["description"]:
103
+ output += f" {g['description']}\n"
104
+ output += "\n"
105
+
106
+ return output
107
+
108
+
109
+ @mcp.tool()
110
+ def get_switch_discounts(page_size: int = 15) -> str:
111
+ """看看Switch现在有啥游戏在打折"""
112
+ try:
113
+ html = _fetch("https://eshop-prices.com/discounts?currency=CNY")
114
+ games = _parse_games(html, page_size)
115
+ except Exception as e:
116
+ return f"没拉到折扣数据: {e}"
117
+
118
+ if not games:
119
+ return "今天好像没啥打折的"
120
+
121
+ output = "🔥 Switch游戏打折清单\n\n"
122
+ for i, g in enumerate(games, 1):
123
+ output += f"{i}. {g['title']}\n"
124
+ if g["original_price"]:
125
+ output += f" 原价: {g['original_price']}"
126
+ if g["sale_price"] and g["sale_price"] != g["original_price"]:
127
+ output += f" → {g['sale_price']} {g['discount']}"
128
+ output += "\n\n"
129
+
130
+ return output
131
+
132
+
133
+ @mcp.tool()
134
+ def get_new_switch_games(page_size: int = 10) -> str:
135
+ """最近有啥新出的Switch游戏"""
136
+ try:
137
+ html = _fetch("https://eshop-prices.com/new-games?currency=CNY")
138
+ games = _parse_games(html, page_size)
139
+ except Exception as e:
140
+ return f"没拉到新游戏数据: {e}"
141
+
142
+ if not games:
143
+ return "最近好像没啥新游戏"
144
+
145
+ output = "🆕 最近上架的Switch游戏\n\n"
146
+ for i, g in enumerate(games, 1):
147
+ output += f"{i}. {g['title']}\n"
148
+ if g["original_price"]:
149
+ output += f" 价格: {g['original_price']}"
150
+ if g["sale_price"] and g["sale_price"] != g["original_price"]:
151
+ output += f" → {g['sale_price']}"
152
+ output += "\n"
153
+ output += "\n"
154
+
155
+ return output
156
+
157
+
158
+ @mcp.tool()
159
+ def get_game_price_info(game_name: str) -> str:
160
+ """查某个游戏的具体价格,看看划不划算
161
+
162
+ Args:
163
+ game_name: 游戏名字(英文名搜得更准)
164
+ """
165
+ q = urllib.parse.quote(game_name)
166
+ url = f"https://eshop-prices.com/games?q={q}&currency=CNY"
167
+
168
+ try:
169
+ html = _fetch(url)
170
+ games = _parse_games(html, 1)
171
+ except Exception as e:
172
+ return f"查不到: {e}"
173
+
174
+ if not games:
175
+ return f"没找到\"{game_name}\"的信息"
176
+
177
+ g = games[0]
178
+ output = f"📊 \"{g['title']}\" 的价格\n\n"
179
+
180
+ if g["original_price"]:
181
+ output += f"💰 现在卖:\n"
182
+ output += f" 原价: {g['original_price']}\n"
183
+ if g["sale_price"] and g["sale_price"] != g["original_price"]:
184
+ output += f" 打折: {g['sale_price']} {g['discount']}\n"
185
+
186
+ output += f"\n🔗 各区服价格对比: {g['url']}\n"
187
+ output += f"\n数据来源: eshop-prices.com (就是Nintendo eShop官方数据,实时的)"
188
+ return output
189
+
190
+
191
+ def main():
192
+ mcp.run(transport="stdio")
193
+
194
+
195
+ if __name__ == "__main__":
196
+ main()