AI编码代理自救服务

一个为AI编码代理提供结构化思维协议以自主解决执行卡顿问题的MCP服务器服务。

  • by askman-dev
  • TypeScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 askman-dev/agent-never-give-up-mcp

使用说明

代理商永不放弃MCP

这是一个MCP服务器,充当AI编码代理的“逃生指南”。

它提供结构化思维协议,帮助代理在没有人类帮助的情况下摆脱困境。

下图说明了代理何时应该调用此服务器以及它收到的回报:

graph TD
    %% 1. The Normal Loop
    UserLoop["<b>User Query & Agent Loop</b><br/>(Claude Code / Windsurf / Cursor)<br/>Agent executing tasks..."]

    %% 2. The Problem (Triggers)
    subgraph Triggers ["Agent Gets Stuck (Trigger State)"]
        direction TB
        S1["Circular Reasoning"]
        S2["Bug Fix Fails"]
        S3["Missing Info"]
        S4["Analysis Paralysis"]
        S5["Unclear 'Done' State"]
    end

    %% Flow: Loop -> Stuck
    UserLoop -.->|"⚠️ Detects Issue<br/>(Inner Loop Stall)"| Triggers

    %% 3. The Solution (MCP Call)
    subgraph MCP ["Agent Never Give Up MCP"]
        direction TB
        T1(logic-is-too-complex)
        T2(bug-fix-always-failed)
        T3(missing-requirements)
        T4(analysis-too-long)
        T5(unclear-acceptance-criteria)
    end

    %% Mapping Triggers to Tools
    S1 -->|Call| T1
    S2 -->|Call| T2
    S3 -->|Call| T3
    S4 -->|Call| T4
    S5 -->|Call| T5

    %% 4. The Response
    MCP -->|Returns| R1["<b>Metacognitive Protocol</b><br/>Structured markdown to:<br/>1. Re-anchor goal<br/>2. Summarize failures<br/>3. Propose NEW strategy"]

    %% 5. The Outcome
    R1 --> Result["<b>Autonomous Recovery</b><br/>Agent unblocks itself &<br/>resumes execution<br/>(No Human Hand-off)"]

    %% Cycle back to loop
    Result -.->|"Resumes Loop"| UserLoop

    %% Styling
    classDef loop fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
    classDef trigger fill:#ffebee,stroke:#b71c1c,stroke-width:2px;
    classDef tool fill:#fff3e0,stroke:#e65100,stroke-width:2px;
    classDef response fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    
    class UserLoop loop;
    class S1,S2,S3,S4,S5 trigger;
    class T1,T2,T3,T4,T5 tool;
    class R1,Result response;

特性

  • 远程MCP服务器 在 /mcp 端点(符合流式HTTP规范)
  • 两层场景组织:
    • 核心场景 (自动注册为直接MCP工具):
      • logic-is-too-complex -用于循环推理或过于复杂的逻辑
      • bug-fix-always-failed –用于重复失败的错误修复尝试
      • missing-requirements –要求不明确或缺失
      • lost-main-objective –当当前的行动与最初的目标脱节时
      • scope-creep-during-task –当更改扩展到原始任务范围之外时
      • long-goal-partially-done –用于忘记剩余工作的多步骤任务
      • strategy-not-working –当相同的方法反复失败时
    • 扩展场景 (发现通过 list_scenarios,通过访问 get_prompt):
      • analysis-too-long –分析时间过长
      • unclear-acceptance-criteria –对于未定义的验收标准
      • wrong-level-of-detail –在错误的抽象级别工作
      • constraints-cant-all-be-met –用于冲突的要求或约束
      • blocked-by-environment-limits –环境阻断与逻辑问题
  • 发现工具:
    • list_scenarios –列出所有场景及其级别(核心/扩展)
    • get_prompt –访问任何场景(核心或扩展)
  • 双模式支持:每个工具都支持 static 和 sampling 模式
  • 社区贡献的提示 通过markdown文件
  • 公共和无身份验证 (v0)
  • Cloudflare Workers部署

配置

自从 agent-never-give-up 是云托管的MCP服务器,不需要本地安装。只需将服务器配置添加到您首选的AI工具中即可。

