mcpField
C
Chain Of Recursive Thoughts (cort) Mcp Server

Chain Of Recursive Thoughts (cort) Mcp Server

本地服务
pypi.orgAI 与智能体576 周前更新

关于 Chain Of Recursive Thoughts (cort) Mcp Server

CoRT MCP Server 将 Chain-of-Recursive-Thoughts 方法提供给 MCP 客户端,通过迭代生成并评估备选回答。它支持单模型和混合 LLM 推理,并提供简洁输出或回答历史详情等工具。

主要功能

  1. 01迭代生成并评估备选回答
  2. 02跨提供商混合 LLM 推理
  3. 03简洁、详情及混合 LLM 工具
  4. 04包含推理说明的增强评估提示词

适用场景

  1. 01比较提示词对应的候选回答
  2. 02使用多个 LLM 探索备选方案

MCP 相关

它向 MCP 客户端提供 CoRT 思考工具,包括简洁、详情、混合 LLM 和新评估版本。模型调用使用 OpenRouter 和 OpenAI API 密钥。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"cort": {
"command": "uvx",
"args": [
"cort-mcp"
],
"env": {
"OPENAI_API_KEY": "<OPENAI_API_KEY>",
"OPENROUTER_API_KEY": "<OPENROUTER_API_KEY>"
}
}
}
}
启动命令uvx cort-mcp
需要配置的环境变量
OPENAI_API_KEY密钥
OPENROUTER_API_KEY密钥

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypicort-mcp

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

CoRT MCP 服务

smithery badge

这是一个 Chain-of-Recursive-Thoughts(CORT)MCP 服务。 原始项目如下,非常感谢原作者的工作。

原始项目:PhialsBasement/Chain-of-Recursive-Thoughts:我让 AI 不断与自己辩论,从而让它进行更深入的思考。效果好得惊人。
https://github.com/PhialsBasement/Chain-of-Recursive-Thoughts

发布说明

0.2.0 更新大模型列表 0.1.0 首次发布

功能

  • 通过 MCP 服务提供 CoRT 方法,让 AI 不断与自己辩论,从而进行更深入的思考。效果好得惊人。

已验证

Roo code / Cline

MCP 主机配置

建议将超时设置为 300 秒。(有时可能需要比预期更长的时间) 需要 OPENROUTER_API_KEY。https://openrouter.ai/

示例:禁用日志
"CoRT-chain-of-recursive-thinking": {
  "command": "pipx",
  "args": ["run", "cort-mcp", "--log=off"],
  "env": {
    "OPENAI_API_KEY": "{apikey}",
    "OPENROUTER_API_KEY": "{apikey}"
  }
}
示例:启用日志(需要绝对日志文件路径)
"CoRT-chain-of-recursive-thinking": {
  "command": "pipx",
  "args": ["run", "cort-mcp", "--log=on", "--logfile=/workspace/logs/cort-mcp.log"],
  "env": {
    "OPENAI_API_KEY": "{apikey}",
    "OPENROUTER_API_KEY": "{apikey}"
  }
}
  • --log=off:禁用所有日志(不写入任何日志)
  • --log=on --logfile=/absolute/path/to/logfile.log:启用日志并将其写入指定的绝对路径
  • 启用日志时,必须提供这两个参数。若缺少任一参数、路径不是绝对路径,或提供了无效值,服务将报错退出。

注意:

  • 启用日志时,日志只会写入指定的绝对路径。使用相对路径或省略 --logfile 都会导致错误。
  • 禁用日志时,不会输出任何日志。
  • 如果缺少必需参数或参数无效,服务将无法启动并打印错误消息。
  • MCP 服务进程必须能够访问并写入日志文件。
  • 如果无法运行此服务,可能是因为缓存了较旧版本的 cort-mcp。请尝试使用以下设置运行最新版本的 cort-mcp(将 x.y.z 替换为最新版本)。
"CoRT-chain-of-recursive-thinking": {
  "command": "pipx",
  "args": ["run", "cort-mcp==x.y.z", "--log=off"],
  "env": {
    "OPENAI_API_KEY": "{apikey}",
    "OPENROUTER_API_KEY": "{apikey}"
  }
}

可用工具

  • {toolname}.simple 不提供详情,只输出最终选定的备选方案。
  • {toolname}.details 包含大模型响应历史记录的详情。
  • {toolname}.mixed.llm 多大模型推理。
  • {toolname}.neweval 新的评估提示词。

请查看以下详情。

什么是 CoRT?

flowchart TB
    Start[User query] --> DetermineRounds[AI determine thinking rounds]
    DetermineRounds -->|determine_thinking_rounds 1-5 rounds| InitialResponse[Initial response\ntemperature=0.7]

    InitialResponse --> Round1[Starting round1]

    subgraph "Round 1"
        Round1 --> R1A1[Create alternative 1 temperature=0.7]
        Round1 --> R1A2[Create alternative 2 temperature=0.8]
        Round1 --> R1A3[Create alternative 3 temperature=0.9]

        InitialResponse & R1A1 & R1A2 & R1A3 --> R1Eval[Evaluation temperature=0.2]
        R1Eval --> R1Best[Round 1 best response]
    end

    R1Best --> Round2[Starting round2]

    subgraph "Round 2"
        Round2 --> R2A1[Create alternative 1 temperature=0.7]
        Round2 --> R2A2[Create alternative 2 temperature=0.8]
        Round2 --> R2A3[Create alternative 3 temperature=0.9]

        R1Best & R2A1 & R2A2 & R2A3 --> R2Eval[Evaluation temperature=0.2]
        R2Eval --> R2Best[Round 2 best response]
    end

    R2Best --> Remaining[Remaining rounds Repeat the same process]
    Remaining --> FinalBest[Final round best response]

    FinalBest --> FinalResponse[Final response]

