Clone MCP 工具

init_context、提示词预测工具、ask_question 和 feedback_loop 的用途、输入、输出与调用时机。

Clone MCP 提供五个工具。客户端会将它们列在你所选的服务器名称下,例如 clone_mcp.init_context 或 mcp__clone_mcp__init_context。每个结果都包含符合该工具 outputSchema 的 structuredContent,以及供只显示文本的客户端使用的简短文字摘要。

工具调用时机返回内容
init_context在对话开始时调用一次,先于其他 Clone 工具session_id 和用户选择共享的 Clone 上下文
predict_first_prompts用户尚未提出具体请求时最多 5 条按排名排列的首条提示词
predict_followup_prompts智能体完成一个结果之后、交还控制权之前最多 5 条按排名排列的反馈或下一步请求提示词
ask_question代替向用户提出澄清问题Clone 预期的用户回答,以及是否必须由用户决定
feedback_loop用户接受、编辑或拒绝某条预测或回答时反馈已记录的确认

Clone 会返回供你审阅的建议,并记录预测 ID 以接收反馈。如果某个 Clone 工具调用失败,不要中断任务:错误与限制说明了何时应再次调用 Clone、何时应在没有它的情况下继续。

对于预测工具和 ask_question,session_id 是可选的。没有它时,Clone 会使用该次调用中发送的上下文以及用户共享的 Clone 上下文。

init_context

为当前对话启动或恢复一个 Clone 会话。它会将对话的初始上下文存储在 Clone 的服务器上,并返回用户在连接应用时选择的上下文来源。

JSON
{
  "conversation_id": "host-thread-42",
  "workspace": { "name": "clone", "kind": "repository", "summary": "React site and FastAPI server" },
  "task": "Add a Clone MCP page to the developer site.",
  "messages": [],
  "instructions": "Prefer small pull requests. Write docs in English.",
  "language": "auto"
}

所有字段都是可选的。conversation_id 让调用具有幂等性:相同的 ID 会恢复同一个会话,并在上下文发生变化时返回新的 context_revision。workspace.kind 为 chat、repository、document 或 other。messages 最多接受 30 个最近的轮次,每个最多 8,000 个字符,包含 role(user 或 assistant)和可选的 origin(human 或 agent)。仅当 instructions 描述的是用户本人的长期偏好时才发送它。

JSON
{
  "session_id": "mcp-session-example",
  "context_revision": "1",
  "user_context": {
    "profile": [{ "id": "profile-1", "label": "Writing", "text": "Prefers concise Korean summaries." }],
    "goals": [{ "id": "goal-1", "title": "Clone MCP design", "summary": "Design the server and docs." }]
  },
  "agent_guidance": "Ask Clone with ask_question before asking the user a clarifying question.",
  "expires_at": 1790812860
}

如果用户没有共享任何来源,user_context 为空。会话在 7 天没有活动后过期;如需继续,请使用相同的 conversation_id 再次调用 init_context。

predict_first_prompts

根据共享的 Clone 上下文和工作区,预测用户会如何开始这次会话。当开场消息为空或含糊(例如“继续”或“下一步呢?”),或者你的宿主应用会显示起始建议时,请使用它。

JSON
{ "session_id": "mcp-session-example", "count": 3, "draft": "" }

count 为 1 到 5,默认为 3。非空的 draft(最多 8,000 个字符)会让 Clone 改为补全用户已开始输入的文本。没有 session_id 时,预测只使用用户共享的 Clone 上下文。

JSON
{
  "status": "suggested",
  "predictions": [
    { "prediction_id": "prediction-example-1", "rank": 1, "text": "Review the Clone MCP design and list open decisions." },
    { "prediction_id": "prediction-example-2", "rank": 2, "text": "Draft the docs page for the MCP tools." }
  ],
  "expires_at": 1790812860
}

将预测作为选项显示。除非用户选择,否则绝不要把某条预测作为用户的消息发送。abstained 结果的 predictions 列表为空;照常继续即可。

predict_followup_prompts

预测用户在智能体给出最新结果之后的下一条消息:对该结果的反馈,或下一个请求。

JSON
{
  "session_id": "mcp-session-example",
  "messages": [
    { "role": "user", "content": "Add a Clone MCP page.", "origin": "human" },
    { "role": "assistant", "content": "Added /mcp with connection steps and a tool list." }
  ],
  "artifact": { "kind": "code", "title": "CloneMcp.tsx", "summary": "New page, route and nav entry." },
  "count": 3
}

