MCP标准服务器
     ](https://badge.fury.io/py/mcp-standards-server) ](https://pypi.org/project/mcp-standards-server/)
一种模型上下文协议(MCP)服务器,提供对开发标准的智能、上下文感知访问。该系统使LLM能够根据项目要求自动选择和应用适当的标准。
项目状态
最近的改进(2025年1月)
此项目经过了重大修复以恢复功能:
✅ 已解决的问题:
- 修复了关键的CI/CD工作流故障和安全漏洞
- 解决了Python 3.12兼容性问题(aioredis、类型提示)
- 将依赖关系管理整合到pyproject.toml
- 修复了数百个代码质量违规(flake8、mypy、black)
- 优化GitHub工作流程,性能提高40%
✅ 核心系统状态:
- 25个全面标准,满载且可访问
- 25条智能选择规则可操作
- MCP服务器,配备21个功能齐全的工具
- 多语言代码分析(6种语言)工作
- Redis缓存和性能优化处于活动状态
⚠️ 需要验证的组件:
- Web UI部署过程和功能
- 完整的E2E集成测试(跳过了一些测试)
- 绩效基准基线建立
看 CLAUDE.md 了解详细的实施状态。
特性
核心能力
- 25综合标准:全面覆盖软件开发生命周期
- 智能标准选择:基于规则的引擎,具有25个检测规则
- MCP服务器实现:使用多种工具支持完整的模型上下文协议
- 标准生成系统:基于模板的创建,具有质量保证
- 混合矢量存储:内存中的ChromaDB+用于语义搜索
- 多语言分析器:Python、JavaScript、Go、Java、Rust、TypeScript支持
高级功能
- Redis缓存层:用于性能优化的L1/L2架构
- Web用户界面:用于浏览和测试标准的React/TypeScript接口
- CLI工具:带文档的全面命令行界面
- 绩效基准测试:持续监控和优化
- 令牌优化:多种压缩格式,提高LLM效率
- NIST合规性:NIST 800-53r5控制映射和验证
- 社区特征:审查流程、贡献指南、分析
需求
- Python 3.10或更高版本
- Redis(可选,用于缓存)
- Node.js 16+(可选,用于web UI)
🚀 5分钟快速入门
在5分钟内使MCP标准服务器运行:
# 1. Clone and setup (1 minute)
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
python -m venv venv && source venv/bin/activate
# 2. Install core dependencies (2 minutes)
pip install -e .
# 3. Verify CLI installation (30 seconds)
python -m src.cli.main --help
python -m src.cli.main status
# 4. Test MCP server functionality (1 minute)
python -m src # Should load 31 standards and initialize MCP server
# 5. Check available standards (30 seconds)
python -m src.cli.main cache --list # View cached standards🎉 成功! 您的MCP标准服务器现在正在运行。继续到 完整安装 用于Redis缓存和web UI的完整设置。
完整安装指南
安装
从PyPI安装(推荐)
# Install the latest release
pip install mcp-standards-server
# Or install with specific feature sets:
pip install "mcp-standards-server[full]" # All features including web API
pip install "mcp-standards-server[test]" # Testing tools only
pip install "mcp-standards-server[dev]" # Development tools
pip install "mcp-standards-server[performance]" # Performance monitoring tools从源代码安装
# Clone the repository
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
# Create and activate virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Or install with specific feature sets:
pip install -e ".[full]" # All features including web API
pip install -e ".[test]" # Testing tools only
pip install -e ".[dev]" # Development tools (linting, formatting)
pip install -e ".[performance]" # Performance monitoring tools
# Install all development dependencies
pip install -e ".[dev,test,performance,visualization,full]"
# Install Redis (optional but recommended for caching)
# 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 (using WSL2):
wsl --install # If not already installed
# Then follow Ubuntu instructions inside WSL
# Or use Docker:
docker run -d -p 6379:6379 redis:alpine验证安装
# Run basic tests to verify core functionality
pytest tests/unit/core/standards/test_rule_engine.py -v
# Check if the project is properly installed
python -c "import src; print('Installation successful')"
# Note: The CLI command (mcp-standards) requires the package to be installed
# in the current environment. If you see import errors, ensure you've run:
# pip install -e .基本用法
from pathlib import Path
from src.core.standards.rule_engine import RuleEngine
# Load the rule engine
rules_path = Path("data/standards/meta/standard-selection-rules.json")
engine = RuleEngine(rules_path)
# Define your project context
context = {
"project_type": "web_application",
"framework": "react",
"language": "javascript",
"requirements": ["accessibility", "performance"]
}
# Get applicable standards
result = engine.evaluate(context)
print(f"Selected standards: {result['resolved_standards']}")运行MCP服务器
# Start the MCP server (stdio mode for tool integration)
python -m src
# Or use the CLI
mcp-standards --help
# Start MCP server with specific options
mcp-standards serve --stdio # For direct tool integration
mcp-standards serve --port 3000 # HTTP server mode
mcp-standards serve --daemon # Run as background service
# Start the web UI (requires separate setup)
cd web && ./start.shMCP工具可用
MCP服务器为LLM集成提供了以下工具:
- 获取_适用_标准:根据项目背景获取相关标准
- validate_against_stard:检查代码是否符合特定标准
- 建议改进:获取改进建议
- 搜索_标准:跨所有标准的语义搜索
- get_compliance_mapping:将标准映射到NIST控制
- 分析代码:分析代码文件以符合标准
- 获取标准内容:检索完整或压缩的标准内容
MCP集成示例
# Example: Using with MCP client
import mcp
# Connect to the MCP server
async with mcp.Client("stdio://python -m src") as client:
# Get applicable standards for a project
result = await client.call_tool(
"get_applicable_standards",
context={
"project_type": "web_application",
"framework": "react",
"requirements": ["accessibility", "security"]
}
)
# Validate code against standards
validation = await client.call_tool(
"validate_against_standard",
code_path="./src",
standard_id="react-18-patterns"
)
# Search for specific guidance
search_results = await client.call_tool(
"search_standards",
query="authentication best practices",
limit=5
)使用通用项目Kickstart
# Copy the kickstart prompt for any LLM
cat kickstart.md同步标准
服务器可以自动同步GitHub存储库中的标准:
# Check for updates
mcp-standards sync --check
# Perform synchronization
mcp-standards sync
# Force sync all files (ignore cache)
mcp-standards sync --force
# View sync status
mcp-standards status
# Manage cache
mcp-standards cache --list
mcp-standards cache --clear在中配置同步 data/standards/sync_config.yaml.
生成标准
使用内置生成系统创建新标准:
# List available templates
mcp-standards generate list-templates
# Generate a new standard interactively
mcp-standards generate --interactive
# Generate from a specific template
mcp-standards generate --template standards/technical.j2 --title "My New Standard"
# Generate domain-specific standard
mcp-standards generate --domain ai_ml --title "ML Pipeline Standards"
# Validate an existing standard
mcp-standards generate validate path/to/standard.mdWeb用户界面
该项目包括一个基于React的web UI,用于浏览和测试标准:
# Start the web UI
cd web
./start.sh
# Or run components separately:
# Backend API
cd web/backend
pip install -r requirements.txt
python main.py
# Frontend
cd web/frontend
npm install
npm startweb UI提供:
- 具有搜索和过滤功能的标准浏览器
- 规则测试界面
- 通过WebSocket实时更新
- 标准分析仪表板
访问UIhttp://localhost:3000(前端)和APIhttp://localhost:8000(后端)。
其他CLI命令
增强的CLI提供了其他功能:
# Query standards based on project context
mcp-standards query --project-type web --framework react --language javascript
# Validate code against standards
mcp-standards validate src/ --format json --severity warning
# Auto-fix code issues (preview mode)
mcp-standards validate src/ --fix --dry-run
# Configuration management
mcp-standards config --init # Initialize configuration
mcp-standards config --show # Display current config
mcp-standards config --validate # Validate config file规则配置
规则以JSON格式定义 data/standards/meta/standard-selection-rules.json。每条规则规定:
- 适用条件
- 匹配时适用的标准
- 解决冲突的优先顺序
- 分类标签
示例规则:
{
"id": "react-web-app",
"name": "React Web Application Standards",
"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": ["frontend", "react", "web"]
}可用标准
该体系包括25个综合标准:
专业领域(8)
- AI/ML运营、区块链/Web3、物联网/边缘计算、游戏开发
- AR/VR开发、高级API设计、数据库优化、绿色计算
测试与质量(3)
- 高级测试、代码审查、性能优化
安全与合规(3)
- 安全审查和审计、数据隐私、业务连续性
文件与沟通(4)
- 技术内容、文档撰写、团队协作、项目规划
运营与基础设施(4)
- 部署与发布、监控与事件响应、SRE、技术债务
用户体验(3)
- 高级可访问性、国际化、开发人员体验
看 标准_完整\_ talog.md 了解详情。
建筑
mcp-standards-server/
├── src/
│ ├── core/
│ │ ├── mcp/ # MCP server implementation
│ │ ├── standards/ # Standards engine & storage
│ │ └── cache/ # Redis caching layer
│ ├── analyzers/ # Language-specific analyzers
│ ├── generators/ # Standards generation system
│ └── cli/ # CLI interface
├── web/ # React/TypeScript UI (separate app)
│ ├── frontend/ # React application
│ └── backend/ # FastAPI backend
├── data/
│ └── standards/ # 25 comprehensive standards
│ ├── meta/ # Rule engine configuration
│ └── cache/ # Local file cache
├── templates/ # Standard generation templates
├── tests/ # Comprehensive test suite
├── benchmarks/ # Performance benchmarking
└── docs/ # Documentation测试
运行测试套件:
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=term-missing
# Run specific test categories
pytest tests/unit/ # Unit tests only
pytest tests/integration/ # Integration tests
pytest tests/e2e/ # End-to-end tests
# Run specific test file
pytest tests/unit/core/standards/test_rule_engine.py
# Run performance tests
python run_performance_tests.py
# Run tests in parallel (faster)
python run_tests_parallel.py开发工作流程
设置开发环境
# Clone the repository
git clone https://github.com/williamzujkowski/mcp-standards-server.git
cd mcp-standards-server
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with all dependencies
pip install -e ".[dev,test,performance,visualization,full]"
# Install pre-commit hooks (if available)
pre-commit install运行基准
# Run all benchmarks
python benchmarks/run_benchmarks.py
# Run specific benchmark suites
python benchmarks/analyzer_performance.py
python benchmarks/semantic_search_benchmark.py
python benchmarks/token_optimization_benchmark.py
# Generate performance reports
python benchmarks/run_benchmarks.py --reportCI/CD集成
该项目使用GitHub Actions进行持续集成:
- CI徽章:对每个推送和拉取请求运行测试
- 释放徽章:自动发布到PyPI
- 基准徽章:跟踪一段时间内的性能指标
在CI/CD管道中使用
# Example GitHub Actions workflow
- name: Validate Standards
run: |
pip install mcp-standards-server
mcp-standards validate . --format sarif --output results.sarif
- name: Upload SARIF results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif贡献
- 分叉存储库
- 创建要素分支
- 添加新功能的测试
- 确保所有测试通过
- 提交拉取请求
文档
快速开始
- 环球项目Kickstart -复制粘贴任何LLM的提示
- 标准完整目录 -全部25个标准
- 创建标准指南 -如何制定新标准
技术文档
许可证
该项目根据MIT许可证获得许可。
故障排除
常见问题
- Redis连接错误:确保Redis正在运行或禁用缓存:
export MCP_STANDARDS_NO_CACHE=true- 导入错误:确保以开发模式安装:
pip install -e .- MCP服务器未启动:检查端口冲突:
lsof -i :3000 # Check if port is in use环境变量
以下环境变量可用于配置服务器:
MCP_STANDARDS_CONFIG:自定义配置文件的路径MCP_STANDARDS_CACHE_DIR:覆盖默认缓存目录MCP_STANDARDS_NO_CACHE:禁用缓存(设置为true)MCP_STANDARDS_LOG_LEVEL:设置日志记录级别(调试、信息、警告、错误)REDIS_URL:自定义Redis连接URLNO_COLOR:禁用CLI中的彩色输出
性能提示
- 启用Redis缓存 为了在大型代码库中获得更好的性能
- 使用令牌优化 在有限的背景下与LLM合作时
- 并行运行分析器 用于更快的代码验证
- 使用规则引擎 用于高效的标准选择
致谢
该项目是williamzujkowski/标准生态系统的一部分,旨在通过智能标准选择和应用来提高代码质量和一致性。
