一个提供智能上下文感知访问开发标准的模型上下文协议(MCP)服务器。该系统使大语言模型能够根据项目需求自动选择并应用适当的规范。
该项目进行了重大修复以恢复功能:
✅ 已解决问题:
✅ 核心系统状态:
⚠️ 需要验证的组件:
详见CLAUDE.md中的详细实施状态。
在5分钟内启动MCP标准服务器:
# 1. 克隆并设置(1分钟)
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
python -m venv venv && source venv/bin/activate
# 2. 安装核心依赖(2分钟)
pip install -e .
# 3. 验证CLI安装(30秒)
python -m src.cli.main --help
python -m src.cli.main status
# 4. 测试MCP服务器功能(1分钟)
python -m src # 应加载31项标准并初始化MCP服务器
# 5. 检查可用标准(30秒)
python -m src.cli.main cache --list # 查看缓存的标准
**🎉 成功!**您的MCP标准服务器现在正在运行。继续阅读完整安装以完成带有Redis缓存和Web UI的完整设置。
# 安装最新版本
pip install mcp-standards-server
# 或者安装特定功能集:
pip install "mcp-standards-server[full]" # 包括Web API的所有功能
pip install "mcp-standards-server[test]" # 仅测试工具
pip install "mcp-standards-server[dev]" # 开发工具
pip install "mcp-standards-server[performance]" # 性能监控工具
# 克隆仓库
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
# 创建并激活虚拟环境(推荐)
python -m venv venv
source venv/bin/activate # 在Windows上:venv\Scripts\activate
# 以开发模式安装
pip install -e .
# 或者安装特定功能集:
pip install -e ".[full]" # 包括Web API的所有功能
pip install -e ".[test]" # 仅测试工具
pip install -e ".[dev]" # 开发工具(代码检查、格式化)
pip install -e ".[performance]" # 性能监控工具
# 安装所有开发依赖
pip install -e ".[dev,test,performance,visualization,full]"
# 安装Redis(可选但推荐用于缓存)
# macOS:
brew install redis
brew services start redis
# Ubuntu/Debian:
sudo apt-get update
sudo apt-get install redis-server
sudo systemctl start redis-server
# Windows(使用WSL2):
wsl --install # 如果尚未安装
# 然后在WSL中按照Ubuntu的步骤操作
# 或使用Docker:
docker run -d -p 6379:6379 redis:alpine
# 运行基本测试以验证核心功能
pytest tests/unit/core/standards/test_rule_engine.py -v
# 检查项目是否正确安装
python -c "import src; print('安装成功')"
# 注意:CLI命令(mcp-standards)需要当前环境中安装了该包。如果看到导入错误,请确保您已经运行:
# pip install -e .
from pathlib import Path
from src.core.standards.rule_engine import RuleEngine
# 加载规则引擎
rules_path = Path("data/standards/meta/standard-selection-rules.json")
engine = RuleEngine(rules_path)
# 定义您的项目上下文
context = {
"project_type": "web_application",
"framework": "react",
"language": "javascript",
"requirements": ["accessibility", "performance"]
}
# 获取适用的标准
result = engine.evaluate(context)
print(f"选定的标准:{result['resolved_standards']}")
# 启动MCP服务器(用于工具集成的stdio模式)
python -m src
# 或使用CLI
mcp-standards --help
# 使用特定选项启动MCP服务器
mcp-standards serve --stdio # 直接工具集成
mcp-standards serve --port 3000 # HTTP服务器模式
mcp-standards serve --daemon # 作为后台服务运行
# 启动Web UI(需要单独设置)
cd web && ./start.sh
MCP服务器提供了以下工具供LLM集成:
# 示例:与MCP客户端一起使用
import mcp
# 连接到MCP服务器
async with mcp.Client("stdio://python -m src") as client:
# 获取项目的适用标准
result = await client.call_tool(
"get_applicable_standards",
context={
"project_type": "web_application",
"framework": "react",
"requirements": ["accessibility", "security"]
}
)
# 验证代码与标准的一致性
validation = await client.call_tool(
"validate_against_standard",
code_path="./src",
standard_id="react-18-patterns"
)
# 搜索特定指导
search_results = await client.call_tool(
"search_standards",
query="身份验证最佳实践",
limit=5
)
# 复制适用于任何LLM的启动提示
cat kickstart.md
服务器可以从GitHub仓库自动同步标准:
# 检查更新
mcp-standards sync --check
# 执行同步
mcp-standards sync
# 强制同步所有文件(忽略缓存)
mcp-standards sync --force
# 查看同步状态
mcp-standards status
# 管理缓存
mcp-standards cache --list
mcp-standards cache --clear
在data/standards/sync_config.yaml中配置同步。
使用内置生成系统创建新标准:
# 列出可用模板
mcp-standards generate list-templates
# 交互式生成新标准
mcp-standards generate --interactive
# 从特定模板生成
mcp-standards generate --template standards/technical.j2 --title "我的新标准"
# 生成领域特定标准
mcp-standards generate --domain ai_ml --title "ML流水线标准"
# 验证现有标准
mcp-standards generate validate path/to/standard.md
项目包括一个基于React的Web UI,用于浏览和测试标准:
# 启动Web UI
cd web
./start.sh
# 或分别运行组件:
# 后端API
cd web/backend
pip install -r requirements.txt
python main.py
# 前端
cd web/frontend
npm install
npm start
Web UI提供:
访问UI:http://localhost:3000(前端)和API:http://localhost:8000(后端)。
增强的CLI提供了额外的功能:
# 根据项目上下文查询标准
mcp-standards query --project-type web --framework react --language javascript
# 验证代码与标准的一致性
mcp-standards validate src/ --format json --severity warning
# 自动修复代码问题(预览模式)
mcp-standards validate src/ --fix --dry-run
# 配置管理
mcp-standards config --init # 初始化配置
mcp-standards config --show # 显示当前配置
mcp-standards config --validate # 验证配置文件
规则定义在JSON格式的data/standards/meta/standard-selection-rules.json中。每个规则指定:
示例规则:
{
"id": "react-web-app",
"name": "React Web应用程序标准",
"priority": 10,
"conditions": {
"logic": "AND",
"conditions": [
{
"field": "project_type",
"operator": "equals",
"value": "web_application"
},
{
"field": "framework",
"operator": "in",
"value": ["react", "next.js", "gatsby"]
}
]
},
"standards": [
"react-18-patterns",
"javascript-es2025",
"frontend-accessibility"
],
"tags": ["前端", "React", "Web"]
}
系统包括25项全面标准:
详见STANDARDS_COMPLETE_CATALOG.md中的详情。
mcp-standards-server/
├── src/
│ ├── core/
│ │ ├── mcp/ # MCP服务器实现
│ │ ├── standards/ # 标准引擎及存储
│ │ └── cache/ # Redis缓存层
│ ├── analyzers/ # 语言特定分析器
│ ├── generators/ # 标准生成系统
│ └── cli/ # CLI接口
├── web/ # React/TypeScript UI(独立应用)
│ ├── frontend/ # React应用程序
│ └── backend/ # FastAPI后端
├── data/
│ └── standards/ # 25项全面标准
│ ├── meta/ # 规则引擎配置
│ └── cache/ # 本地文件缓存
├── templates/ # 标准生成模板
├── tests/ # 综合测试套件
├── benchmarks/ # 性能基准测试
└── docs/ # 文档
运行测试套件:
# 运行所有测试
pytest
# 运行覆盖率测试
pytest --cov=src --cov-report=term-missing
# 运行特定测试类别
pytest tests/unit/ # 仅单元测试
pytest tests/integration/ # 集成测试
pytest tests/e2e/ # 端到端测试
# 运行特定测试文件
pytest tests/unit/core/standards/test_rule_engine.py
# 运行性能测试
python run_performance_tests.py
# 并行运行测试(更快)
python run_tests_parallel.py
# 克隆仓库
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # 在Windows上:venv\Scripts\activate
# 以开发模式安装所有依赖
pip install -e ".[dev,test,performance,visualization,full]"
# 安装预提交钩子(如果可用)
pre-commit install
# 运行所有基准测试
python benchmarks/run_benchmarks.py
# 运行特定基准测试套件
python benchmarks/analyzer_performance.py
python benchmarks/semantic_search_benchmark.py
python benchmarks/token_optimization_benchmark.py
# 生成性能报告
python benchmarks/run_benchmarks.py --report
该项目使用GitHub Actions进行持续集成:
# 示例GitHub Actions工作流
- name: 验证标准
run: |
pip install mcp-standards-server
mcp-standards validate . --format sarif --output results.sarif
- name: 上传SARIF结果
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif