返回市场
扫描上下文

扫描上下文

作者:tfmart2 星标更新:2025-06-05

项目介绍

ScrobblerContext - Last.fm MCP 服务器

npm 版本 Swift 6.0+ License: MIT MCP

这是一个提供访问 Last.fm 音乐数据库的 Model Context Protocol (MCP) 服务器。用 Swift 编写,它使 AI 助手能够搜索音乐、管理用户库以及提交播放记录。

目录

特性

  • 认证:安全的浏览器 OAuth 流程,具有会话持久性
  • 艺术家操作:搜索艺术家,获取详细信息,查找相似艺术家
  • 专辑操作:搜索专辑,获取曲目列表和元数据
  • 曲目操作:搜索曲目,获取详细信息和推荐
  • 用户数据:访问收听历史、统计数据和社会功能
  • 提交播放记录:提交曲目播放,更新当前播放状态,喜爱或取消喜爱曲目

快速开始

通过 npm 安装(推荐)

# 全局安装
npm install -g scrobblercontext-mcp

# 设置你的 Last.fm API 凭证
export LASTFM_API_KEY="your_api_key_here"
export LASTFM_SECRET_KEY="your_secret_key_here"

# 运行服务器
scrobblercontext-mcp

获取 Last.fm API 凭证

  1. 访问 Last.fm API 账户创建
  2. 填写应用详情:
    • 应用名称:你的应用名称(例如,“我的 MCP 服务器”)
    • 应用描述:简要描述
    • 应用主页 URL:你的网站(可以是 GitHub 仓库)
    • 回调 URLhttp://localhost:8080/callback(用于 OAuth)
  3. 保存你的 API 密钥共享密钥

与 MCP 客户端设置

Claude Desktop

添加到你的 claude_desktop_config.json

{
  "mcpServers": {
    "lastfm": {
      "command": "scrobblercontext-mcp",
      "env": {
        "LASTFM_API_KEY": "your_api_key_here",
        "LASTFM_SECRET_KEY": "your_secret_key_here"
      }
    }
  }
}

配置文件位置:

  • macOS~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%/Claude/claude_desktop_config.json

Cursor

添加到你的 MCP 设置:

{
  "mcpServers": {
    "lastfm": {
      "command": "scrobblercontext-mcp",
      "env": {
        "LASTFM_API_KEY": "your_api_key_here", 
        "LASTFM_SECRET_KEY": "your_secret_key_here"
      }
    }
  }
}

其他 MCP 客户端

该服务器通过 stdio 按照 Model Context Protocol 标准进行通信。配置你的客户端以:

  1. 执行 scrobblercontext-mcp 作为服务器命令
  2. 设置所需的环境变量
  3. 使用 stdio 传输

使用示例

与 Last.fm 认证:

用户: "与 Last.fm 认证"
助手: [使用 authenticate_browser 工具启动 OAuth 流程]

搜索音乐:

用户: "找到与 Radiohead 类似的艺术家"
助手: [使用 get_similar_artists 工具查找推荐]

提交播放记录:

用户: "提交 '波西米亚狂想曲' 由皇后乐队"
助手: [使用 scrobble_track 工具提交到你的个人资料]

手动安装

前提条件:

  • Swift 6.0+ (下载)
  • macOS 13.0+ 或支持 Swift 的 Linux
  • Last.fm API 凭证

从源代码构建:

git clone https://github.com/tfmart/ScrobblerContext
cd ScrobblerContext
swift build
export LASTFM_API_KEY="your_api_key_here"
export LASTFM_SECRET_KEY="your_secret_key_here"
swift run ScrobblerContext

可用工具

<details> <summary><strong>认证工具 (5)</strong></summary>
  • authenticate_browser - 在浏览器中启动 OAuth 流程
  • set_session_key - 设置现有会话密钥
  • check_auth_status - 检查认证状态
  • restore_session - 恢复保存的会话
  • logout - 清除认证
</details> <details> <summary><strong>艺术家工具 (9)</strong></summary>
  • search_artist - 搜索艺术家
  • get_artist_info - 获取艺术家详情及传记
  • get_similar_artists - 查找相似艺术家
  • get_artist_correction - 获取纠正后的艺术家名称
  • get_artist_tags - 获取艺术家标签
  • get_artist_top_albums - 获取艺术家的热门专辑
  • get_artist_top_tracks - 获取艺术家的热门曲目
  • add_artist_tags - 添加个人标签(需要认证)
  • remove_artist_tag - 移除个人标签(需要认证)
</details> <details> <summary><strong>专辑工具 (6)</strong></summary>
  • search_album - 搜索专辑
  • get_album_info - 获取专辑详情及曲目列表 -_ get_album_tags - 获取专辑标签
  • get_album_top_tags - 获取热门专辑标签
  • add_album_tags - 添加个人标签(需要认证)
  • remove_album_tag - 移除个人标签(需要认证)
</details> <details> <summary><strong>曲目工具 (8)</strong></summary>
  • search_track - 搜索曲目
  • get_track_info - 获取曲目详情
  • get_similar_tracks - 查找相似曲目
  • get_track_correction - 获取纠正后的曲目信息
  • get_track_tags - 获取曲目标签
  • get_track_top_tags - 获取热门曲目标签
  • add_track_tags - 添加个人标签(需要认证)
  • remove_track_tag - 移除个人标签(需要认证)
</details> <details> <summary><strong>用户工具 (9)</strong></summary>
  • get_user_info - 获取用户资料及统计数据
  • get_user_recent_tracks - 获取最近的收听历史
  • get_user_top_artists - 获取按时间段划分的顶级艺术家
  • get_user_top_tracks - 获取按时间段划分的顶级曲目
  • get_user_top_albums - 获取按时间段划分的顶级专辑
  • get_user_top_tags - 获取最常用的标签
  • get_user_friends - 获取好友列表
  • get_user_loved_tracks - 获取喜爱的曲目
  • get_user_personal_tags_for_artists - 获取标记的艺术家
</details> <details> <summary><strong>提交播放记录工具 (5)</strong></summary>
  • scrobble_track - 提交单个曲目播放
  • scrobble_multiple_tracks - 提交多个播放
  • update_now_playing - 更新当前播放状态
  • love_track - 将曲目标记为喜爱
  • unlove_track - 从喜爱的曲目中移除
</details>

贡献

欢迎贡献!请参阅 CONTRIBUTING.md 了解指南。

文档

故障排除

未找到 Swift:从 swift.org 安装 Swift

无效的会话密钥:重新运行认证 authenticate_browser

API 键错误:验证你的 LASTFM_API_KEYLASTFM_SECRET_KEY 是否正确

服务器断开连接:检查 MCP 客户端配置中的环境变量是否已设置

许可证

MIT 许可证 - 详情见 LICENSE 文件。

致谢