mcpField
N
Neurodev Mcp

Neurodev Mcp

本地服务
github.com/ravikant1918开发工具051 周前更新

关于 Neurodev Mcp

Neurodev Mcp 是面向 Python 开发者的 MCP 服务,提供代码审查、pytest 测试生成与执行,以及代码格式化。它结合静态分析工具和 AST 分析,并支持 STDIO 与 SSE 传输。

主要功能

  1. 01多工具静态代码审查
  2. 02AST 驱动的 pytest 生成
  3. 03测试执行与覆盖率报告
  4. 04Black 和 autopep8 格式化
  5. 05支持 STDIO 与 SSE

适用场景

  1. 01检查 Python 代码质量与安全问题
  2. 02为函数和类生成边界测试
  3. 03运行测试并查看覆盖率
  4. 04将代码格式化为 PEP 8 风格

MCP 相关

该 MCP 服务向客户端提供代码审查、测试生成、测试执行和格式化工具。可使用 STDIO 连接本地客户端,也可通过 SSE 支持 Web 集成。

配置

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

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

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

详细介绍

🧠 NeuroDev MCP Server

智能代码分析、测试生成与执行

Python 3.8+ MCP License: MIT Tests

这是一款功能强大的模型上下文协议(MCP)服务,通过 AI 驱动的代码审查、智能测试生成和全面的测试执行,为你的 Python 开发工作流注入强大动力。

功能 • 安装 • 快速入门 • 工具 • 示例


✨ 功能

🔍 代码审查
  • 6 款强大的分析器
    • pylint - 代码质量与 PEP8
    • flake8 - 风格规范检查
    • mypy - 类型检查
    • bandit - 安全扫描
    • radon - 复杂度指标
    • AST - 自定义检查
  • 实时问题检测
  • 安全漏洞扫描
  • 复杂度与可维护性评分
🧪 测试生成
  • 智能 AST 分析
    • 自动生成 pytest 测试
    • 覆盖正常路径
    • 处理边界情况
    • 异常测试
    • 类型验证测试
  • 支持函数与类
  • 感知类型提示
▶️ 测试执行
  • 全面测试
    • 隔离环境
    • 覆盖率报告
    • 逐行分析
    • 超时保护
  • 详细的通过/失败结果
  • 性能指标
🎨 代码格式化
  • 自动格式化
    • black - 主张明确的代码风格
    • autopep8 - 符合 PEP8 规范
  • 可配置行长度
  • 统一的代码风格
  • 一条命令即可格式化

📦 安装

快速安装

