Google Photos MCP Server
Google Photos MCP 服务器
一个用于 Google 相册集成的模型上下文协议 (MCP) 服务器,使 Claude、Gemini 和其他 AI 助手能够读取、写入和选择您 Google 相册库中的照片。
✅ Picker API 支持 (2025 年 3 月起)
此服务器实现了 Google Photos Picker API,即使在 2025 年 3 月 31 日某些 Library API 作用域弃用后,也能提供完整的相册库访问权限。
功能 | 状态 | API |
浏览完整照片库 | ✅ | Picker API |
按文本/日期/类别搜索照片 | ✅ | Library API |
创建相册并上传照片 | ✅ | Library API |
访问应用创建的内容 | ✅ | Library API |
Picker API 的工作原理
调用
create_picker_session— 返回一个用户在浏览器中打开的 URL用户从其完整相册库中选择照片
调用
poll_picker_session— 当mediaItemsSet为 true 时,返回选定的照片
Related MCP server: CoreViz MCP
🛡️ 安全声明:已移除 CORS
出于安全考虑,已移除 CORS 中间件(防止针对 localhost 的驱动下载攻击)。
✅ STDIO 模式 (Claude Desktop):正常工作
✅ 流式 HTTP (Cursor, 服务器到服务器):正常工作
❌ 浏览器 AJAX:不支持(设计使然)
功能
读取操作
按文本、日期、位置、类别、收藏夹搜索照片
按媒体类型(照片/视频)、日期范围、归档状态进行过滤
获取照片详情,包括 base64 编码的图像
列出相册及其内容
描述可用的过滤功能
写入操作
创建相册并上传照片
使用
create_album_with_media进行批量上传(最多 50 个文件)向相册添加文本和位置丰富信息
设置相册封面照片
Picker 操作
创建 Picker 会话以访问完整相册库
轮询会话并检索选定的媒体项
基础设施
⚡ 流式 HTTP 传输 (MCP 2025-06-18 规范)
🔗 带有连接池的 HTTPS Keep-Alive
🔒 操作系统密钥链令牌存储
📊 带有自动跟踪的配额管理
🔄 自动令牌刷新
先决条件
Node.js 22.22+
已启用 Photos Library API 的 Google Cloud 项目
OAuth 2.0 凭据(Web 应用类型)
设置
1. Google Cloud 设置
创建一个新项目(或选择现有项目)
启用 Photos Library API
创建 OAuth 2.0 凭据(Web 应用)
将
http://localhost:3000/auth/callback添加为授权重定向 URI记下您的客户端 ID 和客户端密钥
2. 安装
git clone https://github.com/savethepolarbears/google-photos-mcp.git
cd google-photos-mcp
npm install3. 配置
cp .env.example .env编辑 .env:
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/callback
PORT=3000
NODE_ENV=development4. 构建并运行
npm run build # Compile TypeScript
npm start # HTTP mode (for auth & Cursor)
npm run stdio # STDIO mode (for Claude Desktop)
npm run dev # Dev mode with live reload5. 身份验证
以 HTTP 模式启动:
npm start在浏览器中访问
http://localhost:3000/auth完成 Google OAuth 流程
令牌会自动保存到操作系统密钥链中
注意:必须先在 HTTP 模式下完成身份验证。之后,切换到 STDIO 模式以供 Claude Desktop 使用。
动态端口
PORT=3001 npm start
# Also update GOOGLE_REDIRECT_URI in .env to match客户端配置
Claude Desktop (STDIO)
{
"mcpServers": {
"google-photos": {
"command": "node",
"args": ["/path/to/google-photos-mcp/dist/index.js", "--stdio"],
"env": {
"GOOGLE_CLIENT_ID": "your_client_id",
"GOOGLE_CLIENT_SECRET": "your_client_secret",
"GOOGLE_REDIRECT_URI": "http://localhost:3000/auth/callback"
}
}
}
}Cursor IDE
STDIO (推荐):
类型:Command
命令:
node /path/to/google-photos-mcp/dist/index.js --stdio
HTTP:
类型:URL
URL:
http://localhost:3000/mcp
Smithery
# Claude Desktop
npx -y @smithery/cli install google-photos-mcp --client claude
# Cursor IDE
npx -y @smithery/cli install google-photos-mcp --client cursorMCP Inspector
npx @modelcontextprotocol/inspector node dist/index.js # HTTP
npx @modelcontextprotocol/inspector node dist/index.js --stdio # STDIO可用工具 (19)
搜索与浏览
工具 | 描述 |
| 基于文本的照片搜索 |
| 按位置名称搜索 |
| 按日期、类别、媒体类型、收藏夹、归档进行过滤 |
| 获取照片详情(可选 base64) |
| 列出所有相册 |
| 获取相册详情 |
| 列出相册中的照片 |
| 列出所有媒体项 |
| 所有过滤选项的 JSON 参考 |
写入与管理
工具 | 描述 |
| 创建新相册 |
| 上传本地文件 |
| 将现有项目添加到相册(最多 50 个) |
| 一次调用创建相册 + 上传文件(最多 50 个) |
| 添加文本或位置丰富信息 |
| 设置相册封面照片 |
Picker API
工具 | 描述 |
| 启动 Picker 会话以访问完整相册库 |
| 检查会话状态并检索选定的照片 |
身份验证
工具 | 描述 |
| 检查身份验证状态 |
| 通过临时本地服务器启动 OAuth 流程 |
示例查询
"Show me photos from my trip to Paris"
"Find photos of my dog from 2024"
"List my photo albums"
"Upload these vacation photos to a new album called 'Summer 2025'"
"Search for landscape photos from last year, ordered newest first"
"Let me pick some photos from my library" (triggers Picker API)位置数据
位置数据是近似值,使用 OpenStreetMap/Nominatim 地理编码从照片描述中提取。如果可用,包括纬度/经度、城市、地区、国家。
部署/发布
本项目是一个模型上下文协议 (MCP) 服务器,旨在与 Claude Desktop 或 Cursor 等 AI 客户端一起在本地运行。除了保持您的本地检出或 NPM 安装为最新版本外,无需进行远程部署或发布流程。
故障排除
Node 版本:确保您使用的是 Node.js 22.22+,因为不支持旧版本。
身份验证:如果您遇到
GOOGLE_CLIENT_ID is not set错误或身份验证失败,请验证您的.env文件是否存在于根目录中,并包含正确的 Google Cloud 凭据。请记住在切换到 STDIO 模式之前运行npm start(HTTP 模式) 进行身份验证。配额问题:适用 Google Photos API 限制。确保您没有达到每天 10,000 次请求的配额限制。服务器通过
quotaManager跟踪此限制。CORS 错误:服务器有意禁用 CORS 以防止驱动下载攻击。请勿尝试直接从浏览器 AJAX 请求调用服务器。
开发
项目结构
src/
├── index.ts # HTTP entry point
├── dxt-server.ts # STDIO/DXT entry point
├── mcp/core.ts # All tool handlers (19 tools)
├── api/
│ ├── client.ts # REST client (Library + Picker)
│ ├── photos.ts # Facade module (re-exports)
│ ├── types.ts # TypeScript interfaces
│ └── repositories/ # Low-level API calls
├── auth/ # OAuth, tokens, keychain
├── schemas/ # Zod validation schemas
├── utils/ # Config, logging, quota, retry
└── views/ # HTML templates测试
npm test # All tests (Vitest)
npm run test:watch # Interactive TDD
npm run test:coverage # Coverage report
npm run test:security # Security suite only质量检查
合并前必须通过以下三项:
npx tsc --noEmit # Type check
npm run lint # ESLint
npm test # Tests许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Holiday photo MCP server: list and fetch personal holiday photos inline in Claude chat.
Geolocate Me turns your phone into location context for any AI assistant. Install the iOS or Android app, connect once with OAuth, and your GPS is queryable in natural language. Ask where you are, where you parked, where you were yesterday at 3pm, or how long you were at the office — the assistant calls the tool and answers with a real street address. https://geolocateme.app
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables AI assistants to query and export from the macOS Apple Photos library using natural language, backed by osxphotos.21154 npm22MIT

CoreViz MCPofficial
AlicenseNot gradedqualityDmaintenanceExposes a visual library with semantic search, tagging, editing, and management of photos as tools for AI agents like Claude Code.8 npm48MIT- FlicenseNot gradedqualityBmaintenanceEnables users to search and retrieve photos from a self-hosted Immich photo library via natural language, supporting CLIP-based semantic search, metadata filtering, album browsing, and share link creation.-
- AlicenseAqualityAmaintenanceEnables AI agents to search, inspect, organize, and export photos from a local Apple Photos library using natural language, including scene labels, text, faces, places, and albums.1331 npmMIT