Skip to main content
Glama
boranesn
by boranesn

devflow-mcp

一个生产就绪的 Model Context Protocol 服务器,为 AI 助手提供深入的 GitHub 开发者工具——PR 分析、代码审查、变更日志生成、依赖审计、提交摘要和重构建议。

功能特性

  • 6 个 MCP 工具,涵盖完整的开发者工作流

  • 启发式分析 —— 无需外部 LLM 调用,快速且确定

  • OSV.dev 集成,获取真实的漏洞数据(npm 和 PyPI)

  • 带 TTL 的 LRU 缓存,最大限度减少 GitHub API 调用

  • 令牌桶限流器,确保在 GitHub 的限制范围内运行

  • 零 any —— 全程严格的 TypeScript

  • ≥80% 测试覆盖率,使用 MSW 模拟 HTTP

Related MCP server: GitHub MCP Agent Server

要求

  • Node.js 18+

  • 具有 repo 作用域的 GitHub 个人访问令牌

安装

npm install -g devflow-mcp

或者直接使用 npx 运行:

npx devflow-mcp

或者克隆并构建:

git clone https://github.com/yourorg/devflow-mcp
cd devflow-mcp
npm install
npm run build

Claude Desktop 配置

添加到你的 claude_desktop_config.json 中:

{
  "mcpServers": {
    "devflow": {
      "command": "npx",
      "args": ["devflow-mcp"],
      "env": {
        "GITHUB_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

工具

analyze_pr

分析 GitHub 拉取请求的风险、安全发现和合并就绪情况。

参数:

名称

类型

必需

描述

owner

string

是

仓库所有者

repo

string

是

仓库名称

pr_number

number

是

拉取请求编号

focus

string[]

否

限制分析范围:security、performance、logic、style

返回: risk_score (0-100), risk_level, findings[], change_summary, merge_recommendation


review_code

审查代码片段的质量、安全问题和改进机会。

参数:

名称

类型

必需

描述

code

string

是

要审查的源代码

language

string

是

编程语言

context

string

否

关于代码功能的额外上下文

返回: overall_score (1-10), issues[] (包含严重程度和修复建议), positive_observations[], refactor_priority


generate_changelog

根据提交历史生成两个 Git 引用之间的变更日志。

参数:

名称

类型

必需

描述

owner

string

是

仓库所有者

repo

string

是

仓库名称

from_ref

string

是

基础引用 (标签、SHA、分支)

to_ref

string

是

目标引用

format

string

否

markdown (默认), json, plain

group_by

string

否

type (默认), author, date

include_authors

boolean

否

包含作者姓名 (默认: true)

返回: changelog 字符串, commit_count, 每个类别的 stats, breaking_changes[]


audit_dependencies

根据 OSV 漏洞数据库审计项目依赖项。

参数:

名称

类型

必需

描述

owner

string

是

仓库所有者

repo

string

是

仓库名称

ecosystem

string

是

npm、pypi 或 auto

severity_threshold

string

否

报告的最低严重程度:low (默认), moderate, high, critical

返回: vulnerabilities[] (包含 CVE ID、修复版本和修复命令); audit_passed, 每个严重级别的 stats, osv_query_timestamp


summarize_commits

将分支上的近期提交总结为人类可读的摘要。

参数:

名称

类型

必需

描述

owner

string

是

仓库所有者

repo

string

是

仓库名称

branch

string

否

分支名称 (默认: 仓库默认分支)

since

string

否

ISO 日期或相对时间 (7d, 24h, 2w, 1m)

limit

number

否

最大提交数 (默认: 50)

output_style

string

否

digest (默认), standup, detailed

返回: summary 字符串, categories (功能/修复/文档/重构/杂务/其他), authors[], commit_count


suggest_refactor

分析代码的重构机会,并按影响与工作量比率进行排序。

参数:

名称

类型

必需

描述

code

string

是

要分析的源代码

language

string

是

编程语言

goals

string[]

否

关注领域:readability、performance、testability、maintainability

返回: suggestions[] (包含理由和工作量估算), priority_order[], original_complexity_score

开发

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Type-check and build
npm run build

# Lint
npm run lint

# Format
npm run format

# Start the server (after build)
npm start

项目结构

src/
  index.ts              # Entry point
  server.ts             # MCP server registration
  tools/                # Tool handlers (one per tool)
  github/               # GitHub API clients
  lib/                  # Shared utilities
    cache.ts            # LRU cache with TTL
    rate-limiter.ts     # Token-bucket rate limiter
    commit-parser.ts    # Conventional commit parser
    diff-parser.ts      # Git diff parser
    risk-scorer.ts      # PR risk scoring heuristics
    errors.ts           # Typed MCP errors
  providers/
    osv.ts              # OSV.dev vulnerability API
tests/
  integration/          # Full MCP server tests via InMemoryTransport
  tools/                # Unit tests per tool handler
  lib/                  # Unit tests for utilities

测试策略

  • 单元测试:每个工具处理程序和库都使用 vi.mock 进行模拟

  • 集成测试:通过 InMemoryTransport 进行完整的 MCP 客户端↔服务器往返测试,HTTP 请求由 MSW 拦截

  • HTTP 模拟:MSW v2 (msw/node) — 测试中无真实网络调用

  • 覆盖率:要求 ≥80% 分支覆盖率 (npm run test:coverage)

贡献

  1. Fork 本仓库

  2. 创建功能分支

  3. 为新行为添加测试

  4. 确保 npm run build && npm run test:coverage && npm run lint 全部通过

  5. 提交拉取请求

许可证

MIT

Related MCP Connectors

Related MCP Servers