内容
# pinterest-mcp
一个本地的MCP服务器,向Claude Code公开Pinterest API v5(只读)。
六个工具,所有工具的`readOnlyHint`均为`true`:
| 工具 | 端点 |
| --- | --- |
| `pinterest_get_user_account` | `GET /v5/user_account` |
| `pinterest_list_boards` | `GET /v5/boards` |
| `pinterest_get_board` | `GET /v5/boards/{board_id}` |
| `pinterest_list_board_pins` | `GET /v5/boards/{board_id}/pins` |
| `pinterest_list_pins` | `GET /v5/pins` |
| `pinterest_get_pin` | `GET /v5/pins/{pin_id}` |
令牌存储在`~/.pinterest-mcp/tokens.json`并自动刷新。
---
## 1. 创建一个Pinterest开发者应用
1. 在 <https://developers.pinterest.com/apps/> 登录。
2. 点击 **创建应用**。选择任意名称和描述。
3. 创建后,打开应用并复制 **应用ID** 和 **应用密钥**。
4. 在 **重定向URI** 下,添加确切的:`http://localhost:8085/callback`
- OAuth助手在该端口监听。如果需要不同的端口,请更改此字段和 `.env` 中的 `PINTEREST_REDIRECT_URI`。
5. 默认作用域(`user_accounts:read`,`boards:read`,`pins:read`)在标准应用层级上有效。只读探索不需要交易审查。
## 2. 配置项目
```sh
cd pinterest-mcp
npm install
cp .env.example .env
# 编辑 .env 并粘贴 PINTEREST_APP_ID 和 PINTEREST_APP_SECRET
```
## 3. 授权一次
```sh
npm run auth
```
这将:
1. 在浏览器中打开 `pinterest.com/oauth/`。
2. 等待您批准请求的作用域。
3. 在 `localhost:8085` 捕获重定向,将代码兑换为令牌。
4. 编写 `~/.pinterest-mcp/tokens.json`(模式 0600)。
您只需要重复此操作,如果您撤销访问权限或刷新令牌过期(Pinterest连续刷新令牌持续60天,但在使用时自动延长)。
## 4. 构建和烟雾测试
```sh
npm run build
npm run inspect # 打开MCP检查器,对抗构建的服务器
```
在检查器中,调用 `pinterest_get_user_account` — 它应该返回您的个人资料。
## 5. 连接到Claude Code
将以下内容添加到您的Claude Code MCP配置中(例如,`~/.claude.json`下的 `mcpServers`):
```json
{
"mcpServers": {
"pinterest": {
"command": "node",
"args": ["/Users/marketingmanagerturkiye/Documents/Claude/Projects/HyperFrame/pinterest-mcp/dist/server.js"],
"env": {
"PINTEREST_APP_ID": "...",
"PINTEREST_APP_SECRET": "..."
}
}
}
}
```
`PINTEREST_APP_ID` 和 `PINTEREST_APP_SECRET` 必须可被服务器进程读取 — 可以像上面一样内联,也可以从此目录中的 `.env` 文件(dotenv自动加载)。
---
## 注意
- 分页:返回列表的工具接受 `page_size`(1–100)和 `bookmark`。从以前的响应中传递 `bookmark` 以获取下一页。
- 错误:Pinterest API错误作为MCP工具错误返回,包含完整的响应体,以便您可以调试4xx/5xx而无需读取服务器日志。
- 添加写入工具(创建pin,创建板块等)需要匹配的`:write`作用域 — 将它们添加到`PINTEREST_SCOPES`并重新运行`npm run auth`,然后将工具添加到`src/server.ts`。