Skip to content

Lance52259/api-scan

Repository files navigation

华为云API分析MCP服务器

基于 Model Context Protocol (MCP) 的华为云API文档查询工具,专为Cursor IDE优化。

✨ 特性

  • 🔍 智能API查询 - 通过自然语言查询华为云API文档
  • 🤖 Cursor集成 - 在Cursor Agent模式中自动识别并调用工具
  • 🌐 全局命令 - 一键安装,任意路径使用
  • 📊 完整覆盖 - 支持280+华为云产品和服务
  • 🔧 易于维护 - 内置状态检查和诊断功能
  • 🐍 Python 3.10 自动安装 - 自动检测并安装 Python 3.10(Ubuntu/Debian)

🚀 快速开始

一键安装

# 使用 curl 安装(推荐)
curl -fsSL https://raw.githubusercontent.com/Lance52259/api-scan/master/install.sh | bash

# 或使用 wget
wget -qO- https://raw.githubusercontent.com/Lance52259/api-scan/master/install.sh | bash

# 或克隆后安装
git clone https://github.com/Lance52259/api-scan.git
cd api-scan
./install.sh

✨ 自动化安装特性

  • 🚀 全自动化: 无需手动干预,一条命令完成所有安装
  • ⚡ 无需重启: 环境变量自动配置,安装完成立即可用
  • 🎯 智能检测: 自动检测并安装 Python 3.10(Ubuntu/Debian)
  • 🔧 依赖解决: 智能处理包版本冲突,多策略安装
  • 🤖 非交互模式: 支持CI/CD环境的无人值守安装

Python 3.10 自动安装

如果系统没有 Python 3.10,安装脚本会自动:

  • 检测系统环境(支持 Ubuntu/Debian)
  • 询问是否安装 Python 3.10.13
  • 自动下载、编译和安装 Python 3.10
  • 安装完成后继续 MCP 服务器安装

详细信息请参考:Python 3.10 自动安装功能

配置Cursor

在Cursor MCP设置中添加:

{
  "mcpServers": {
    "api_scan": {
      "command": "wsl",
      "args": ["/home/huawei/.local/bin/api-scan", "--run"]
    }
  }
}

📋 命令参考

命令 功能 用途
api-scan --run 启动MCP服务器 Cursor配置使用
api-scan --test 交互式测试 功能验证
api-scan --check 状态检查 诊断问题
api-scan --help 显示帮助 查看用法

🎯 支持的查询

产品列表

华为云有哪些产品和服务?
我想了解华为云提供的所有服务

API列表

华为云ECS有哪些API接口?
RDS产品提供哪些API?

API详细信息

我需要创建云服务器的API详细信息
华为云对象存储上传文件的API怎么用?

🔧 技术架构

  • 协议: JSON-RPC 2.0 (MCP标准)
  • Python版本: 3.10+ (自动安装支持)
  • 工具数量: 3个核心工具
  • 产品覆盖: 280+华为云产品
  • 兼容性: Ubuntu/Debian (自动安装), 其他系统需手动安装Python

📁 项目结构

api-scan/
├── api-scan                           # 全局命令行工具
├── install.sh                         # 增强安装脚本(支持Python自动安装)
├── run_cursor_server.py               # MCP服务器启动器
├── yaml_export_tool.py                # YAML导出工具
├── src/scan/
│   ├── cursor_optimized_server.py     # 核心MCP服务器
│   ├── client.py                      # 华为云API客户端
│   ├── yaml_exporter.py               # YAML导出模块
│   └── models.py                      # 数据模型
├── docs/
│   ├── INSTALL_GUIDE.md                     # 安装指南
│   ├── CURSOR_AUTO_TOOL_USAGE.md            # 使用指南
│   ├── PYTHON_AUTO_INSTALL.md               # Python自动安装说明
│   ├── YAML_EXPORT_GUIDE.md                 # YAML导出功能指南
│   └── DEPENDENCY_CONFLICT_RESOLUTION.md    # 依赖冲突解决方案
└── requirements.txt                         # 依赖声明

🛠️ 开发

运行测试

# 协议兼容性测试
python3 test_cursor_mcp.py

# 交互式功能测试  
api-scan --test

# 状态检查
api-scan --check

调试

# 查看服务器日志
api-scan --run > server.log 2>&1

# 检查配置
api-scan --help

🐍 Python 环境要求

自动安装(推荐)

  • 支持系统: Ubuntu/Debian
  • 自动检测: 缺少 Python 3.10 时自动安装
  • 安装版本: Python 3.10.13
  • 编译优化: 启用优化选项

手动安装

对于其他系统,请手动安装 Python 3.10+:

# CentOS/RHEL
sudo dnf install python3.10 python3.10-pip

# macOS
brew install [email protected]

# Arch Linux
sudo pacman -S python310

🛠️ 故障排除

✅ 自动化安装改进

新版本安装脚本已完全自动化,解决了以下常见问题:

  • 无需重启终端: 环境变量自动配置并立即生效
  • 智能PATH管理: 自动添加到shell配置文件并在当前会话中生效
  • 重复安装检测: 避免重复配置,安全多次运行
  • 非交互模式: 支持CI/CD环境,无需用户确认

pip路径问题

如果遇到 bad interpreter: No such file or directory 错误:

# 问题症状
main: /home/user/.local/bin/pip3.10: /usr/local/bin/python3.10: bad interpreter: No such file or directory

# 解决方案1: 使用修复脚本
curl -fsSL https://raw.githubusercontent.com/Lance52259/api-scan/master/fix_pip_path.sh | bash

# 解决方案2: 手动修复
python3.10 -m ensurepip --user --upgrade
python3.10 -m pip install --user --upgrade pip

# 解决方案3: 使用调试模式安装
DEBUG=1 curl -fsSL https://raw.githubusercontent.com/Lance52259/api-scan/master/install.sh | bash

依赖冲突

如果遇到包版本冲突:

# 强制重新安装所有依赖
python3.10 -m pip install --user --force-reinstall mcp httpx pydantic PyYAML

# 或使用保守版本
python3.10 -m pip install --user mcp==1.0.0 httpx==0.27.0 pydantic==1.10.21 PyYAML==6.0

权限问题

如果遇到权限错误:

# 确保使用用户安装模式
python3.10 -m pip install --user <package>

# 或检查目录权限
mkdir -p ~/.local/bin ~/.local/share
chmod 755 ~/.local/bin ~/.local/share

📖 文档

🤝 贡献

欢迎提交Issue和Pull Request来改进项目。

📄 许可证

MIT License - 详见 LICENSE 文件


让华为云API查询变得更简单! 🎉

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published