Skip to main content
Glama

dev-loop-mcp

一个运行 AI 驱动的 TDD 开发循环的 MCP (Model Context Protocol) 服务器。它将开发循环状态机通用化,通过简单的配置文件即可适用于任何项目。

功能概述

提供两种循环类型——两者共享相同的 TDD 流水线;区别仅在于任务的生成方式:

flowchart LR
    subgraph start_loop["start_loop (feature)"]
        direction LR
        A("description<br/>or tasks") --> B["DECOMPOSE<br/>AI breaks into tasks"]
        B --> C[/"tasks"/]
    end

    subgraph start_debug_loop["start_debug_loop (bug)"]
        direction LR
        D("symptom<br/>+ context files") --> E["DIAGNOSE<br/>AI ranks hypotheses"]
        E --> F[/"tasks"/]
    end

    C --> Pipeline["TDD pipeline"]
    F --> Pipeline

    subgraph Pipeline["Shared TDD pipeline"]
        direction LR
        I[INIT] --> T[TDD_LOOP<br/>per task]
        T --> Bu[BUILD]
        Bu --> De[DEPLOY<br/>optional]
        De --> It[INTEG_TEST<br/>optional]
        It -->|pass| Qr[QUALITY_REVIEW]
        It -->|fail| If[INTEG_FIX<br/>up to 5×]
        If --> Qr
        Qr --> Ct[CLEAN_TREE<br/>CHECK]
        Ct --> Pr[PUSH_AND_PR]
        Pr --> Done(["✓ DONE<br/>PR opened"])
    end

完整状态机

flowchart TD
    start_loop --> INIT
    start_debug_loop -->|"DIAGNOSE:<br/>ranked hypotheses → tasks"| INIT

    INIT -->|"pre-loaded tasks"| TDD_LOOP
    INIT -->|"description only"| DECOMPOSE
    DECOMPOSE -->|"AI → Task[]"| TDD_LOOP

    TDD_LOOP -->|"task done, more remain"| TDD_LOOP
    TDD_LOOP -->|"all tasks done"| BUILD
    TDD_LOOP -->|"task failed"| FAILED

    BUILD -->|pass| DEPLOY
    BUILD -->|fail| FAILED

    DEPLOY -->|"pass / skipped"| INTEG_TEST
    DEPLOY -->|fail| FAILED

    INTEG_TEST -->|"pass / skipped"| QUALITY_REVIEW
    INTEG_TEST -->|fail| INTEG_FIX

    INTEG_FIX -->|fixed| QUALITY_REVIEW
    INTEG_FIX -->|"still failing<br/>(retry, max 5)"| INTEG_FIX
    INTEG_FIX -->|"5 attempts exhausted"| FAILED

    QUALITY_REVIEW --> CLEAN_TREE_CHECK
    CLEAN_TREE_CHECK --> PUSH_AND_PR
    PUSH_AND_PR --> DONE

    DONE(["✓ DONE"])
    FAILED(["✗ FAILED"])

    style DONE fill:#22c55e,color:#fff
    style FAILED fill:#ef4444,color:#fff
    style start_loop fill:#6366f1,color:#fff
    style start_debug_loop fill:#f59e0b,color:#fff

任务级 TDD 循环

TDD_LOOP 中的每个任务都会运行此内部循环(最多 5 次编码迭代):

flowchart LR
    A["Write scenarios<br/>scenarios/scenarios-*.md"] --> B["Write failing tests<br/>*.test.ts"]
    B --> C{"Tests<br/>fail?"}
    C -->|"no — tester error"| Z["✗ task failed"]
    C -->|yes| D["Implement"]
    D --> E{"Tests<br/>pass?"}
    E -->|yes| F["✓ commit & next task"]
    E -->|"no (retry)"| D