在游标中安装

  1. 打开 光标设置 > 主控程序.
  2. 点击 +添加新的全局MCP服务器.
  3. 使用以下配置(或编辑您的 ~/.cursor/mcp.json 直接文件):
{
  "mcpServers": {
    "agent-never-give-up": {
      "type": "http",
      "url": "https://agent-never-give-up-mcp.askman.dev/mcp",
      "note": "A 'Swiss Army knife' toolset to help agents recover from getting stuck"
    }
  }
}

在Claude桌面中安装

要为Claude Desktop配置服务器,请编辑位于以下位置的配置文件:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 窗户: %APPDATA%\Claude\claude_desktop_config.json

将以下条目添加到 mcpServers 对象:

{
  "mcpServers": {
    "agent-never-give-up": {
      "type": "http",
      "url": "https://agent-never-give-up-mcp.askman.dev/mcp"
    }
  }
}

安装在Cline中

  1. 打开 克莱恩 然后单击 MCP服务器 图标(☰)。
  2. 选择 远程服务器 选项卡(如果可用)或单击 配置MCP服务器.
  3. 编辑 cline_mcp_settings.json 文件包括:
{
  "mcpServers": {
    "agent-never-give-up": {
      "type": "http",
      "url": "https://agent-never-give-up-mcp.askman.dev/mcp",
      "note": "A comprehensive suite of tools designed to keep agents persistent and unstuck"
    }
  }
}

安装在Windsurf中

  1. 打开 帆板运动.
  2. 首选 文件 > 设置 > 配置MCP服务器 (或编辑 ~/.codeium/windsurf/mcp_config.json).
  3. 添加服务器配置:
{
  "mcpServers": {
    "agent-never-give-up": {
      "type": "http",
      "url": "https://agent-never-give-up-mcp.askman.dev/mcp"
    }
  }
}

发展

要为此项目做出贡献或运行本地实例,请执行以下操作:

# Install dependencies
npm install

本地服务器将在 http://localhost:8787/mcp.

贡献提示

提示分为两层 prompts/ 目录:

prompts/
├── core/                           # Core scenarios (auto-registered as tools)
│   ├── logic-is-too-complex/
│   │   └── tool.md
│   ├── bug-fix-always-failed/
│   │   └── tool.md
│   └── missing-requirements/
│       └── tool.md
└── extended/                       # Extended scenarios (via list_scenarios + get_prompt)
    ├── analysis-too-long/
    │   └── tool.md
    └── unclear-acceptance-criteria/
        └── tool.md

提示文件格式

每 tool.md 该文件遵循简单的markdown格式,具有YAML frontmatter和单个协议体:

---
name: scenario_name
title: "Scenario Title"
description: "When / why the agent should call this tool, from the agent's perspective"
---

When you notice [the trigger condition], follow this exact protocol step by step.

## 1. First step title

1. Action item one.
2. Action item two.
3. Action item three.

Keep it concrete.

## 2. Second step title

...

## 3. Third step title

...

关键原则:

  • 这 description 解释 当 使用工具(触发条件)
  • 身体是一个 对单个协议 带有编号的部分
  • 每个部分有2-6个具体步骤
  • 专注于 如何思考,不是特定于域的详细信息
  • 没有系统提示/用户提示模板部分,只有一个可操作的协议

看 prompts/AGENTS.md 获取撰写有效提示的详细指导。

添加新场景

场景是从中自动发现的 prompts/ 树和生成的文件 src/prompts/generated-scenarios.ts 和 src/types/generated-scenarios.ts确实如此 不 需要手动编辑TypeScript文件——只需添加提示并重新生成。

核心场景 (自动注册为工具):

  1. 创建新目录: prompts/core/{scenario_name}/ (必须匹配 /^[a-z0-9]+(-[a-z0-9]+)*$/).
  2. 添加a tool.md 按照上述格式的文件。
  3. 跑 npm run generate:scenarios 以重新生成类型和发现数据。

扩展场景 (可通过以下方式访问 get_prompt):

  1. 创建新目录: prompts/extended/{scenario_name}/ (命名规则与上述相同)。
  2. 添加a tool.md 按照上述格式的文件。
  3. 跑 npm run generate:scenarios 以重新生成类型和发现数据。

部署

# Deploy to Cloudflare Workers
npm run deploy

部署后,您的MCP端点将是: https://agent-never-give-up-mcp.<account>.workers.dev/mcp

许可证

麻省理工学院