# run_report

> 立即生成一份已保存的报告，并把 PDF 附在结果中。

URL: https://repliqds.com/zh/docs/mcp/tools/run-report
更新于: 2026-11-24

## 功能说明

立即生成一份已保存的报告，并把 PDF 附在结果中。

- 消耗套餐每月报告额度中的 1 份（与应用相同的计数器）；请先调用 `get_quota`。
- PDF 仅作为嵌入资源发送给助手，不会发送任何邮件。超过 4 MB 时不附带，但仍会计入额度。
- 只有所有者、管理员和编辑者可以生成报告。

## 权限与限制

| 属性 | 值 |
| --- | --- |
| 权限 | `repliq:draft` |
| 类型 | 修改数据 |
| 每小时预算 | 无 |
| 套餐配额 | 无 |
| 行为提示 | 写入数据 · 非幂等 · 仅限 Repliq 内部 |

## 参数

- `report_id` (string (uuid), 必填): A report id from list_reports.
- `workspace_id` (string (uuid), 可选): A workspace id from list_locations; optional when the account has one workspace.

## 示例

一次完整调用，分别给出原始 JSON-RPC 请求和官方 MCP SDK 的写法。把 `REPLIQ_TOKEN` 换成访问令牌或个人令牌（参见[认证](https://repliqds.com/zh/docs/mcp/authentication)），并把 id 换成你自己通过 `list_locations` 得到的值。

**curl**

```bash
curl -sS https://repliqds.com/api/mcp \
  -H "Authorization: Bearer $REPLIQ_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"run_report","arguments":{"report_id":"5e2b7c90-4d1a-4a68-8f3b-0c9d1e7a2b46"}}}'
```

**TypeScript**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const client = new Client({ name: "my-script", version: "1.0.0" });
await client.connect(new StreamableHTTPClientTransport(new URL("https://repliqds.com/api/mcp"), {
  requestInit: { headers: { Authorization: `Bearer ${process.env.REPLIQ_TOKEN}` } },
}));

const result = await client.callTool({
  name: "run_report",
  arguments: {
    "report_id": "5e2b7c90-4d1a-4a68-8f3b-0c9d1e7a2b46"
  },
});
console.log(result.structuredContent);
```

本示例的参数已在 Repliq 自己的测试中按该工具的输入模式校验通过。

## 响应

调用成功时会返回两份相同的 JSON：一份在 `structuredContent` 中，另一份序列化在文本块中。其顶层字段为：

- `generated`
- `workspace_id`
- `run`
- `pdf`
- `note`
- `quota`

## 错误

调用失败时返回 `isError: true`，文本为 JSON：`{ "error": 错误码, "message": … }`。除了不符合输入模式的参数（会在工具运行前被拒绝）外，该工具可能返回：

| 错误码 | 含义 | 处理方法 |
| --- | --- | --- |
| `INSUFFICIENT_SCOPE` | 该连接没有被授予此工具所需的权限。 | 重新连接 Repliq 并勾选该权限，或创建包含该权限的个人令牌。 |
| `WORKSPACE_REQUIRED` | 账户有多个工作区，工具需要知道使用哪一个。 | 传入 `workspace_id`（错误信息会列出可用 id，`list_locations` 也会返回）。 |
| `NO_WORKSPACE` | 账户中还没有包含地点的工作区。 | 请先在 Repliq 应用中连接一个地点。 |
| `REPORT_NOT_FOUND` | 工作区中不存在该 id 的已保存报告。 | 调用 `list_reports`，使用其中的 id（及其 `workspace_id`）。 |
| `REPORT_QUOTA_EXCEEDED` | 该工作区已用完本月套餐允许的报告数量。 | 调用 `get_quota` 查看何时重置，或在 Repliq 中升级套餐。 |
| `READ_ONLY_ROLE` | 你在该工作区的角色是 viewer（只读）。 | 请所有者或管理员授予 Manager（editor）角色。 |
| `PLAN_REQUIRED` | 该地点没有有效的套餐或试用。 | 在 Repliq 中开始试用或订阅套餐。 |
| `TEMPORARILY_UNAVAILABLE` | Repliq 暂时无法完成请求，或无法检查每小时预算（此时会安全失败，不执行任何操作）。 | 稍后重试。 |

## 服务器发布的描述

Generates a saved report now and attaches its PDF to the result. Spends one report of the plan's monthly allowance (call get_quota first). Nothing is emailed. Owners, admins and editors. Needs the draft permission.

## 相关工具

- [`list_reports`](https://repliqds.com/zh/docs/mcp/tools/list-reports): 工作区中已保存的报告定义：类型、频率、收件人、上次和下次运行时间。
- [`get_quota`](https://repliqds.com/zh/docs/mcp/tools/get-quota): 每个工作区套餐的剩余额度：AI 回复、评价邀请、报告、导出、二维码、门店、团队席位、模板、分享链接和手动同步。
- [`list_exports`](https://repliqds.com/zh/docs/mcp/tools/list-exports): 工作区最近的导出记录（CSV、Excel、PDF、Word）：内容、操作者、时间和行数。
- [全部 MCP 工具](https://repliqds.com/zh/docs/mcp/tools): 完整目录及每个工具所需的权限。

## 相关文档

- [list_reports](https://repliqds.com/zh/docs/mcp/tools/list-reports)
- [get_quota](https://repliqds.com/zh/docs/mcp/tools/get-quota)
- [list_exports](https://repliqds.com/zh/docs/mcp/tools/list-exports)
