Metadata-Version: 2.4
Name: play-music-mcp
Version: 0.1.1
Summary: Local music playback MCP server powered by pygame and FastMCP.
Author: MCP Contributors
License: MIT License
        
        Copyright (c) 2024 MCP Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/yourname/play-music-mcp
Project-URL: Source, https://github.com/yourname/play-music-mcp
Project-URL: Issues, https://github.com/yourname/play-music-mcp/issues
Keywords: mcp,music,pygame,automation,agent
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastmcp>=0.3.0
Requires-Dist: pygame>=2.5.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: oauthlib>=3.2.2
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Dynamic: license-file

# play-music-mcp

一个基于 [FastMCP](https://github.com/modelcontextprotocol/fastmcp) 和 `pygame` 的本地音乐播放 Model Context Protocol (MCP) 服务器。通过 MCP 工具可以管理播放列表、播放/暂停/上一首/下一首等控制动作，并提供音乐文件维护工具，适合在 Copilot / Claude Desktop 等遵循 MCP 标准的客户端中使用。

## 功能特性
- 异步 MCP 工具：播放、暂停、恢复、停止、上一首、下一首、查看播放列表、列出本地音乐文件等。
- 后台播放线程：使用 `pygame.mixer` 长时间保持播放状态，支持单曲循环、列表循环、随机播放三种模式。
- 自动扫描 `music_file/` 目录，将匹配到的音频文件加载到播放列表。
- 标准输出 (STDIO) 传输：与大多数 MCP 客户端兼容，部署简单。

## 安装
```bash
pip install play-music-mcp
```
或在本地源码目录下构建并安装：
```bash
cd 音乐
python -m build
pip install dist/play_music_mcp-*.whl
```

## 运行方式
包中提供了一个 `play-music-mcp` 控制台脚本，或直接运行模块：
```bash
play-music-mcp --music-dir /absolute/path/to/music_dir
# 等价于
python -m play_music --music-dir /absolute/path/to/music_dir
```
通过 `--music-dir` 参数指定存放 `.mp3/.wav` 等文件的目录；若未提供，则默认使用当前工作目录下的 `music_file/`。服务器启动后会在 STDIO 上传输 MCP 消息，可直接由支持 MCP 的客户端托管。

## MCP 工具列表
| 工具名 | 说明 |
| --- | --- |
| `play_musics_local` | 扫描 `music_file/` 并按设定模式播放（single/list/random）。 |
| `pause_music` / `unpause_music` | 暂停或恢复当前曲目。 |
| `stop_music` | 停止播放并重置内部状态。 |
| `next_song` / `previous_song` | 在当前播放列表内切歌。 |
| `get_playlist` | 返回当前播放列表及正在播放的歌曲。 |
| `list_music_files` | 新增工具，列出目录下可用的音频文件，便于先行确认。 |

## 开发说明
1. 确保本地已安装 `SDL`/`pygame` 所需的系统依赖。
2. 在 `music_file/` 文件夹中放置 `.mp3/.wav/.ogg` 文件。
3. 运行 `play-music-mcp`，并在 MCP 客户端侧配置好服务器（STDIO 传输无需额外参数）。
4. 若要发布到 PyPI：
   - 更新 `pyproject.toml` 中的版本号与项目信息。
   - 运行 `python -m build` 生成分发包。
   - 使用 `twine upload dist/*` 上传。

## 许可证
本项目使用 MIT License，详见 `LICENSE` 文件。