相较于原版的主要增强

CoRT 方法在原版基础上进行了多项增强。

  1. 多大模型推理:每个备选方案都由不同的大模型(模型 + 提供方)随机生成。
  2. 评估增强:更新了提示词评估,添加了一个要求 AI 解释推理过程的提示词。(可通过工具使用原始提示词)
多大模型推理

概述: 这是一个新工具,在传统 CoRT 思考流程中加入了“为每个备选方案随机选择不同大模型(模型 + 提供方)”的探索策略。 这能让你充分利用不同模型的知识和想法,并从更多选项中选出最佳方案。

  • 此功能可通过 mixed llm 工具使用。
大模型列表
  • 为了提供更好的用户体验,选择了速度更快、资源占用更低的模型。
MIXED_LLM_LIST = [
    {"provider": "openai", "model": "gpt-4.1-nano"},
    {"provider": "openrouter", "model": "meta-llama/llama-4-scout:free"},
    {"provider": "openrouter", "model": "google/gemini-2.0-flash-exp:free"},
    {"provider": "openrouter", "model": "mistralai/mistral-small-3.1-24b-instruct:free"},
    {"provider": "openrouter", "model": "meta-llama/llama-3.2-3b-instruct:free"},
    {"provider": "openrouter", "model": "thudm/glm-4-9b:free"},
]
mixed LLM 工具的处理流程
  • 为每个备选方案从上述列表中随机选择一个大模型(模型 + 提供方)
  • 始终在日志中记录每个生成的备选方案“使用了哪个模型和提供方”
  • 在详情模式下,在响应历史信息中明确包含“每个备选方案使用的模型和提供方”

评估增强

概述: 改进了评估提示词,使其更加丰富。(可通过工具使用原始提示词) 使用 {toolname}.neweval 提示词,要求 AI 解释其推理过程。

原始提示词
f"""Original message: {prompt}
Evaluate these responses and choose the best one:
Current best: {current_best}
Alternatives:
{chr(10).join([f"{i+1}. {alt}" for i, alt in enumerate(alternatives)])}
Which response best addresses the original message? Consider accuracy, clarity, and completeness.
First, respond with ONLY 'current' or a number (1-{len(alternatives)}).
Then on a new line, explain your choice in one sentence."""
增强后的提示词
f""" Original message: {prompt}
You are an expert evaluator tasked with selecting the response that best fulfills the user's true needs, considering multiple perspectives.
Current best: {current_best}
Alternatives: {chr(10).join([f"{i+1}. {alt}" for i, alt in enumerate(alternatives)])}
Please follow this evaluation process:
Intent Analysis: What is the user REALLY seeking? What underlying needs might be present beyond the surface question?
Context Consideration: What possible situations or backgrounds could this question arise from?
Diversity Assessment: Does the response consider different viewpoints or possible interpretations?
Practicality Evaluation: How useful would the response be in the user's real-world context?
Consistency Check: Is the response internally consistent and logically coherent?
For each response (including the current best):
Does it solve the user's TRUE problem?
Does it balance accuracy and usefulness?
Does it avoid unnecessary assumptions or biases?
Is it flexible enough to apply in various contexts or situations?
Does it account for exceptions or special cases?
After completing your evaluation:
Indicate your choice with ONLY 'current' or a number (1-{len(alternatives)}).
On the next line, explain specifically why this response best meets the user's true needs. """
参数规范与回退处理

此 API 会根据指定的 provider 和 model 参数确定实际使用的模型,并在出错时进行回退处理。

  1. Provider(provider)解析

    • 未指定时:使用默认 provider openrouter。
    • 指定了无效值时(除 openai 或 openrouter 之外):回退到默认 provider openrouter。
  2. 模型(model)解析

    • 未指定时:
      • 如果解析后的 provider 是 openrouter:使用默认模型 mistralai/mistral-small-3.1-24b-instruct:free。
      • 如果解析后的 provider 是 openai:使用默认 OpenAI 模型。
    • 已指定时(且 provider 有效):
      • 使用指定的模型名称,并搭配解析后的 provider。
      • 重要:此阶段不会验证指定的模型名称是否确实存在于该 provider。
  3. API 调用与错误回退

    • 首先使用上述规则解析出的 provider 和模型组合尝试调用 API。
    • 如果 API 调用期间发生错误(例如,指定的模型在该 provider 中不存在、API 密钥身份验证错误等):
      • 条件 1:首次尝试调用所用的 provider 不是 openai。
      • 条件 2:系统中已设置环境变量 OPENAI_API_KEY。
      • 如果同时满足上述两个条件,系统会自动使用 openai provider 的默认模型重试(即回退处理)。
      • 如果不满足其中任一条件或两者都不满足(例如,首次尝试使用的是 openai,或未设置 OPENAI_API_KEY),则会将初始错误作为最终结果返回,并且不会进行此类回退。

环境变量说明:

  • 使用 openrouter 需要设置 OPENROUTER_API_KEY。
  • 使用 openai 或启用上述回退功能需要设置 OPENAI_API_KEY。
  • 如果未设置相应的 API 密钥,API 调用将失败(是否也会导致回退到 OpenAI 失败,取决于回退条件)。

许可证

MIT

尽情发挥吧

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。