ben-music-mcp 0.1.1__tar.gz → 0.1.4__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: ben-music-mcp
3
+ Version: 0.1.4
4
+ Summary:
5
+ Author: ben
6
+ Author-email: 2014911413@qq.com
7
+ Requires-Python: >=3.12
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Requires-Dist: fastmcp (>=2.13.0.2)
13
+ Requires-Dist: requests (>=2.32.4)
14
+ Description-Content-Type: text/markdown
15
+
16
+ # ben-music-mcp
17
+
18
+ 本产品是一套面向开发者和智能体的音乐信息服务工具,专注于高效、专业的音乐数据获取与个性化推荐。所有接口均采用标准 JSON 格式,便于自动化集成与二次开发。
19
+
20
+ ---
21
+
22
+ ## 产品功能概览
23
+
24
+ ### 歌曲与歌手信息
25
+ - **歌曲检索**:支持通过关键词精准获取歌曲详情,包括名称、艺人、专辑等核心信息。
26
+ - **歌词查询**:一键获取任意歌曲的完整歌词文本。
27
+ - **歌手检索与详情**:快速定位歌手并获取其详细资料及代表作品。
28
+ - **热门歌曲榜单**:自动获取歌手最受欢迎的曲目列表。
29
+
30
+ ### 音乐播放与评论
31
+ - **在线试听链接**:根据需求获取不同音质等级的音乐播放地址。
32
+ - **热门评论提取**:智能筛选并返回歌曲的高质量评论,便于用户快速了解口碑。
33
+ - **相似歌曲推荐**:基于音乐特征,智能推荐与目标歌曲风格相近的作品。
34
+
35
+ ### 歌单与榜单服务
36
+ - **歌单详情查询**:支持按歌单编号获取完整歌单信息,涵盖曲目、封面、创建者等。
37
+ - **排行榜检索**:覆盖主流及特色音乐榜单,助力发现最新流行趋势。
38
+ - **用户歌单获取**:根据用户昵称,自动获取其公开歌单列表。
39
+
40
+ ### 曲风与标签体系
41
+ - **曲风分类查询**:支持按风格名称获取对应曲风下的热门歌曲。
42
+ - **风格列表获取**:一键获取所有可选音乐风格,便于个性化筛选。
43
+ - **榜单名称获取**:快速获取所有可用排行榜名称,提升榜单检索效率。
44
+
45
+ ### 用户与客户端服务
46
+ - **用户身份查询**:通过昵称获取用户唯一标识,便于个性化服务。
47
+ - **本地客户端启动**:支持远程启动本地网易云音乐客户端,提升桌面体验。
48
+
49
+ ---
50
+
51
+
52
+ ## 接口返回格式
53
+ 所有接口均返回标准结构,便于前后端集成:
54
+
55
+ ```json
56
+ {
57
+ "code": 200, // 状态码,200 表示成功
58
+ "msg": "success", // 状态信息
59
+ "data": {...} // 具体数据内容
60
+ }
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 技术与环境要求
66
+ - Python 3.8 及以上
67
+ - requests
68
+ - fastmcp
69
+
@@ -0,0 +1,53 @@
1
+ # ben-music-mcp
2
+
3
+ 本产品是一套面向开发者和智能体的音乐信息服务工具,专注于高效、专业的音乐数据获取与个性化推荐。所有接口均采用标准 JSON 格式,便于自动化集成与二次开发。
4
+
5
+ ---
6
+
7
+ ## 产品功能概览
8
+
9
+ ### 歌曲与歌手信息
10
+ - **歌曲检索**:支持通过关键词精准获取歌曲详情,包括名称、艺人、专辑等核心信息。
11
+ - **歌词查询**:一键获取任意歌曲的完整歌词文本。
12
+ - **歌手检索与详情**:快速定位歌手并获取其详细资料及代表作品。
13
+ - **热门歌曲榜单**:自动获取歌手最受欢迎的曲目列表。
14
+
15
+ ### 音乐播放与评论
16
+ - **在线试听链接**:根据需求获取不同音质等级的音乐播放地址。
17
+ - **热门评论提取**:智能筛选并返回歌曲的高质量评论,便于用户快速了解口碑。
18
+ - **相似歌曲推荐**:基于音乐特征,智能推荐与目标歌曲风格相近的作品。
19
+
20
+ ### 歌单与榜单服务
21
+ - **歌单详情查询**:支持按歌单编号获取完整歌单信息,涵盖曲目、封面、创建者等。
22
+ - **排行榜检索**:覆盖主流及特色音乐榜单,助力发现最新流行趋势。
23
+ - **用户歌单获取**:根据用户昵称,自动获取其公开歌单列表。
24
+
25
+ ### 曲风与标签体系
26
+ - **曲风分类查询**:支持按风格名称获取对应曲风下的热门歌曲。
27
+ - **风格列表获取**:一键获取所有可选音乐风格,便于个性化筛选。
28
+ - **榜单名称获取**:快速获取所有可用排行榜名称,提升榜单检索效率。
29
+
30
+ ### 用户与客户端服务
31
+ - **用户身份查询**:通过昵称获取用户唯一标识,便于个性化服务。
32
+ - **本地客户端启动**:支持远程启动本地网易云音乐客户端,提升桌面体验。
33
+
34
+ ---
35
+
36
+
37
+ ## 接口返回格式
38
+ 所有接口均返回标准结构,便于前后端集成:
39
+
40
+ ```json
41
+ {
42
+ "code": 200, // 状态码,200 表示成功
43
+ "msg": "success", // 状态信息
44
+ "data": {...} // 具体数据内容
45
+ }
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 技术与环境要求
51
+ - Python 3.8 及以上
52
+ - requests
53
+ - fastmcp
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ben-music-mcp"
3
- version = "0.1.1"
3
+ version = "0.1.4"
4
4
  description = ""
