VLC MCP 服务器是一个借助 VLC 媒体播放器来实现电影播放与控制的 Model Context Protocol (MCP) 服务器。借助任意 MCP 客户端(例如 awesome-mcp-clients),就能远程操控视频播放。
我使用运行在旧笔记本电脑上的 signal-mcp-client 连接到投影仪,这样只需发送一条信号消息就能播放电影。以下是使用方法示例:
此安装适用于运行 Ubuntu 或类似基于 Debian 系统的 Linux 系统(例如 Raspberry Pi OS)。经过适当修改,它也应在其他系统上运行。如果成功在其他系统上运行,请随时提交拉取请求。
安装 VLC、mediainfo 和 uv:
sudo apt-get install vlc mediainfo
curl -LsSf https://astral.sh/uv/install.sh | sh
启动 VLC HTTP 服务器:
export DISPLAY=:0 # 在远程服务器上运行时需要设置此变量
vlc --extraintf=http --http-host=localhost --http-port=8081 --http-password=your_password
配置 MCP 客户端以与 VLC HTTP 接口通信。例如,在 config.json
中添加以下内容:
{
"vlc": {
"host": "localhost",
"port": 8081,
"password": "your_password"
}
}
使用 MCP 客户端控制 VLC 播放器。例如,发送以下命令来播放媒体:
mcpctl send vlc.play "media_url"
# 安装依赖
sudo apt-get install vlc mediainfo
curl -LsSf https://astral.sh/uv/install.sh | sh
# 启动 VLC HTTP 服务器
export DISPLAY=:0
vlc --extraintf=http --http-host=localhost --http-port=8081 --http-password=your_password
# 配置 MCP 客户端
{
"vlc": {
"host": "localhost",
"port": 8081,
"password": "your_password"
}
}
# 播放媒体
mcpctl send vlc.play "media_url"
# 若要在系统启动时自动运行 VLC HTTP 服务器,可配置 systemd 服务
cat << EOF > "/home/$USER/.config/systemd/user/vlc-http.service"
[Unit]
Description=VLC Media Player with HTTP Interface
After=network.target sound.target
[Service]
Restart=on-failure
RestartSec=30
SyslogIdentifier=vlc-http
Environment="DISPLAY=:0"
ExecStart=/usr/bin/vlc --extraintf=http --http-host=localhost --http-port=8081 --http-password=your_password
ExecStop=/usr/bin/pkill -f '/usr/bin/vlc --extraintf=http --http-host=localhost --http-port=8081'
[Install]
WantedBy=default.target
EOF
# 启用并启动服务
systemctl --user daemon-reload
systemctl --user enable vlc-http.service
systemctl --user start vlc-http.service
# 检查服务状态和日志
systemctl --user status vlc-http.service
journalctl --user -u vlc-http.service -f
欢迎任何贡献!如果您发现任何问题,请在 GitHub 上提交问题或拉取请求。
格式化代码:
使用 black
来格式化 Python 代码:
black .
构建文档:
使用 sphinx-build
生成文档:
sphinx-build docs/ docs/_build/
测试: 运行单元测试以确保功能正常。
此项目在 MIT 许可证下开源。有关详细信息,请参阅 LICENSE 文件。