Unsplash MCP Server

Unsplash MCP Server

这是一个基于hellokaton/unsplash-mcp-server的Swift实现,并添加了get_photo和random_photo等功能。

一个提供 Unsplash 照片搜索和检索功能的模型上下文协议服务器,让 LLMs 能够访问 Unsplash 的海量照片库。

🚀 安装

方法 1: 单行安装

curl -fsSL https://raw.githubusercontent.com/okooo5km/unsplash-mcp-server-swift/main/install.sh | bash

方法 2: 从源代码构建

git clone https://github.com/okooo5km/unsplash-mcp-server-swift.git
cd unsplash-mcp-server-swift
swift build -c release
mkdir -p ~/.local/bin
cp $(swift build -c release --show-bin-path)/unsplash-mcp-server ~/.local/bin/
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc  # 或 ~/.bashrc
source ~/.zshrc  # 或 ~/.bashrc

⚙️ 配置

1. 获取 Unsplash API 密钥

  1. 前往 Unsplash 开发者门户
  2. 注册/登录并创建新应用
  3. 完成注册后获取访问密钥

2. 设置环境变量

export UNSPLASH_ACCESS_KEY="your-access-key-here"

3. 客户端配置

Claude.app:

"mcpServers": {
  "unsplash": {
    "command": "unsplash-mcp-server"
  }
}

Cursor:

{
  "mcpServers": {
    "unsplash": {
      "command": "unsplash-mcp-server",
      "env": {
        "UNSPLASH_ACCESS_KEY": "${YOUR_ACCESS_KEY}"
      }
    }
  }
}

Chatwise:

  • 添加环境变量时,不要用引号包裹值

🛠️ 可用工具

search_photos

搜索 Unsplash 照片

参数:
- query (字符串, 必需): 搜索关键词
- page (数字, 可选): 页码, 默认: 1
- perPage (数字, 可选): 每页结果数 (1-30), 默认: 10
- orderBy (字符串, 可选): 排序方法 (relevant/latest), 默认: "relevant"
- color (字符串, 可选): 颜色过滤
- orientation (字符串, 可选): 方向过滤 (landscape/portrait/squarish)

get_photo

获取特定照片的详细信息

参数:
- photoId (字符串, 必需): 要检索的照片ID

random_photo

获取随机照片

参数:
- count (数字, 可选): 返回的照片数量 (默认: 1; 最大: 30)
- collections, topics, username, query, orientation, content_filter, featured (可选)

系统要求

  • Swift 6.0+
  • macOS 14.0+
  • MCP Swift SDK 0.2.0+

Buy me a coffee