> ## Documentation Index
> Fetch the complete documentation index at: https://docs.minidesk.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 工具

> 十三个工具，各自接收什么参数，返回什么结果。

十三个工具。九个读取，四个写入。客户端通过标准的 `tools/list` 发现它们，因此这里的内容都不需要自定义集成。

每个摘要都带有 `as_of`。AI 客服在阅读队列摘要时，队列本身仍在变化；一个没有时间戳的数字，一小时后就会被人拿到会议上引用。

## get\_support\_summary

队列当前的状态。

**输入：** 无。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "open_conversations": 59,
  "by_status": { "new": 12, "open": 38, "pending": 9, "resolved": 104 },
  "oldest_waiting_hours": 32,
  "first_reply": { "median_minutes": 42.5, "window_days": 30 }
}
```

`open_conversations` 把 `new`、`open` 和 `pending` 合计在一起。`resolved` 和 `closed` 已经离开队列，因此会出现在 `by_status` 中，但不计入总数。

`first_reply` 是会话开启到首次公开回复之间的中位时间，统计范围为最近 30 天内开启的会话。它与聊天插件上“通常回复时间”那一行显示的是同一个数字。引用时需要注意两点：

* AI 客服的自动回复也计入首次回复。发送自动回复的工作区在这里看起来很快，即使人工回复很慢。
* 当统计窗口内获得回复的会话少于五个时，`median_minutes` 为 `null`。否则一个缓慢的夜晚就会决定这个数字。

## list\_oldest\_unanswered

自客户最后一条消息以来没有回复的会话，按等待时间从长到短排列。

**输入：** `limit`，1 到 50，默认 10。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "data": [
    {
      "id": "0195e2c1-...",
      "reference": "ACME-1042",
      "preview": "Clicking export does nothing.",
      "priority": "high",
      "waiting_since": "2026-08-27T06:12:00Z",
      "requester": "sam@customer.com"
    }
  ]
}
```

> [!NOTE]
>
> “未回复”与 `status = "new"` 不是一回事。有人开启、读过又搁置的工单，从客户关心的任何角度看都是未回复的，而它的状态是 `open`。这里检查的是自请求者最后一条消息以来是否有过公开回复。

## search\_tickets

按会话中写的内容、开启时间或两者兼有来查找会话。所有匹配项的数量会显示在结果行旁边。可以用它查找单个工单（“提到订单 4512 的那位客户”），也可以查看某个时间段（“这个月客户都在反馈什么”“八月与七月相比如何”）。

**输入：** 全部可选。

| 字段 | 含义 |
| - | - |
| `query` | 要查找的词：客户写的内容、工单编号、姓名或电子邮件地址。 |
| `days` | 从今天往前推的天数，1 到 365。默认 30；带 `query` 时默认 365。 |
| `from` | 统计的第一天，格式如 `2026-08-01`。 |
| `to` | 统计的最后一天，包含当天，格式如 `2026-08-31`。 |
| `tag` | 工作区标签列表中的一个标签名，例如 `billing`。旧版客户端中的 `topic` 按同样方式读取。 |
| `limit` | 每页行数，1 到 50。默认 25。 |
| `cursor` | 上一次调用返回的 `next_cursor`。 |

单独给出 `days` 表示滚动窗口，给出 `from` 和 `to` 表示固定窗口。只要出现其中任一日期，就优先于 `days`。只给 `from` 时统计到今天；只给 `to` 时从该日期往前推 `days` 天。

带 `query` 且没有日期时，窗口是最近一年而不是最近 30 天。搜索通常是为了找某个特定会话，而那个会话很少来自本月。

```json theme={null}
{
  "as_of": "2026-09-08T14:22:10Z",
  "period": { "from": "2025-09-09", "to": "2026-09-08", "timezone": "UTC" },
  "query": "charged twice",
  "total": 3,
  "by_status": { "new": 0, "open": 1, "pending": 0, "resolved": 2, "closed": 0 },
  "by_tag": [
    { "tag": "billing", "count": 3 }
  ],
  "tickets": [
    {
      "id": "0195e2c1-...",
      "reference": "ACME-1043",
      "status": "open",
      "priority": "high",
      "tags": ["billing"],
      "created_at": "2026-09-07T08:41:00Z",
      "preview": "I was charged twice for the September plan."
    }
  ],
  "next_cursor": null
}
```

