Pexels MCP Server
# Pexels MCP Server
基于 [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 的 Pexels API 服务器,允许 AI 助手通过工具调用访问 Pexels 的免费高质量图片库。
## 功能特性
- 🔍 **搜索照片** - 根据关键词搜索 Pexels 上的免费照片
- 🎨 **获取精选照片** - 获取 Pexels 团队精选的高质量照片
- 📸 **照片详情** - 获取特定照片的详细信息
- 🔧 **丰富的过滤选项** - 支持按方向、尺寸、颜色等过滤搜索结果
- ⚡ **高性能** - 基于 TypeScript 和现代 Node.js 构建
## 安装
### 前置要求
- Node.js 18 或更高版本
- Pexels API 密钥(免费获取:[Pexels API](https://www.pexels.com/api/))
### 1. 克隆项目
```bash
git clone https://github.com/your-username/pexels-mcp.git
cd pexels-mcp
```
### 2. 安装依赖
```bash
npm install
```
### 3. 设置环境变量
创建 `.env` 文件:
```bash
PEXELS_API_KEY=your_pexels_api_key_here
```
或者直接导出环境变量:
```bash
export PEXELS_API_KEY=your_pexels_api_key_here
```
### 4. 构建项目
```bash
npm run build
```
## 配置
### Claude Desktop
在你的 Claude Desktop 配置文件中添加 MCP 服务器:
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`
```json
{
"mcpServers": {
"pexels": {
"command": "node",
"args": ["/path/to/pexels-mcp/dist/index.js"],
"env": {
"PEXELS_API_KEY": "your_pexels_api_key_here"
}
}
}
}
```
### 其他 MCP 客户端
对于其他 MCP 客户端,使用以下命令运行服务器:
```bash
PEXELS_API_KEY=your_api_key node dist/index.js
```
## 可用工具
### 1. search_photos
根据关键词搜索照片。
**参数:**
- `query` (必需): 搜索关键词
- `per_page` (可选): 每页结果数量 (1-80, 默认: 15)
- `page` (可选): 页码 (默认: 1)
- `orientation` (可选): 照片方向 (`landscape`, `portrait`, `square`)
- `size` (可选): 最小尺寸 (`large`, `medium`, `small`)
- `color` (可选): 主要颜色过滤 (`red`, `orange`, `yellow`, `green`, `turquoise`, `blue`, `violet`, `pink`, `brown`, `black`, `gray`, `white`)
**示例:**
```json
{
\"query\": \"mountain landscape\",
\"per_page\": 10,
\"orientation\": \"landscape\",
\"color\": \"blue\"
}
```
### 2. get_curated_photos
获取 Pexels 团队精选的高质量照片。
**参数:**
- `per_page` (可选): 每页结果数量 (1-80, 默认: 15)
- `page` (可选): 页码 (默认: 1)
**示例:**
```json
{
\"per_page\": 20,
\"page\": 1
}
```
### 3. get_photo_details
获取特定照片的详细信息。
**参数:**
- `id` (必需): 照片 ID
**示例:**
```json
{
\"id\": 1234567
}
```
## 使用示例
### 在 Claude Desktop 中使用
安装配置完成后,你可以直接与 Claude 对话:
```
用户:帮我找一些关于海滩日落的照片
Claude:我来为您搜索海滩日落的照片...
```
```
用户:给我看一些 Pexels 上的精选照片
Claude:让我为您获取一些精选照片...
```
### API 响应示例
照片数据包含以下信息:
- 照片基本信息(ID、尺寸、URL)
- 摄影师信息
- 多种尺寸的图片链接
- 平均颜色
- ALT 文本
## 开发
### 启动开发服务器
```bash
npm run dev
```
### 运行测试
```bash
npm test
```
### 构建生产版本
```bash
npm run build
```
## API 限制
Pexels API 有以下限制:
- **免费账户**: 每小时 200 次请求,每月 20,000 次请求
- 所有照片都是免费使用的,但建议标注来源
## 许可协议
本项目采用 MIT 许可协议 - 详情请查看 [LICENSE](LICENSE) 文件。
## 贡献
欢迎提交 Pull Request 和 Issue!
1. Fork 本项目
2. 创建特性分支 (`git checkout -b feature/amazing-feature`)
3. 提交更改 (`git commit -m 'Add some amazing feature'`)
4. 推送到分支 (`git push origin feature/amazing-feature`)
5. 打开 Pull Request
## 致谢
- [Pexels](https://www.pexels.com/) - 提供免费高质量图片
- [Model Context Protocol](https://modelcontextprotocol.io/) - 标准化 AI 助手工具接口
## 支持
如果你觉得这个项目有用,请给它一个 ⭐️!
如有问题或建议,请创建 [Issue](https://github.com/your-username/pexels-mcp/issues)。TDQS
Scored across 3 tools
Each tool targets a distinct access path: query-based search, a curated feed with no input, and ID-based detail lookup. There is no realistic scenario where an agent would confuse search_photos with get_curated_photos or get_photo_details.
All three follow a clean verb_noun pattern (search_photos, get_curated_photos, get_photo_details) with consistent snake_case. The verbs accurately signal the operation type.
Three tools is on the thin side but well-matched to a focused, read-only photo browsing server. Nothing feels redundant, though a bit more surface would make it feel complete.
Search, curated browsing, and detail lookup cover the core read-only discovery lifecycle for photos. Gaps exist for collections, videos, or download/link retrieval, but agents can work around these for the stated photo-search purpose.