```bash

# Clone the repository
git clone https://github.com/ravikant1918/neurodev-mcp.git
cd neurodev-mcp

# Create virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\\Scripts\\activate

# Install the package
pip install -e .
\`\`\`

### **Verify Installation**

\`\`\`bash
# Run tests (should show 15/15 passing)
python test_installation.py

# Test the server
python -m neurodev_mcp.server
\`\`\`

<details>
<summary><b>📁 Project Structure</b> (click to expand)</summary>

\`\`\`
neurodev-mcp/
├─ neurodev_mcp/              # 📦 Main package
│   ├─ __init__.py            # Package exports
│   ├─ server.py              # MCP server entry point
│   ├─ analyzers/             # 🔍 Code analysis
│   │   ├─ __init__.py
│   │   └─ code_analyzer.py   # Multi-tool static analysis
│   ├─ generators/            # 🧪 Test generation
│   │   ├─ __init__.py
│   │   └─ test_generator.py  # AST-based test creation
│   └─ executors/             # ▶️ Test execution
│       ├─ __init__.py
│       └─ test_executor.py   # Test running & formatting
├─ pyproject.toml             # Project configuration
├─ README.md                  # This file
├─ test_installation.py       # Installation validator
├─ examples.py                # Usage examples
└─ requirements.txt           # Dependencies

🚀 快速入门

步骤 1:配置 MCP 客户端
🖥️ Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "neurodev-mcp": {
      "command": "/absolute/path/to/neurodev-mcp/.venv/bin/python",
      "args": ["-m", "neurodev_mcp.server"]
    }
  }
}

💡 提示: 将 /absolute/path/to/neurodev-mcp 替换为你的实际路径

🔧 Cline (VSCode)

添加到 MCP 设置中:

{
  "neurodev-mcp": {
    "command": "python",
    "args": ["-m", "neurodev_mcp.server"]
  }
}
🐍 独立使用

直接运行服务:

# Using the module
python -m neurodev_mcp.server

# Or as a command (if installed)
neurodev-mcp
步骤 2:重启客户端

重启 Claude Desktop 或重新加载 VSCode,以加载服务。

步骤 3:开始使用!🎉

尝试向 AI 助手发送以下指令:

  • “检查这段 Python 代码是否存在问题”
  • “为此函数生成单元测试”
  • “运行这些测试并生成覆盖率报告”
  • “将这段代码格式化为符合 PEP8 规范”

🌐 传输选项

NeuroDev MCP 支持多种传输协议,以适用于不同场景:

STDIO(默认)- 本地 CLI

适用于使用 Claude Desktop 或 Cline 等 MCP 客户端进行本地开发:

# Default STDIO transport
neurodev-mcp

# Or explicitly specify STDIO
neurodev-mcp --transport stdio

配置(Claude Desktop):

{
  "mcpServers": {
    "neurodev-mcp": {
      "command": "neurodev-mcp",
      "args": ["--transport", "stdio"]
    }
  }
}
SSE(服务器发送事件)- Web 集成

适用于基于 Web 的集成和 HTTP 流式传输:

# Run with SSE on default port (8000)
neurodev-mcp --transport sse

# Custom host and port
neurodev-mcp --transport sse --host 0.0.0.0 --port 3000

端点:

  • SSE 流: http://localhost:8000/sse
  • 消息: http://localhost:8000/messages (POST)

Web 客户端示例:

const sse = new EventSource('http://localhost:8000/sse');

sse.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received:', data);
};

// Send message
fetch('http://localhost:8000/messages', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    method: 'tools/call',
    params: {
      name: 'code_review',
      arguments: { code: 'def test(): pass', analyzers: ['pylint'] }
    }
  })
});
传输方式对比
传输方式使用场景最适合
STDIO本地 CLI 客户端Claude Desktop、Cline、本地开发
SSEWeb 集成浏览器应用、webhook、远程客户端

🛠️ 可用工具

1. code_review

🔍 使用多种静态分析工具进行全面代码分析

输入:

{
  "code": "def calculate(x):\n    return x * 2",
  "analyzers": ["pylint", "flake8", "mypy", "bandit", "radon", "ast"]
}

输出:

  • 各分析器的详细问题报告
  • 安全漏洞
  • 复杂度指标
  • 代码质量评分
  • 逐行建议

2. generate_tests

🧪 使用 AST 分析智能生成 pytest 测试

输入:

{
  "code": "def add(a: int, b: int) -> int:\n    return a + b",
  "module_name": "calculator",
  "save": false
}

输出:

  • 完整的 pytest 测试套件
  • 多种测试用例(正常路径、边界情况、异常)
  • 类型验证测试
  • 可直接运行的测试代码

3. run_tests

▶️ 运行 pytest 测试并生成覆盖率报告

输入:

{
  "test_code": "def test_add():\n    assert add(1, 2) == 3",
  "source_code": "def add(a, b):\n    return a + b",
  "timeout": 30
}

输出:

  • 通过/失败状态
  • 覆盖率百分比
  • 行覆盖率详情
  • 执行时间
  • 详细的 stdout/stderr

4. format_code

🎨 将 Python 代码自动格式化为符合 PEP8 标准的样式

输入:

{
  "code": "def   messy(  x,y  ):\n        return x+y",
  "line_length": 88
}

输出:

  • 格式优美的代码
  • 符合 PEP8 标准
  • 风格一致
  • 变更检测

💡 使用示例

示例 1:完整的代码审查工作流
You: "Review this code for issues and security problems"

[paste code]

AI: [Uses code_review tool]
    → Finds 3 style issues
    → Detects 1 security vulnerability
    → Suggests complexity improvements
    
You: "Fix those issues and show me the updated code"

AI: [Provides fixed code with explanations]
示例 2:生成并运行测试
You: "Generate tests for this function and run them"

def divide(a: float, b: float) -> float:
    if b == 0:
        raise ValueError("Cannot divide by zero")
    return a / b

AI: [Uses generate_tests tool]
    → Creates 5 test cases
    → Includes edge cases (zero, negative numbers)
    → Tests exception handling
    
    [Uses run_tests tool]
    → 5/5 tests passing ✓
    → 100% code coverage
    → All edge cases handled
示例 3:代码格式化
You: "Format this messy code"

def   calculate(  x,y,z  ):
        result=x+y+z
        if result>10:
                    return   True
        return False

AI: [Uses format_code tool]
    → Applies black formatting
    → Returns clean, PEP8-compliant code

def calculate(x, y, z):
    result = x + y + z
    if result > 10:
        return True
    return False

📋 依赖要求

包版本用途
mcp≥0.9.0Model Context Protocol SDK
pylint≥3.0.0代码质量分析
flake8≥7.0.0样式检查
mypy≥1.7.0静态类型检查
bandit≥1.7.5安全扫描
radon≥6.0.1复杂度指标
black≥23.12.0代码格式化
autopep8≥2.0.4PEP8 格式化
pytest≥7.4.3测试框架
pytest-cov≥4.1.0覆盖率报告
pytest-timeout≥2.2.0测试超时

Python: 3.8 或更高版本


🧪 开发

运行测试
# Run installation tests
python test_installation.py

# Run examples
python examples.py

# Run pytest (if you add tests)
pytest
作为库使用
from neurodev_mcp import CodeAnalyzer, TestGenerator, TestExecutor
import asyncio

# Analyze code
code = "def hello(): print('world')"
result = asyncio.run(CodeAnalyzer.analyze_ast(code))

# Generate tests
tests = TestGenerator.generate_tests(code, "mymodule")

# Run tests
output = TestExecutor.run_tests(test_code, source_code)

❓ 故障排查

在 MCP 客户端中看不到服务?
  • ✅ 检查配置中的路径是否为绝对路径
  • ✅ 确保 Python 可执行文件路径正确
  • ✅ 完全重启 Claude Desktop 或 VSCode
  • ✅ 检查服务日志是否有错误
导入或模块错误?
# Reinstall the package
pip install -e .

# Verify installation
python -c "from neurodev_mcp import CodeAnalyzer; print('✓ OK')"

# Run installation tests
python test_installation.py
测试失败?
  • ✅ 确保已安装 Python 3.8+
  • ✅ 激活虚拟环境:source .venv/bin/activate
  • ✅ 重新安装依赖:pip install -e .
  • ✅ 运行:python test_installation.py 以进行诊断
性能问题?
  • 某些分析器(pylint、mypy)在大型文件上运行可能较慢
  • 使用指定的分析器:"analyzers": ["flake8", "ast"]
  • 为大型测试套件延长超时时间
  • 考虑缓存结果(未来功能)

🤝 参与贡献

欢迎贡献!参与方式如下:

  1. Fork 此仓库
  2. 创建功能分支:git checkout -b feature/amazing-feature
  3. 进行修改
  4. 运行测试:python test_installation.py
  5. 提交:git commit -m 'Add amazing feature'
  6. 推送:git push origin feature/amazing-feature
  7. 发起 Pull Request
未来改进
  • 添加更多分析器(pydocstyle、vulture)
  • 缓存结果以提升性能
  • 支持配置文件
  • Web 仪表板
  • 支持多种语言
  • CI/CD 流水线

📄 许可证

本项目采用 MIT License 授权,详情请参阅 LICENSE 文件。


🙏 致谢


📞 支持


准备好提升你的 Python 开发效率了吗! 🚀

由 NeuroDev Team 倾心打造 ❤️

⭐ 在 GitHub 上点星 • 🐛 报告 Bug • ✨ 请求新功能

评论

支持 Markdown

第一次接触 MCP?

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

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