> [!NOTE]
>
> `total`、`by_status` 和 `by_tag` 描述的是全部匹配项。`tickets` 只是其中一页。用计数了解该时间段的整体情况，用结果行了解客户使用的措辞，不要把一页当作整个时间段。

`by_tag` 中 `tag` 为 `null` 的是未打标签的类别：没有标签的会话。带有两个标签的会话会在两个标签下各计一次，因此 `by_tag` 的合计可能大于 `total`；`by_status` 才是合计等于总数的分类。

窗口按会话开启的时间筛选。结果行按队列自身的顺序返回，最近活跃的在前，这两者并不相同：本月 1 日开启、今早有人回复的会话会排在靠前的位置。每一行都带有自己的 `created_at`。

没有状态筛选，因为 `by_status` 就是状态分类。指定窗口，然后读取分类结果。

内部备注不参与其中。`query` 只匹配客户能看到的文本，`preview` 是最新的公开消息。否则，搜索备注中的某个词就会让 AI 客服知道该备注存在以及它的内容。

可能的错误：

| `error` | 含义 |
| - | - |
| `query must be text...` | `query` 不是字符串 |
| `days must be a number of days, such as 30.` | `days` 不是数字 |
| `from must be a date like 2026-08-01.` | 无法解析或不可能的日期 |
| `from is after to. Give the earlier date as from.` | 日期范围颠倒 |

## get\_agent\_workload

每位活跃成员被分配了多少个未关闭的会话。

**输入：** 无。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "data": [
    { "name": "Priya", "open_assigned": 14 },
    { "name": "Sam", "open_assigned": 3 }
  ]
}
```

仅限活跃成员。已停用的同事保留其消息历史，但不计入处理能力。

## get\_ticket

一个会话及其**公开**消息。

**输入：** `ticket_id`，必填。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "id": "0195e2c1-...",
  "reference": "ACME-1042",
  "status": "open",
  "priority": "high",
  "tags": [{ "name": "billing", "ai": true }],
  "language": "en",
  "messages": [
    {
      "author_type": "requester",
      "body": "Clicking export does nothing.",
      "created_at": "2026-08-27T06:12:00Z",
      "attachments": [
        {
          "filename": "export-error.webp",
          "mime_type": "image/webp",
          "size_bytes": 48211,
          "url": "https://..."
        }
      ]
    }
  ]
}
```

每条消息都会列出其 `attachments`：客户的截图和 PDF，其中的 `url` 在一小时内有效。需要新链接时，重新请求该会话即可。没有文字的文件以文件名作为 `body`。

内部备注不会从结果中过滤掉，而是从一开始就不会被获取。MCP 客户端是一个 AI 客服，其输出可能被人粘贴到任何地方；内部备注一旦到达它那里，就等同于泄露给客户，只是多隔了一步。

未知的或属于其他工作区的 id 会返回 `{ "error": "not_found" }`。

## get\_customer

一位客户：身份信息、联系了多久，以及最近十次会话。