5
5
  authors = [
6
6
  {name = "ben",email = "2014911413@qq.com"}
@@ -1,5 +1,7 @@
1
1
 
2
2
 
3
+
4
+
3
5
  from fastmcp import FastMCP
4
6
  from .tool import (
5
7
  _hello,
@@ -20,6 +22,8 @@ from .tool import (
20
22
  _start_netease_music,
21
23
  _get_uid,
22
24
  _get_user_playlist,
25
+ _return_stylelist,
26
+ _return_toplist_name,
23
27
  global_cookie
24
28
  )
25
29
 
@@ -28,10 +32,13 @@ mcp = FastMCP("MCPService")
28
32
 
29
33
  @mcp.tool
30
34
  def hello() -> dict:
31
- """方法注释"""
35
+ """测试使用,version=0.1.4"""
32
36
  return _hello()
33
37
 
34
38
 
39
+
40
+
41
+
35
42
  @mcp.tool
36
43
  def get_song_info(keywords: str) -> dict:
37
44
  """
@@ -41,76 +48,95 @@ def get_song_info(keywords: str) -> dict:
41
48
  """
42
49
  return _get_song_info(keywords)
43
50
 
51
+ # @mcp.tool
52
+ # def get_song_id(keywords: str) -> dict:
53
+ # """
54
+ # 根据关键词搜索歌曲,返回第一首歌的ID
55
+ # :param keywords: 歌曲关键词
56
+ # :return: 歌曲ID
57
+ # """
58
+ # return _get_song_id(keywords)
44
59
 
45
60
  @mcp.tool
46
- def get_song_id(keywords: str) -> dict:
61
+ def lyric(keywords: str) -> dict:
47
62
  """
48
- 根据关键词搜索歌曲,返回第一首歌的ID
63
+ 根据歌名关键词搜索歌词
49
64
  :param keywords: 歌曲关键词
50
- :return: 歌曲ID
65
+ :return: 歌词文本
51
66
  """
52
- return _get_song_id(keywords)
67
+ return _lyric(keywords)
53
68
 
69
+ @mcp.tool
70
+ def get_music_url(keywords: str, level: str = "standard") -> dict:
71
+ """
72
+ 根据关键词获取音乐在线试听url
73
+ :param keywords: 歌曲关键词
74
+ :param level: 音质等级
75
+ :return: 音乐url json
76
+ """
77
+ return _get_music_url(keywords, level)
54
78
 
55
79
  @mcp.tool
56
- def lyric(keywords: str) -> dict:
80
+ def get_song_comment(keywords: str) -> dict:
57
81
  """
58
- 根据歌名关键词搜索歌词(内部先获取歌曲ID)
82
+ 根据歌名关键词获取歌曲评论
59
83
  :param keywords: 歌曲关键词
60
- :return: 歌词文本
84
+ :return: 歌曲评论json
61
85
  """
62
- return _lyric(keywords)
86
+ return _get_song_comment(keywords)
87
+
88
+ @mcp.tool
89
+ def get_similar_songs(keywords: str) -> dict:
90
+ """
91
+ 根据关键词获取相似音乐(先查id再查/simi/song)
92
+ :param keywords: 歌曲关键词
93
+ :return: 相似音乐json
94
+ """
95
+ return _get_similar_songs(keywords)
96
+
97
+ @mcp.tool
98
+ def get_style_songs(style_name: str) -> dict:
99
+ """
100
+ 根据曲风名返回歌曲列表。
101
+ :param style_name: 曲风名
102
+ :return: 歌曲列表json
103
+ """
104
+ return _get_style_songs(style_name)
105
+
106
+
107
+
63
108
 
64
109
 
65
110
  @mcp.tool
66
111
  def search_artist(keyword: str) -> dict:
67
112
  """
68
- 根据关键词搜索歌手信息,自动带上cookie
113
+ 根据关键词搜索歌手信息
69
114
  :param keyword: 歌手关键词
70
115
  :return: 歌手信息字符串
71
116
  """
72
117
  return _search_artist(keyword)
73
118
 
74
-
75
119
  @mcp.tool
76
120
  def get_artist_info(keyword: str) -> dict:
77
121
  """
78
- 根据关键词获取歌手详细信息,先查id再查详情,返回json
122
+ 根据关键词获取歌手详细信息
79
123
  :param keyword: 歌手关键词
80
124
  :return: 歌手详细信息json
81
125
  """
82
126
  return _get_artist_info(keyword)
83
127
 
84
-
85
128
  @mcp.tool
86
129
  def get_artist_hot_songs(keyword: str) -> dict:
87
130
  """
88
- 根据关键词获取歌手最火的50首歌曲,先查id再查热门歌曲,返回json
131
+ 根据关键词获取歌手最火的50首歌曲
89
132
  :param keyword: 歌手关键词
90
133
  :return: 热门歌曲json
91
134
  """
92
135
  return _get_artist_hot_songs(keyword)
93
136
 
94
137
 
95
- @mcp.tool
96
- def get_music_url(keywords: str, level: str = "standard") -> dict:
97
- """
98
- 根据关键词获取音乐播放url,先查歌曲id再查url,返回json
99
- :param keywords: 歌曲关键词
100
- :param level: 音质等级
101
- :return: 音乐url json
102
- """
103
- return _get_music_url(keywords, level)
104
138
 
105
139
 
106
- @mcp.tool
107
- def get_song_comment(keywords: str) -> dict:
108
- """
109
- 根据关键词获取歌曲评论,先查歌曲id再查评论,返回json
110
- :param keywords: 歌曲关键词
111
- :return: 歌曲评论json
112
- """
113
- return _get_song_comment(keywords)
114
140
 
115
141
  @mcp.tool
116
142
  def get_playlist(id: int) -> dict:
@@ -124,44 +150,29 @@ def get_playlist(id: int) -> dict:
124
150
  @mcp.tool
125
151
  def get_toplist(name: str) -> dict:
126
152
  """
127
- 根据排行榜名获取榜单详情(先查id再查_get_playlist)
153
+ 根据排行榜名字获取榜单详情(先查id再查_get_playlist)
128
154
  :param name: 榜单名称
129
155
  :return: 榜单详情json
130
156
  """
131
157
  return _get_toplist(name)
132
158
 
133
- @mcp.tool
134
- def get_similar_songs(keywords: str) -> dict:
135
- """
136
- 根据关键词获取相似音乐(先查id再查/simi/song)
137
- :param keywords: 歌曲关键词
138
- :return: 相似音乐json
139
- """
140
- return _get_similar_songs(keywords)
141
159
 
142
- @mcp.tool
143
- def get_style_songs(style_name: str) -> dict:
144
- """
145
- 根据曲风名返回歌曲列表。
146
- :param style_name: 曲风名
147
- :return: 歌曲列表json
148
- """
149
- return _get_style_songs(style_name)
150
160
 
151
161
 
152
- @mcp.tool()
153
- def get_uid(nickname: str) -> dict:
154
- """
155
- 根据用户昵称获取其uid
156
- :param nickname: 用户昵称
157
- :return: 用户uid json
158
- """
159
- return _get_uid(nickname)
162
+
163
+ # @mcp.tool()
164
+ # def get_uid(nickname: str) -> dict:
165
+ # """
166
+ # 根据用户昵称获取其uid
167
+ # :param nickname: 用户昵称
168
+ # :return: 用户uid json
169
+ # """
170
+ # return _get_uid(nickname)
160
171
 
161
172
  @mcp.tool()
162
173
  def get_user_playlist(nickname: str) -> dict:
163
174
  """
164
- 输入用户昵称,获取用户歌单(只保留必要字段)
175
+ 输入用户昵称,获取用户歌单(含有歌单id)
165
176
  :param nickname: 用户昵称
166
177
  :return: 歌单列表json
167
178
  """
@@ -172,20 +183,38 @@ def get_user_playlist(nickname: str) -> dict:
172
183
 
173
184
 
174
185
  @mcp.tool
175
- def login_anonymous() -> dict:
186
+ def return_stylelist() -> dict:
176
187
  """
177
- 游客登录,获取游客 cookie,并保存到全局变量
178
- :return: 游客 cookie 字符串
188
+ 返回所有风格名称(不含id),从styleList.json读取。没有输入参数
189
+ :return: {"code": 200, "msg": "success", "data": [风格名列表]}
179
190
  """
180
- return _login_anonymous()
191
+ return _return_stylelist()
181
192
 
182
193
  @mcp.tool
183
- def login_refresh() -> dict:
194
+ def return_toplist_name() -> dict:
184
195
  """
185
- 刷新登录状态,获取新的 cookie
186
- :return: 新的 cookie 字符串
196
+ 返回所有排行榜名称(不含id),从toplist.json读取。没有输入参数
197
+ :return: {"code": 200, "msg": "success", "data": [榜单名列表]}
187
198
  """
188
- return _login_refresh()
199
+ return _return_toplist_name()
200
+
201
+
202
+
203
+ # @mcp.tool
204
+ # def login_anonymous() -> dict:
205
+ # """
206
+ # 游客登录,获取游客 cookie,并保存到全局变量
207
+ # :return: 游客 cookie 字符串
208
+ # """
209
+ # return _login_anonymous()
210
+
211
+ # @mcp.tool
212
+ # def login_refresh() -> dict:
213
+ # """
214
+ # 刷新登录状态,获取新的 cookie
215
+ # :return: 新的 cookie 字符串
216
+ # """
217
+ # return _login_refresh()
189
218
 
190
219
 
191
220
  @mcp.tool()
@@ -1,5 +1,4 @@
1
1
 
2
-
3
2
  import subprocess
4
3
  import requests
5
4
 
@@ -287,7 +286,8 @@ def _get_toplist(name: str) -> dict:
287
286
  :return: 榜单详情json
288
287
  """
289
288
  try:
290
- with open("toplist.json", "r", encoding="utf-8") as f:
289
+ path = os.path.join(os.path.dirname(__file__), "toplist.json")
290
+ with open(path, "r", encoding="utf-8") as f:
291
291
  data = json.load(f)
292
292
  toplists = data.get("toplists", [])
293
293
  match = next((item for item in toplists if item.get("name") == name), None)
@@ -337,7 +337,8 @@ def _get_style_songs(style_name: str) -> dict:
337
337
 
338
338
  # 读取 styleList.json
339
339
  try:
340
- with open("styleList.json", "r", encoding="utf-8") as f:
340
+ path = os.path.join(os.path.dirname(__file__), "styleList.json")
341
+ with open(path, "r", encoding="utf-8") as f:
341
342
  style_list = json.load(f)
342
343
  except Exception as e:
343
344
  return {"code": 500, "msg": f"读取曲风列表失败: {e}", "data": {}}
@@ -450,6 +451,36 @@ def _get_user_playlist(nickname: str) -> dict:
450
451
  return {"code": 500, "msg": f"请求失败: {e}", "data": []}
451
452
 
452
453
 
454
+ def _return_stylelist() -> dict:
455
+ """
456
+ 返回所有风格名称(不含id),从styleList.json读取。
457
+ :return: {"code": 200, "msg": "success", "data": [风格名列表]}
458
+ """
459
+ try:
460
+ path = os.path.join(os.path.dirname(__file__), "styleList.json")
461
+ with open(path, "r", encoding="utf-8") as f:
462
+ style_list = json.load(f)
463
+ names = [item.get("tagName", "") for item in style_list if item.get("tagName")]
464
+ return {"code": 200, "msg": "success", "data": names}
465
+ except Exception as e:
466
+ return {"code": 500, "msg": f"读取风格列表失败: {e}", "data": []}
467
+
468
+
469
+ def _return_toplist_name() -> dict:
470
+ """
471
+ 返回所有排行榜名称(不含id),从toplist.json读取。
472
+ :return: {"code": 200, "msg": "success", "data": [榜单名列表]}
473
+ """
474
+ try:
475
+ path = os.path.join(os.path.dirname(__file__), "toplist.json")
476
+ with open(path, "r", encoding="utf-8") as f:
477
+ data = json.load(f)
478
+ toplists = data.get("toplists", [])
479
+ names = [item.get("name", "") for item in toplists if item.get("name")]
480
+ return {"code": 200, "msg": "success", "data": names}
481
+ except Exception as e:
482
+ return {"code": 500, "msg": f"读取榜单列表失败: {e}", "data": []}
483
+
453
484
 
454
485
 
455
486
  def _login_anonymous() -> dict:
@@ -1,99 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ben-music-mcp
3
- Version: 0.1.1
4
- Summary:
5
- Author: ben
6
- Author-email: 2014911413@qq.com
7
- Requires-Python: >=3.12
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.12
10
- Classifier: Programming Language :: Python :: 3.13
11
- Classifier: Programming Language :: Python :: 3.14
12
- Requires-Dist: fastmcp (>=2.13.0.2)
13
- Requires-Dist: requests (>=2.32.4)
14
- Description-Content-Type: text/markdown
15
-
16
- # API 工具说明
17
-
18
- 本项目基于 FastMCP,封装了音乐相关常用接口,所有方法均以 JSON 格式返回,适合自动化调用和二次开发。
19
-
20
- ## 方法列表
21
-
22
- ### 1. hello
23
- 测试方法,返回示例字符串。
24
-
25
- ### 2. get_song_info(keywords)
26
- 根据关键词搜索歌曲信息,返回首条歌曲的详细信息(id、name、artists、album、alias、transNames、duration、fee、mvid)。
27
-
28
- ### 3. get_song_id(keywords)
29
- 根据关键词搜索歌曲,返回第一首歌的ID。
30
-
31
- ### 4. lyric(keywords)
32
- 根据歌名关键词搜索歌词(内部先获取歌曲ID),返回歌词文本。
33
-
34
- ### 5. search_artist(keyword)
35
- 根据关键词搜索歌手信息,自动带上 cookie,返回首个歌手的基本信息(artistName、artistId、avatar)。
36
-
37
- ### 6. get_artist_info(keyword)
38
- 根据关键词获取歌手详细信息,先查 id 再查详情,返回完整歌手信息。
39
-
40
- ### 7. get_artist_hot_songs(keyword)
41
- 根据关键词获取歌手最火的 50 首歌曲,先查 id 再查热门歌曲。
42
-
43
- ### 8. get_music_url(keywords, level="standard")
44
- 根据关键词获取音乐播放 url,先查歌曲 id 再查 url,支持音质等级选择。
45
-
46
- ### 9. get_song_comment(keywords)
47
- 根据关键词获取歌曲评论,先查歌曲 id 再查评论,只保留有用字段(nickname、content、likedCount、timeStr)。
48
-
49
- ### 10. get_playlist(id)
50
- 根据歌单 id 获取歌单详情,只返回关键字段(id、name、coverImgUrl、userId、trackCount、playCount、tracks 等)。
51
-
52
- ### 11. get_toplist(name)
53
- 根据排行榜名获取榜单详情(先查 id 再查 get_playlist)。
54
-
55
- ### 12. get_similar_songs(keywords)
56
- 根据关键词获取相似音乐(先查 id 再查 /simi/song),只保留关键信息。
57
-
58
- ### 13. get_style_songs(style_name)
59
- 根据曲风名返回歌曲列表(先查曲风 id,再查 /style/song),只保留关键信息(id、name、artists、album、duration)。
60
-
61
- ### 14. get_uid(nickname)
62
- 根据用户昵称获取其 uid,返回 uid 和昵称。
63
-
64
- ### 15. get_user_playlist(nickname)
65
- 输入用户昵称,获取用户歌单(先查 uid,再查 /user/playlist),只保留必要字段(id、name、coverImgUrl、trackCount、playCount、creator 信息)。
66
-
67
- ### 16. login_anonymous()
68
- 游客登录,获取游客 cookie,并保存到全局变量。
69
-
70
- ### 17. login_refresh()
71
- 刷新登录状态,获取新的 cookie。
72
-
73
- ### 18. start_netease_music(exe_path="C:\\CloudMusic\\cloudmusic.exe")
74
- 启动本地网易云音乐客户端,支持自定义 exe 路径。
75
-
76
- ## 返回格式
77
- 所有方法均返回如下结构:
78
-
79
- ```json
80
- {
81
- "code": 200, // 状态码,200 表示成功
82
- "msg": "success", // 状态信息
83
- "data": {...} // 具体数据内容
84
- }
85
- ```
86
-
87
- ## 使用说明
88
- 1. 推荐通过 MCP 工具接口调用各方法。
89
- 2. 部分方法(如评论、歌单、曲风)已做字段精简,适合前端展示和二次处理。
90
- 3. 启动本地网易云客户端需 Windows 环境,默认路径可自定义。
91
-
92
- ## 依赖
93
- - Python 3.8+
94
- - requests
95
- - fastmcp
96
-
97
- ## 维护
98
- 如需扩展新接口或字段,请参考 tool.py 和 server.py 的实现风格。
99
-
@@ -1,83 +0,0 @@
1
- # API 工具说明
2
-
3
- 本项目基于 FastMCP,封装了音乐相关常用接口,所有方法均以 JSON 格式返回,适合自动化调用和二次开发。
4
-
5
- ## 方法列表
6
-
7
- ### 1. hello
8
- 测试方法,返回示例字符串。
9
-
10
- ### 2. get_song_info(keywords)
11
- 根据关键词搜索歌曲信息,返回首条歌曲的详细信息(id、name、artists、album、alias、transNames、duration、fee、mvid)。
12
-
13
- ### 3. get_song_id(keywords)
14
- 根据关键词搜索歌曲,返回第一首歌的ID。
15
-
16
- ### 4. lyric(keywords)
17
- 根据歌名关键词搜索歌词(内部先获取歌曲ID),返回歌词文本。
18
-
19
- ### 5. search_artist(keyword)
20
- 根据关键词搜索歌手信息,自动带上 cookie,返回首个歌手的基本信息(artistName、artistId、avatar)。
21
-
22
- ### 6. get_artist_info(keyword)
23
- 根据关键词获取歌手详细信息,先查 id 再查详情,返回完整歌手信息。
24
-
25
- ### 7. get_artist_hot_songs(keyword)
26
- 根据关键词获取歌手最火的 50 首歌曲,先查 id 再查热门歌曲。
27
-
28
- ### 8. get_music_url(keywords, level="standard")
29
- 根据关键词获取音乐播放 url,先查歌曲 id 再查 url,支持音质等级选择。
30
-
31
- ### 9. get_song_comment(keywords)
32
- 根据关键词获取歌曲评论,先查歌曲 id 再查评论,只保留有用字段(nickname、content、likedCount、timeStr)。
33
-
34
- ### 10. get_playlist(id)
35
- 根据歌单 id 获取歌单详情,只返回关键字段(id、name、coverImgUrl、userId、trackCount、playCount、tracks 等)。
36
-
37
- ### 11. get_toplist(name)
38
- 根据排行榜名获取榜单详情(先查 id 再查 get_playlist)。
39
-
40
- ### 12. get_similar_songs(keywords)
41
- 根据关键词获取相似音乐(先查 id 再查 /simi/song),只保留关键信息。
42
-
43
- ### 13. get_style_songs(style_name)
44
- 根据曲风名返回歌曲列表(先查曲风 id,再查 /style/song),只保留关键信息(id、name、artists、album、duration)。
45
-
46
- ### 14. get_uid(nickname)
47
- 根据用户昵称获取其 uid,返回 uid 和昵称。
48
-
49
- ### 15. get_user_playlist(nickname)
50
- 输入用户昵称,获取用户歌单(先查 uid,再查 /user/playlist),只保留必要字段(id、name、coverImgUrl、trackCount、playCount、creator 信息)。
51
-
52
- ### 16. login_anonymous()
53
- 游客登录,获取游客 cookie,并保存到全局变量。
54
-
55
- ### 17. login_refresh()
56
- 刷新登录状态,获取新的 cookie。
57
-
58
- ### 18. start_netease_music(exe_path="C:\\CloudMusic\\cloudmusic.exe")
59
- 启动本地网易云音乐客户端,支持自定义 exe 路径。
60
-
61
- ## 返回格式
62
- 所有方法均返回如下结构:
63
-
64
- ```json
65
- {
66
- "code": 200, // 状态码,200 表示成功
67
- "msg": "success", // 状态信息
68
- "data": {...} // 具体数据内容
69
- }
70
- ```
71
-
72
- ## 使用说明
73
- 1. 推荐通过 MCP 工具接口调用各方法。
74
- 2. 部分方法(如评论、歌单、曲风)已做字段精简,适合前端展示和二次处理。
75
- 3. 启动本地网易云客户端需 Windows 环境,默认路径可自定义。
76
-
77
- ## 依赖
78
- - Python 3.8+
79
- - requests
80
- - fastmcp
81
-
82
- ## 维护
83
- 如需扩展新接口或字段,请参考 tool.py 和 server.py 的实现风格。