阶段参考:

  • INIT: 创建 git 分支

  • DECOMPOSE: AI 将描述转换为 Task[]

  • DIAGNOSE: (仅限调试循环) AI 读取症状和上下文文件,并生成按优先级排序的根本原因假设作为 Task[]

  • TDD_LOOP: 针对每个任务:场景 → 失败测试 → 实现(每个任务最多 5 次编码迭代)

  • BUILD: 运行 buildCommand

  • DEPLOY: 运行 deployCommand — 若未配置则跳过

  • INTEG_TEST: 运行 integTestCommand — 若未配置则跳过

  • INTEG_FIX: AI 诊断并修复集成测试失败(最多 5 次尝试)

  • QUALITY_REVIEW: AI 审查完整的分支差异并应用质量修复

  • CLEAN_TREE_CHECK: 自动提交所有未提交的文件

  • PUSH_AND_PR: 推送分支并打开 GitHub PR

安装

npm install -g dev-loop-mcp

或者通过 npx 使用:

npx dev-loop-mcp

配置

在项目根目录下创建 dev-loop.config.json

{
  "buildCommand": "npm run build",
  "testCommand": "npm test",
  "deployCommand": "npm run deploy",
  "integTestCommand": "npm run test:integ",
  "branchPrefix": "claude/",
  "model": "claude-sonnet-4-6"
}

所有字段均为可选。默认值:

  • buildCommand: "npm run build"

  • testCommand: "npm test"

  • deployCommand: 不存在(跳过 DEPLOY 阶段)

  • integTestCommand: 不存在(跳过 INTEG_TEST 阶段)

  • branchPrefix: "claude/"

  • model: "claude-sonnet-4-6"

环境变量

变量

必需

描述

ANTHROPIC_API_KEY

您的 Anthropic API 密钥

DEV_LOOP_ROOT

项目根目录(默认为 cwd

MCP 设置

添加到您的 MCP 客户端配置中(例如 Claude Desktop 的 claude_desktop_config.json):

{
  "mcpServers": {
    "dev-loop": {
      "command": "dev-loop-mcp",
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-...",
        "DEV_LOOP_ROOT": "/path/to/your/project"
      }
    }
  }
}

可用工具

start_debug_loop

根据症状描述启动调试循环。AI 将根本原因诊断为按优先级排序的 TDD 任务,然后针对每个假设运行标准 TDD 流水线,并打开一个包含完整诊断报告的 PR。

{
  "symptom": "read_website returns failure on most real URLs",
  "context_files": ["src/tools/read-website.ts", "src/http/client.ts"]
}

参数:

  • symptom (必需) — 对观察到的错误或故障的自然语言描述

  • context_files (可选) — AI 在诊断时应读取的源文件相对路径

DIAGNOSE 步骤在标准 TDD 流水线之前运行(参见上述状态机)。PR 正文包含症状、识别出的根本原因以及修复内容。

分支命名为 <branchPrefix>debug/<symptom-slug>

start_loop

启动一个新的开发循环。

{
  "description": "Add email validation to the user registration flow",
  "branch": "claude/email-validation"
}

或者使用预先分解的任务:

{
  "tasks": [
    {
      "id": 1,
      "title": "Add email validator function",
      "scope": "src/utils/email.ts",
      "acceptance": "validateEmail returns true for valid emails and false for invalid ones"
    }
  ],
  "branch": "claude/email-validation"
}

resume_loop

恢复中断的循环:

{}

loop_status

检查当前循环状态:

{}

作为库使用

import { runLoop, loadConfig, RealShellAdapter, AnthropicDevWorker } from "dev-loop-mcp";
import Anthropic from "@anthropic-ai/sdk";

const config = await loadConfig("/path/to/project");
const client = new Anthropic();
const shell = new RealShellAdapter();
const aiWorker = new AnthropicDevWorker(client, config.model, shell);

const finalState = await runLoop(initialState, {
  shell,
  aiWorker,
  stateFilePath: "/path/to/project/.loop-state.json",
  repoRoot: "/path/to/project",
  config,
});
-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/soynog/dev-loop-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server