messages 是必填项,至少包含一个轮次:发送自上次调用 Clone 以来的轮次,包括最新的结果。artifact 是可选的;但如果发送,就必须同时包含 kind(code、document、image 或 other)和 summary(最多 4,000 个字符)。

结果的结构与 predict_first_prompts 相同。每条预测还带有 kind:feedback 是对最新结果的反应,next_request 则推动工作向前。请将这些预测提供给用户。只有当用户明确要求你按照 Clone 的建议继续时,才自行根据预测采取行动。

ask_question

向 Clone 提出你原本会问用户的问题。输入格式与 AskUserQuestion 一致,因此智能体可以发送相同的问题。

JSON
{
  "session_id": "mcp-session-example",
  "context": "Choosing storage for a local prototype.",
  "questions": [
    {
      "question": "Which database should the prototype use?",
      "header": "Database",
      "multiSelect": false,
      "options": [
        { "label": "SQLite", "description": "No server to run" },
        { "label": "Postgres", "description": "Matches production" }
      ]
    }
  ]
}

发送一到四个问题,每个问题有两到四个选项。适合用简短文字回答时,也可以发送不带选项的问题。

JSON
{
  "answers": [
    {
      "question": "Which database should the prototype use?",
      "prediction_id": "prediction-example-3",
      "selected": ["SQLite"],
      "text": "",
      "confidence": "high",
      "needs_user": false,
      "basis": "Chose SQLite for the last two local prototypes."
    }
  ],
  "expires_at": 1790812860
}

confidence · high / medium / low. 当 needs_user 为 true 时,请询问用户。只有 Clone 给出建议时,才将其标为推荐选项。 付款、删除、执行代码或安装软件、更改访问权限、影响他人的操作,以及在任务范围之外共享数据,都由用户决定。 先问 Clone,再问用户

feedback_loop

报告用户如何处理某条预测或回答。除非此应用的学习功能已关闭,否则编辑和拒绝会让该用户的 Clone 从中学习,改进该用户之后得到的预测和回答,在共享相同 Clone 上下文的其他已连接应用中也是如此。接受会被记录,但不会用于学习。

JSON
{
  "session_id": "mcp-session-example",
  "prediction_id": "prediction-example-3",
  "result": "reject",
  "answer": "Postgres",
  "reason": "The prototype will share the production schema.",
  "event_id": "feedback-001"
}
字段是否必填含义
session_id否产生该预测的会话
prediction_id是来自某条预测或 ask_question 回答的 ID
result是accept:原样使用。edit:修改后使用。reject:已忽略或给出了不同的回答
answeredit 时必填用户实际发送或选择的内容,最多 4,000 个字符
reason否用户编辑或拒绝的原因,最多 1,000 个字符
event_id否幂等键;重试同一报告时请重复使用

仅根据用户实际说过或做过的内容发送 reason 和 answer。不要只为了填写该字段而向用户询问原因。每条预测只报告一次。

JSON
{ "status": "recorded", "event_id": "feedback-001" }

使用相同的 event_id 和请求体重试会返回 duplicate。反馈经过加密,仅用于该用户的 Clone,并在 30 天后过期。Clone 是否从某个应用的反馈中学习,由同意页面上的开关按应用分别设置;如需更改,需要重新连接该应用。在“已连接的应用”中,用户可以断开某个应用的连接,或清除 Clone 从 AI 应用中学到的全部内容。

错误与限制

工具出错时会返回 isError: true,以及以错误代码开头的文本。请按下表处理,不要循环重试。

代码处理方式
invalid_arguments参数与工具的输入 schema 不符:修正参数后再次调用
session_not_found此应用没有该 session_id 对应的 Clone 会话:调用 init_context,并使用它返回的 session_id
session_expired会话已连续 7 天没有活动:使用相同的 conversation_id 再次调用 init_context
context_too_large上下文超出了 Clone 的限制:减少发送的轮次,或缩短轮次
rate_limited短时间内调用过多:等待消息中注明的秒数,或在没有 Clone 的情况下继续
quota_exceeded本周的 Clones 已用完:在没有 Clone 的情况下继续
unavailableClone 暂时无法回答:在没有 Clone 的情况下继续
prediction_not_foundClone 中没有该 prediction_id 对应的预测:按 Clone 返回的原样发送 ID,或放弃这次报告
prediction_expired反馈送达前预测已过期:放弃这次报告
event_id_conflict该 event_id 已用于其他反馈:使用新的 event_id 发送这次报告

登录过期或被撤销时会返回 HTTP 401;客户端会要求用户重新连接。