mcpField
M
MCP Security Scans

MCP Security Scans

本地服务
github.com/mcp-research开发工具226 周前更新

关于 MCP Security Scans

MCP Security Scans 是面向审计含 MCP 服务配置仓库团队的 Python 自动化项目。它将选定仓库分叉到 GitHub 组织,启用受支持的 GitHub Advanced Security 功能并生成报告。

主要功能

  1. 01加载 MCP 服务仓库配置
  2. 02将仓库分叉到目标组织
  3. 03启用受支持的 GHAS 功能
  4. 04检查 Dependabot 配置
  5. 05分析分叉仓库并生成报告
  6. 06处理 GitHub API 错误和速率限制

适用场景

  1. 01为 MCP 服务分叉仓库启用安全扫描
  2. 02跟踪含 Dependabot 配置的仓库
  3. 03定期生成已处理分叉仓库的报告

MCP 相关

这是仓库扫描自动化项目,而非 MCP 服务。它处理包含 MCP 服务配置的仓库。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

MCP 安全扫描

此项目包含一个 Python 脚本,用于自动 fork mcp-agents-ai/mcp-agents-hub 中列出的仓库,并在 fork 的仓库上启用 GitHub Advanced Security(GHAS)功能。

功能

  • 支持从多个仓库来源加载 MCP 服务配置。
  • 目前支持 mcp-agents-ai/mcp-agents-hub 仓库。
  • 使用 GitHub App 向 GitHub 进行身份验证。
  • 将识别出的源仓库 fork 到指定的目标组织(默认:mcp-research)。
  • 在尝试创建 fork 前检查是否已存在。
  • 在 fork 的仓库上启用以下 GHAS 功能:
    • 依赖项扫描(通过漏洞警报)
    • 自动安全修复
    • 密钥扫描
    • 使用默认设置进行代码扫描(如果该仓库的语言支持)
  • 检查每个 fork 中是否存在 .github/dependabot.yml 文件。
  • 报告已处理的仓库总数,以及具有/不具有 Dependabot 配置的仓库数量。
  • 处理 GitHub API 错误并显示速率限制信息。

设置

  1. 克隆此仓库:

    git clone <your-repo-url>
    cd mcp-security-scans
    
  2. 创建 Python 虚拟环境(推荐):

    python -m venv .venv
    source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
    
  3. 安装依赖项:

    pip install -r requirements.txt
    pip install -r requirements-dev.txt
    
  4. 设置 GitHub App:

    • 创建一个 GitHub App(例如,在你的用户账户或某个组织下创建)。
    • 为其授予目标组织(例如 mcp-research)所需的权限:
      • 仓库权限:
        • 管理:读取和写入(用于启用安全功能、创建 fork)
        • 内容:读取和写入(用于检查 dependabot.yml,可能是默认设置所需)
        • 元数据:只读(默认)
        • 密钥扫描警报:读取和写入
        • 代码扫描警报:读取和写入
        • Dependabot 警报:读取和写入
      • 组织权限:
        • 成员:只读(用于验证 App 是否已安装)
    • 在目标组织(mcp-research)中安装此 App。
    • 为此 App 生成私钥并复制其内容。
    • 记下 App ID。
  5. 设置环境变量: 在 shell 中设置以下环境变量,或使用 .env 文件(脚本会自动加载该文件):

    export GH_APP_ID="YOUR_APP_ID"
    export GH_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\\nYOUR_KEY_CONTENT_HERE\\n-----END RSA PRIVATE KEY-----"
    

    将 YOUR_APP_ID 替换为你的 App ID。 将私钥字符串替换为 .pem 文件的实际内容;如果直接在 shell 中设置,请确保保留换行符(\\n),如果使用 .env 文件,则保留实际换行符。

用法

确保已设置环境变量 GH_APP_ID 和 GH_APP_PRIVATE_KEY。然后,从此项目的根目录运行脚本:

python -m src.process_mcp_repos # will process all repos found and fork them into the target org
python -m src.analyze --num-repos x # will analyze the forks and store found information into the forks repository properties
python -m src.report # will generate a report of the forks based on the information stored in the forks repository properties

可选参数:

  • --target-org <org_name>:指定要 fork 到的其他目标组织(默认为 mcp-research)。

示例:

# Assuming environment variables are set and the virtual environment is active
python -m src.process_mcp_repos --target-org my-testing-org

脚本会在控制台中记录运行进度。

添加新的 MCP 服务来源

要添加对包含 MCP 服务配置的新仓库的支持:

  1. 在 src/process_mcp_repos.py 中创建一个新函数,从你的仓库加载 MCP 服务列表:
def load_mcp_servers_from_my_custom_repo() -> list[Path]:
    """
    Loads MCP server configurations from your custom repository.

    Returns:
        A list of Path objects pointing to files containing server configurations.
    """
    repo_url = "https://github.com/your-org/your-repo.git"
    local_path = Path("./cloned_your_repo")
    json_dir_in_repo = Path("path/to/configs")

    # Clone or update the repository
    newly_cloned = clone_or_update_repo(repo_url, local_path)
    if newly_cloned:
        logging.info(f"Custom repository newly cloned to [{local_path}]")
    else:
        logging.info(f"Custom repository at [{local_path}] already exists and was updated")

    # Find configuration files in the repository
    json_dir = local_path / json_dir_in_repo
    if not json_dir.is_dir():
        logging.error(f"Config directory not found: [{json_dir}]")
        return []

    config_files = sorted(list(json_dir.glob("*.json")))  # Adjust the pattern as needed
    if not config_files:
        logging.warning(f"No configuration files found in [{json_dir}]")
        return []

    logging.info(f"Found [{len(config_files)}] configuration files in custom repository")
    return config_files
  1. 将新的加载函数注册到 MCP_SERVER_LOADERS 列表中:
# Register the custom loader
MCP_SERVER_LOADERS.append(load_mcp_servers_from_my_custom_repo)

主函数会自动使用所有已注册的加载函数来收集 MCP 服务配置。

GitHub 工作流

此代码库包含多个 GitHub 工作流,用于自动执行各种任务:

  • 处理 MCP 代码库:自动复刻代码库并启用 GHAS 功能。
  • 每日安全报告:为代码库生成每日安全报告。
  • 创建代码库属性:设置所需的代码库属性。
  • 在新问题中提及 @rajbos:自动在由其他人创建的新问题中提及 @rajbos,确保及时关注报告的问题。

测试

python -m unittest tests.test_mcp_scan

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。