**输入：** `email` 或 `ticket_id` 之一。使用 `ticket_id` 时，得到的是开启该会话的客户。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "name": "Sam Lee",
  "email": "sam@customer.com",
  "external_id": "user_8812",
  "verified": true,
  "customer_since": "2026-02-03T09:15:00Z",
  "last_seen": "2026-08-27T06:12:00Z",
  "conversations": 6,
  "open_conversations": 1,
  "channels": ["email", "widget"],
  "recent_tickets": [
    {
      "id": "0195e2c1-...",
      "reference": "ACME-1042",
      "status": "open",
      "created_at": "2026-08-27T06:12:00Z",
      "preview": "Clicking export does nothing."
    }
  ]
}
```

`external_id` 是您自己的应用用来识别该客户的 id，前提是您的聊天插件或 API 发送过它。`preview` 是每个会话的第一条公开消息，通常就是该会话的主题。

团队对该客户的私密备注永远不会包含在内，原因与 `get_ticket` 不返回内部备注相同。客户的浏览器和设备详情同样不会包含。已请求删除数据的客户会返回 `"erased": true`，且没有姓名或电子邮件。

已合并到另一位客户的客户会返回其合并后的客户。未知的电子邮件，或来自其他工作区的工单，会返回 `{ "error": "not_found" }`。

## list\_pending\_drafts

等待人工审核的 AI 草稿，按时间从早到晚排列。仅限仍处于开启状态的会话：已解决工单中遗留的草稿不会等待任何人。

**输入：** `limit`，1 到 25，默认 10。

```json theme={null}
{
  "as_of": "2026-08-28T14:22:10Z",
  "total": 4,
  "drafts": [
    {
      "draft_id": "0195e3a0-...",
      "ticket_id": "0195e2c1-...",
      "reference": "ACME-1042",
      "ticket_status": "open",
      "body": "Thanks for flagging this. It was a permissions bug and it is now fixed.",
      "confidence": 0.82,
      "grounding_score": 0.91,
      "created_at": "2026-08-27T06:14:00Z"
    }
  ],
  "note": "Drafts reach nobody until a person sends them from the inbox."
}
```

`total` 统计所有待审核草稿，因此可以区分一页和整个列表。其中包括通过 `create_draft_reply` 创建的草稿。

## search\_knowledge

按主题查找工作区自己的参考文档。

**输入：** `query`（空查询会列出全部），`limit` 1 到 25，默认 10。

```json theme={null}
{
  "query": "refund policy",
  "documents": [
    {
      "document_id": "0195dd40-...",
      "title": "Refunds and cancellations",
      "language": "en",
      "tokens": 1840
    }
  ]
}
```

只返回标题和大小，不返回正文。如果搜索返回完整文档，上下文窗口就会被模型不需要的那四篇占满。提供 `tokens` 是为了让模型在请求文档前能区分一行规则和一本手册。

超过 40,000 个字符的文档按章节搜索。命中结果会标明找到这些词的章节，`tokens` 是该章节的大小：

```json theme={null}
{
  "document_id": "0195dd41-...",
  "title": "Staff handbook",
  "language": "en",
  "tokens": 2100,
  "section": 14,
  "section_title": "Returns › Sale items",
  "sections": 52
}
```

将 `section` 传给 `read_document` 即可读取该部分。

## read\_document

一篇参考文档的全文，或长文档中某一章节的内容。

**输入：** `document_id`，必填。请先从 `search_knowledge` 获取。`section` 可选，用于超过 40,000 个字符的文档：可以是搜索命中结果或文档大纲中给出的章节编号。

```json theme={null}
{
  "document_id": "0195dd40-...",
  "title": "Refunds and cancellations",
  "language": "en",
  "complete": true,
  "content": "Refunds are available within 14 days..."
}
```

40,000 个字符及以下的文档会整篇读取。更长的文档按章节读取。不传 `section` 时，会得到其大纲，没有 `content`：

```json theme={null}
{
  "document_id": "0195dd41-...",
  "title": "Staff handbook",
  "complete": false,
  "sections": 52,
  "outline": [
    { "section": 1, "title": "Returns", "tokens": 1900 },
    { "section": 2, "title": "Returns › Sale items", "tokens": 2100 }
  ],
  "note": "This document is long, so it is read by section. ..."
}
```

传入 `section` 时，返回该章节的完整内容，标题带有其所属文档，并给出前后章节的编号：

```json theme={null}
{
  "document_id": "0195dd41-...",
  "title": "Staff handbook › Returns › Sale items",
  "section": 2,
  "sections": 52,
  "previous": 1,
  "next": 3,
  "complete": true,
  "content": "Sale items cannot be returned..."
}
```

条件或例外可能位于搜索命中的章节之外，因此请阅读与问题相关的每个章节。

抓取的网站页面在 80,000 个字符以内会整篇读取。超过后，`complete` 为 `false`，`note` 会说明返回了多少内容：

```json theme={null}
{
  "complete": false,
  "content": "...",
  "note": "This document is 90000 characters and you are reading the first 80000. Say what you could not check rather than assuming the rest agrees."
}
```

截断会被明确告知，而不是静默发生，因为静默截断会被当作完整文本，回复中就会陈述一项被未读部分限定的政策。

传入的不是文档 id 时，会返回一条提示模型先搜索的消息，而不是数据库错误。否则模型往往会根据标题猜测文件名。

## create\_draft\_reply

让 miniDesk 自己的模型根据您的文档撰写回复，供人工审核。如果想发送自己的文字，请使用下面的 `reply_ticket`。

**输入：** `ticket_id`，必填。

```json theme={null}
{
  "draft_id": "0195e3a0-...",
  "body": "Thanks for flagging this. It was a permissions bug and it is now fixed.",
  "confidence": 0.82,
  "grounding_score": 0.91,
  "delivered": false,
  "note": "This is a draft. It reaches nobody until a person sends it."
}
```

`delivered: false` 和这条说明每次都会返回，这是有意为之，这样连接的 AI 客服就无法告诉其用户回复已发送。

草稿会保存在仪表板中供审核，同时记录调用的模型，并在同一事务中写入一条审计日志。它会替换该会话中已在等待的任何草稿，因此客户端会被告知此工具具有破坏性。

可能的错误：

| `error` | 含义 |
| - | - |
| `not_found` | 未知工单，或属于其他工作区 |
| `ai_disabled` | 该工作区已关闭 AI |
| `quota_exceeded` | 工作区已用完 AI 额度。额度重置后再试 |
| `no_draft_available` | 模型没有生成可用内容 |

## reply\_ticket

向客户发送您自己的文字。

> [!WARNING]
>
> 这会送达真实的人，且无法撤回。调用前请把措辞展示给您所服务的人，并取得对方同意。

**输入：** `ticket_id` 和 `body`，均必填。`body` 是客户看到的文本，最多 10,000 个字符。

```json theme={null}
{
  "message_id": "0195e3b7-...",
  "delivered": true,
  "note": "This was sent to the customer. It cannot be unsent."
}
```

当回复已写入但未送达客户时，`delivered` 为 `false`。可能是客户的渠道拒绝了它，例如 Instagram 超过 24 小时窗口，或者您的工作区达到了[发送限制](https://docs.minidesk.ai/guides/sending-limits.md)。回复会保留在会话中，会话中的内部备注会说明原因。

```json theme={null}
{
  "message_id": "0195e3b7-...",
  "delivered": false,
  "note": "The reply is on the conversation, but it did not reach the customer. An internal note on the conversation says why."
}
```

一条消息，一个会话。无法向工单列表群发，这是有意设计的：[原因在这里](https://docs.minidesk.ai/mcp/safety.md)。

消息归属于发送它的凭据，而不是某个人，因此会话记录会显示是哪个集成写入的。出于同样的原因，这些回复不会进入我们的草稿模型学习过往回复的池子：您团队中没有人对它们署名。

可能的错误：

| `error` | 含义 |
| - | - |
| `not_found` | 未知工单，或属于其他工作区 |
| `body is required...` | 正文为空，或不是字符串 |
| `body is N characters...` | 超过 10,000 字符限制 |

## write\_knowledge

提交一篇参考文档：一项政策、一条规则、一则产品说明。

**输入：** `title` 和 `content`，均必填。`content` 是文档正文，最多 80,000 个字符。

```json theme={null}
{
  "document_id": "0195e3c2-...",
  "active": false,
  "note": "Saved as a proposal. An owner has to switch it on from the knowledge screen before the AI can read it."
}
```

> [!NOTE]
>
> 这不会向您的知识中添加任何内容。文档会以关闭状态保存，并出现在知识页面中，标记为**等待您处理**。在所有者批准之前，产品中的任何查询都不会把它的文本交给模型。

文本会经过与其他所有文档相同的脱敏处理，因此 AI 客服从工单会话中复制出来的卡号不会被存储。

可能的错误：

| `error` | 含义 |
| - | - |
| `title is required.` | 标题为空或缺失 |
| `content is required...` | 内容为空或缺失 |
| `content is N characters...` | 超过 80,000 字符限制；请拆分 |

## add\_internal\_note

在一个会话中为您的团队留下备注。

**输入：** `ticket_id` 和 `body`，均必填。`body` 最多 10,000 个字符。

```json theme={null}
{
  "message_id": "0195e3d4-...",
  "visible_to_customer": false,
  "note": "Saved as an internal note. Only your team can see it."
}
```

客户永远看不到它。它不会发送邮件，不会改变会话状态，也不计入您的套餐。

miniDesk 的 AI 也不会读取它。草稿模型只读取公开消息，因此备注无法改变它写给客户的内容。

备注归属于写入它的凭据，而不是某个人，因此您的团队可以区分集成写入的备注和同事写的备注。

可能的错误：

| `error` | 含义 |
| - | - |
| `not_found` | 未知工单，或属于其他工作区 |
| `body is required...` | 正文为空，或不是字符串 |
| `body is N characters...` | 超过 10,000 字符限制 |

## 不存在的工具

没有 `update_ticket`、`assign_ticket` 或 `resolve_ticket`，也没有任何工具接收工单列表。

它们的缺失是安全模型的一部分，而不是疏忽。[原因在这里](https://docs.minidesk.ai/mcp/safety.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.