开发环境副本
一个生产就绪的模型上下文协议(MCP)服务器,为跨平台开发工作流提供智能环境检测和命令语法帮助。
使命: 此MCP服务器通过自动向AI代理和工具提供丰富的上下文感知环境信息,确保用户对其提示有无缝的体验。
______________________________________________________________________
](https://badge.fury.io/js/dev-env-copilot) ](https://pypi.org/project/dev-env-copilot/) ](https://hub.docker.com/r/0nilinkz/dev-env-copilot)  
✨ 特性
- 🔍 自动环境检测 -Windows、Linux和macOS
- 🐚 Shell感知命令 -PowerShell、Bash、Zsh语法优化
- 🤖 VS代码内部人员MCP集成 -与GitHub Copilot无缝集成
- 🌐 交叉平台的 -适用于您开发的任何地方
- 📦 多种安装方式 -NPM、PyPI、Docker Hub
- 🔧 可扩展 -易于定制和扩展
- 🖥️ 架构感知 -始终检测并报告系统架构
- 🚀 生产就绪 -全面的测试覆盖率和自动化CI/CD
🚀 快速开始
NPM(推荐)
# Install globally
npm install -g dev-env-copilot
# Or use without installing
npx dev-env-copilotPython/PyPI
# Install from PyPI
pip install dev-env-copilot
# Run the server
python -m dev_environment_mcp.serverDocker(最简单)
# Run from Docker Hub (no installation needed)
docker run -i 0nilinkz/dev-env-copilot
# Or from GitHub Container Registry
docker run -i ghcr.io/yourusername/dev-env-copilot
# Test with a simple MCP request
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}' | docker run -i 0nilinkz/dev-env-copilot🔧 VS代码内部人员集成
MCP服务器设置(推荐)
添加到您的 VS代码内部人员 MCP配置文件:
视窗: %APPDATA%\Code - Insiders\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json macOS: ~/Library/Application Support/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json Linux: ~/.config/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
{
"mcpServers": {
"dev-environment": {
"command": "npx",
"args": ["dev-env-copilot"]
}
}
}看 VSCODE_INSIDERS_MCP_SETUP.md 有关完整的设置说明。
替代集成方法
方法一:Docker集成
{
"mcpServers": {
"dev-env-copilot-docker": {
"command": "docker",
"args": [
"run", "--rm", "--interactive",
"0nilinkz/dev-env-copilot"
]
}
}
}方法2:Python安装
{
"mcpServers": {
"dev-env-copilot-python": {
"command": "python",
"args": ["-m", "dev_environment_mcp.server"]
}
}
}Copilot使用示例
User: "Run the tests"
Copilot: (detects Windows PowerShell) "python -m pytest test/"
User: "Run the tests"
Copilot: (detects Linux) "python3 -m pytest test/"
User: "Set environment variable"
Copilot: (Windows) "$env:PYTHONPATH = 'c:\dev\project'"
Copilot: (Linux) "export PYTHONPATH=/home/user/project"📊 生产就绪
自动化CI/CD管道
- ✅ 多平台测试 -Ubuntu、Windows、macOS
- ✅ 多版本支持 -Python 3.8-3.12
- ✅ 自动发布 -NPM、PyPI、Docker Hub
- ✅ 基于阶段的部署 -部署前必须通过测试
- ✅ 独立部署 -每个注册表都单独部署
全面测试覆盖
# All installation methods verified
✅ Python/PyPI - Native execution
✅ NPM/Node.js - Cross-platform wrapper
✅ Docker - Multi-architecture builds
✅ MCP Protocol - Full protocol compliance看 DEPLOYMENT_SETUP.md 有关部署架构的详细信息。
可用工具
MCP服务器公开了这些工具:
detect_environment
检测当前操作系统、shell、硬件,并提供环境上下文。
参数:
format(string):输出格式-“json”、“summary”、“copilot”
get_command_syntax
为当前环境提供正确的命令语法。
参数:
operation(string):操作类型-“测试”、“构建”、“部署”、“安装”target(字符串,可选):目标环境-“本地”、“远程”、“pi”format(string):输出格式-“shell”、“exploration”、“examples”
format_command
为当前环境格式化通用命令。
参数:
command_template(string):带占位符的模板命令variables(object):模板中要替换的变量
get_project_context
分析当前项目结构并提供相关背景。
参数:
include_files(boolean):在输出中包含文件列表analyze_dependencies(布尔值):分析package.json/requirements.txt
配置
环境变量
DEV_ENV_MCP_CONFIG:自定义配置文件的路径DEV_ENV_MCP_LOG_LEVEL:日志记录级别(调试、信息、警告、错误)DEV_ENV_MCP_CACHE_TTL:缓存TTL用于环境检测(秒)
自定义配置
创建一个 dev-env-mcp.json 配置文件:
{
"detection": {
"cache_ttl": 300,
"enable_hardware_detection": true,
"custom_environments": {
"my-docker": {
"detect_command": "cat /.dockerenv",
"shell": "bash",
"python_cmd": "python3"
}
}
},
"commands": {
"custom_operations": {
"my-build": {
"windows": "msbuild /p:Configuration=Release",
"linux": "make build",
"macos": "xcodebuild -configuration Release"
}
}
}
}💻 命令行用法
独立命令
# Environment detection
npx dev-env-copilot detect-environment --format json
# Command syntax help
npx dev-env-copilot get-command-syntax --operation test --target local
npx dev-env-copilot get-command-syntax --operation deploy --target pi --format explanation
# MCP server modes
npx dev-env-copilot --mcp-mode --transport stdio
npx dev-env-copilot --mcp-mode --transport http --host 0.0.0.0 --port 9000高级配置
环境变量
DEV_ENV_MCP_LOG_LEVEL:设置日志记录级别(调试、信息、警告、错误)DEV_ENV_MCP_CACHE_TTL:环境检测的缓存持续时间(秒)DEV_ENV_MCP_CONFIG:自定义配置文件的路径
自定义配置文件
创建 ~/.config/dev-env-mcp/config.json:
{
"detection": {
"cache_ttl": 300,
"enable_hardware_detection": true,
"custom_project_roots": [
"/custom/dev/path",
"c:\\custom\\dev\\path"
]
},
"commands": {
"custom_operations": {
"my-test": {
"windows": "npm test",
"linux": "npm test",
"pi": "sudo npm test"
}
}
},
"logging": {
"level": "INFO",
"file": "~/.local/logs/dev-env-mcp.log"
}
}🔥 集成示例
GitHub Copilot 聊天助手
该服务器增强了GitHub Copilot的环境意识:
👤 User: "How do I run tests in this project?"
🤖 Copilot: Based on your Windows PowerShell environment and package.json, run:
npm test
👤 User: "Set up a Python virtual environment"
🤖 Copilot: For Windows PowerShell:
python -m venv venv
.\venv\Scripts\Activate.ps1终端命令生成
👤 User: "Install dependencies and start dev server"
🤖 Copilot: (detects Node.js project on Windows)
npm install && npm run dev
👤 User: "Same command but for production"
🤖 Copilot: npm ci && npm run build && npm start🛠 api参考
MCP工具
detect_environment
返回全面的环境信息。
答复:
{
"os": "windows",
"shell": "powershell",
"architecture": "x64",
"python_version": "3.11.0",
"node_version": "18.17.0",
"hardware": "desktop"
}get_command_syntax
参数:
operation:“测试”|“构建”|“部署”|“安装”|“运行”target:“本地”|“远程”|“pi”|“docker”format:“shell”|“解释”|“示例”
format_command
参数:
command_template:模板{variables}variables:具有替换值的对象
🐛 故障排除
常见问题
“找不到命令”错误
# Check NPM installation
npm list -g dev-env-copilot
# Reinstall if needed
npm install -g dev-env-copilot
# Check Python installation
pip show dev-env-copilotVS代码内部人员MCP集成不起作用
- 验证MCP配置文件的位置和格式
- 配置更改后重新启动VS代码内部人员
- 检查VS代码开发人员控制台是否有错误(
Help > Toggle Developer Tools) - 确保您使用的是VS Code Insider(而不是常规VS Code)
Docker权限问题
# Linux/macOS - add user to docker group
sudo usermod -aG docker $USER
newgrp docker
# Windows - ensure Docker Desktop is runningMCP协议问题
# Test MCP server directly
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}' | npx dev-env-copilot
# Test Python server
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}' | python -m dev_environment_mcp.server调试模式
启用详细日志记录:
# Set environment variable
export DEV_ENV_MCP_LOG_LEVEL=DEBUG
# Or create config file with debug logging
echo '{"logging": {"level": "DEBUG"}}' > ~/.config/dev-env-mcp/config.json📚 其他文件
- VS代码内部人员MCP设置 -完整的集成指南
- 部署设置 -CI/CD管道和工作流架构
- -容器部署指南
- -高级容器化设置
- 集成指南 -技术集成细节
- 分发摘要 -部署和发布概述
🏗️ 发展与贡献
快速开发设置
git clone https://github.com/yourusername/dev-env-copilot.git
cd dev-env-copilot
# Install dependencies
npm install
pip install -e .
# Run tests
python tests/test_mcp_proper.py
node bin/dev-env-copilot.js < echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{}}'工作流结构
我们的CI/CD使用GitHub Actions和现代 基于阶段的体系结构:
Test Stage (test-and-build.yml)
├── Multi-platform testing (Ubuntu, Windows, macOS)
├── Multi-version testing (Python 3.8-3.12)
└── MCP protocol compliance verification
Deploy Stage (on release)
├── deploy-pypi.yml → PyPI publishing
├── deploy-npm.yml → npm registry
└── docker-deploy.yml → Docker Hub + GHCR主要特点:
- 🔒 可靠的:未通过测试,不得部署
- 🔧 模块化:每种部署类型都是独立的
- ⚡ 高效:可重复使用的工作流程,无重复
- 🎯 灵活的:独立部署到特定注册表
贡献
我们欢迎捐款!该项目结构良好,包括:
- ✅ 全面的测试覆盖率
- ✅ 自动化质量检查
- ✅ 清晰的文件
- ✅ 现代开发工作流程
请打开问题或拉取请求以开始。
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
- Anthropic的模型上下文协议(MCP)
- 用于MCP集成的GitHub Copilot团队
- 跨平台开发社区
______________________________________________________________________
