Skip to main content
Glama
prepare_release.py4.38 kB
#!/usr/bin/env python3 """ MCP Recommender 发布准备脚本 检查包的完整性和准备发布 """ import json import subprocess import sys from pathlib import Path def check_files(): """检查必要文件是否存在""" required_files = [ "pyproject.toml", "README.md", "LICENSE", "MANIFEST.in", "mcp_recommender/__init__.py", "mcp_recommender/__main__.py", "mcp_recommender/server.py", "mcp_recommender/data/mcp_database.json" ] print("📋 检查必要文件...") missing_files = [] for file_path in required_files: if not Path(file_path).exists(): missing_files.append(file_path) else: print(f" ✅ {file_path}") if missing_files: print(f" ❌ 缺少文件: {', '.join(missing_files)}") return False return True def check_package_info(): """检查包信息""" print("\n📦 检查包信息...") try: with open("pyproject.toml", "r", encoding="utf-8") as f: content = f.read() # 检查关键字段 required_fields = ["name", "version", "description", "license", "authors"] for field in required_fields: if field in content: print(f" ✅ {field}") else: print(f" ❌ 缺少 {field}") return False # 检查MIT许可证 if 'license = {text = "MIT"}' in content: print(" ✅ MIT许可证配置正确") else: print(" ❌ MIT许可证配置缺失") return False except Exception as e: print(f" ❌ 读取pyproject.toml失败: {e}") return False return True def check_data_integrity(): """检查数据完整性""" print("\n📊 检查数据完整性...") try: # 检查MCP数据库 db_path = Path("mcp_recommender/data/mcp_database.json") if db_path.exists(): with open(db_path, "r", encoding="utf-8") as f: data = json.load(f) print(f" ✅ MCP数据库: {len(data)} 个服务器") else: print(" ❌ MCP数据库文件不存在") return False # 检查功能关键词 keywords_path = Path("mcp_recommender/data/functional_keywords.json") if keywords_path.exists(): with open(keywords_path, "r", encoding="utf-8") as f: keywords = json.load(f) print(f" ✅ 功能关键词: {len(keywords)} 个分类") else: print(" ⚠️ 功能关键词文件不存在(可选)") except Exception as e: print(f" ❌ 数据检查失败: {e}") return False return True def test_import(): """测试包导入""" print("\n🧪 测试包导入...") try: result = subprocess.run([ sys.executable, "-c", "import mcp_recommender; print('导入成功')" ], capture_output=True, text=True, cwd=".") if result.returncode == 0: print(" ✅ 包导入成功") return True else: print(f" ❌ 包导入失败: {result.stderr}") return False except Exception as e: print(f" ❌ 导入测试失败: {e}") return False def main(): """主检查流程""" print("🔍 MCP Recommender 发布准备检查") print("=" * 50) checks = [ ("文件完整性", check_files), ("包信息", check_package_info), ("数据完整性", check_data_integrity), ("导入测试", test_import) ] all_passed = True for name, check_func in checks: if not check_func(): all_passed = False print("\n" + "=" * 50) if all_passed: print("🎉 所有检查通过!包已准备好发布") print("\n📋 发布步骤:") print(" 1. 构建包: uv build") print(" 2. 检查包: twine check dist/*") print(" 3. 测试发布: twine upload --repository testpypi dist/*") print(" 4. 正式发布: twine upload dist/*") else: print("❌ 检查失败,请修复问题后重试") sys.exit(1) if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bxzymy/mcp-recommend'

If you have feedback or need assistance with the MCP directory API, please join our Discord server