内容
# @rendershot/mcp-server
Rendershot截图和PDF生成API的模型上下文协议(MCP)服务器。允许AI代理(如Claude、Cursor等)直接捕获截图并生成PDF。
**来源:** [github.com/Rendershot/rendershot-mcp-server](https://github.com/Rendershot/rendershot-mcp-server)
## 快速开始
无需安装 — 使用 `npx` 运行:
```bash
RENDERSHOT_API_KEY=您的密钥 npx @rendershot/mcp-server
```
## Claude 桌面端设置
添加到 `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"rendershot": {
"command": "npx",
"args": ["-y", "@rendershot/mcp-server"],
"env": {
"RENDERSHOT_API_KEY": "您的API密钥"
}
}
}
}
```
## Cursor / VS Code 设置
添加到您的MCP设置:
```json
{
"rendershot": {
"command": "npx",
"args": ["-y", "@rendershot/mcp-server"],
"env": {
"RENDERSHOT_API_KEY": "您的API密钥"
}
}
}
```
## 环境变量
| 变量 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| `RENDERSHOT_API_KEY` | 是 | — | 您的Rendershot API密钥 |
| `RENDERSHOT_BASE_URL` | 否 | `https://api.rendershot.io` | API基础URL(用于自托管) |
## 工具
### `take_screenshot`
捕获一个URL或HTML字符串的截图。返回一个base64编码的图片。
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| `url` | 字符串 | — | 要截图的页面URL *(必填:url/html之一)* |
| `html` | 字符串 | — | 要渲染的原始HTML *(必填:url/html之一)* |
| `format` | `png` | `png` | 输出图片格式 |
| `quality` | 1–100 | `85` | JPEG质量(忽略PNG) |
| `viewport_width` | 1–3840 | `1280` | 视口宽度(像素) |
| `viewport_height` | 1–2160 | `720` | 视口高度(像素) |
| `full_page` | 布尔值 | `false` | 捕获整个可滚动页面 |
| `wait_for` | 字符串 | `dom_content_loaded` | `load` \| `dom_content_loaded` \| `network_idle` \| `commit` \| CSS选择器 |
| `delay_ms` | 0–10000 | `0` | 页面加载后额外延迟(毫秒) |
| `ai_cleanup` | `fast` \| `thorough` | — | 删除cookie横幅/弹窗前。`fast`使用JS启发式(1积分);`thorough`添加LLM通道(3积分) |
| `headers` | `{ [name]: value }` | — | 自定义HTTP头发送到渲染请求。最多30个,值≤2 KB。`Host` / `Cookie` / `Content-Length` / `Sec-*` / `Connection`被拒绝 |
| `cookies` | 数组 | — | 要注入的会话cookie。每个需要`name`、`value`和`domain` / `url`之一。可选:`path`、`expires`、`http_only`、`secure`、`same_site`(`Lax` \| `Strict` \| `None`)。最多50个 |
| `basic_auth` | `{ username, password }` | — | HTTP基本身份验证。在401挑战时发送 |
### `generate_pdf`
从URL或HTML字符串生成PDF。返回PDF的base64编码字符串。
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| `url` | 字符串 | — | 页面URL *(必填:url/html之一)* |
| `html` | 字符串 | — | 原始HTML *(必填:url/html之一)* |
| `format` | `A3` \| `A4` \| `Letter` \| `Legal` | `A4` | 纸张大小 |
| `orientation` | `portrait` \| `landscape` | `portrait` | 页面方向 |
| `print_background` | 布尔值 | `true` | 打印背景图形/颜色 |
| `wait_for` | 字符串 | `dom_content_loaded` | 与截图相同 |
| `delay_ms` | 0–10000 | `0` | 页面加载后额外延迟(毫秒) |
| `ai_cleanup` | `fast` \| `thorough` | — | 与截图相同 |
| `headers` | `{ [name]: value }` | — | 与截图相同 |
| `cookies` | 数组 | — | 与截图相同 |
| `basic_auth` | `{ username, password }` | — | 与截图相同 |
### `bulk_render`
一次提交最多20个截图或PDF作业。所有作业并行运行,结果包括每个作业的base64输出。
| 参数 | 类型 | 描述 |
|---|---|---|
| `jobs` | 数组(1–20) | 作业对象数组,每个作业类型为`screenshot`或`pdf`,加上与单个工具相同的字段 |
返回一个JSON对象,包含`credits_used`、`credits_remaining`和一个`results`数组,每个作业包含`index`、`result`(base64)和任何`error`。
### `check_balance`
检查剩余的API积分和计划详情。无参数。
## 注意事项
- 所有渲染调用内部使用异步模式,并轮询直到作业完成(最多5分钟)。
- 截图返回MCP `image`内容 — 代理可以内联显示它们。
- PDF返回base64编码的文本;代理可以保存它们到磁盘或传递它们。
- 来自API的错误(速率限制、积分耗尽、无效URL)作为MCP错误出现,带有原始错误代码。
## 要求
- Node.js 18+
## 许可证
MIT