Token导航 LogoToken导航TokenDH.com
MCP Discovery Tool logo
安全风控未说明官方级别未说明来源级核验

MCP Discovery Tool

MCP Server

一款用于扫描.NET程序集以发现MCP服务器功能并分析安全漏洞的命令行工具,支持多格式报告输出和CI/CD集成。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
安全C#静态分析漏洞检测

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

echapmanFromBunnings

提供方

echapmanFromBunnings

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MCP发现和安全分析工具

一个全面的命令行扫描工具。NET程序集,用于发现MCP(模型上下文协议)服务器功能并分析其安全漏洞。它执行基于深度反射的分析,以识别工具、资源和提示,同时检测潜在的安全风险,包括提示注入、工具中毒、有毒流、硬编码秘密和缺少安全控制。

此存储库包含什么

此存储库包括:

  • mcp发现.net -扫描程序集以查找MCP元数据的主要发现工具
  • mcp发现测试 -带有所有功能类型示例的工作测试MCP服务器

工具的作用

mcp-discover 该工具提供了全面的分析。NET MCP服务器程序集:

MCP发现功能

  1. 扫描 指定目录中的所有程序集
  2. 发现 用MCP属性装饰的类和方法:

- [McpServerToolType] / [McpServerTool] -可执行功能/工具 - [McpServerResourceType] / [McpServerResource] -静态内容/资源 - [McpServerPromptType] / [McpServerPrompt] -AI提示模板

  1. 提取 元数据,包括名称、描述和受众定位
  2. 生成 多种格式的结构化输出(JSON、SARIF、CSV、Markdown)

安全分析能力

  1. 漏洞检测 跨越4个类别(20+启发式)
  2. 秘密检测 用于硬编码凭据(API密钥、密码、令牌)
  3. 输入验证跟踪 减少误报
  4. 审计日志分析 识别缺失的安全日志记录
  5. CWE映射 用于行业标准漏洞分类
  6. 补救指南 带有代码示例和文档链接
  7. CI/CD集成 具有可配置的严重性阈值和退出代码
  8. 基于文件的筛选 忽略某些漏洞类别的特定文件

输出格式

该工具支持多种输出格式:

JSON(默认) - mcp-metadata.json:

  • 程序集信息
  • 发现具有MCP属性的类
  • 方法/成员及其元数据(名称、标题、描述、受众)
  • CWE映射和补救指南的安全分析结果
  • 生成时间戳

标记语言 - mcp-metadata.md (与 --markdown 标志):

  • 人类可读摘要
  • 按能力类型(工具、资源、提示)组织的表
  • 按严重程度(严重、高、中、低)分组的安全发现
  • 装配细节和统计数据

沙林2.1.0 - security-report.sarif (与 --format sarif):

  • 静态分析结果交换格式
  • 行业标准漏洞报告
  • 与GitHub代码扫描和其他SAST工具集成
  • CWE映射、严重性级别和补救指南

CSV文件 - security-report.csv (与 --format csv):

  • Excel兼容的表格格式
  • 列:类别、严重程度、CWE、标题、描述、位置、建议、证据
  • 易于过滤和排序以进行安全审查

安装与使用

先决条件

  • .NET 10.0 SDK或更高版本

从源头构建

# Clone the repository
git clone 
cd mcp.discovery.tool

# Build the discovery tool
cd mcp-discover-dotnet
dotnet build -c Release

# The executable will be at:
# ./bin/Release/net10.0/mcp-discover-dotnet.exe (Windows)
# ./bin/Release/net10.0/mcp-discover-dotnet (Linux/macOS)

作为一个使用。NET工具(推荐)

该工具可以作为全局工具安装。NET工具在nuget.org上可用:

# Install globally
dotnet tool install --global --add-source ./bin/Release mcp-discover-dotnet

# Use from anywhere
mcp-discover-dotnet  

直接使用

# Run directly
mcp-discover-dotnet.exe  

# Or with dotnet
dotnet run --project mcp-discover-dotnet --  

命令行语法

mcp-discover-dotnet   [options]

Arguments:
  input-directory   Directory containing .dll assemblies to scan
  output-directory  Directory where output files will be written

Basic Options:
  -h, --help         Show help information
  -m, --markdown     Generate markdown report alongside JSON
  -o, --omit-path    Omit base path from assembly paths in output
  -n, --no-timestamp Omit timestamp from output (for version control)
  -s, --security     Perform security vulnerability analysis

Security Analysis Options:
  --config 
           Load configuration from JSON file
  --format          Export format: json (default), sarif, csv, or all
  --min-severity     Minimum severity to report: Low, Medium, High, Critical
  --exclude     Comma-separated categories to exclude
  --fail-on-critical        Exit with code 1 if critical vulnerabilities found
  --fail-on-high            Exit with code 1 if high+ vulnerabilities found
  --verbose                 Display detailed security findings with CWE mappings

例子

# Basic MCP discovery
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata

# Generate both JSON and markdown reports
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --markdown

# Perform security vulnerability scan
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security

# Security scan with SARIF export for CI/CD integration
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --format sarif

# Export in all formats (JSON, SARIF, CSV)
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --format all

# Filter to show only High and Critical findings
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --min-severity High

# Exclude specific vulnerability categories
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --exclude PromptInjection,ToxicFlow

# CI/CD integration: fail build if critical vulnerabilities found
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --fail-on-critical

# Comprehensive analysis with verbose output
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --markdown --security --format all --verbose

# Use configuration file for custom patterns and thresholds
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --security --config security-config.json

# Use relative paths in output instead of full paths
mcp-discover-dotnet ./bin/Release/net10.0 ./metadata --omit-path --security

安全漏洞检测

该工具使用基于模式的启发式方法和增强的检测对MCP服务器进行全面的安全分析:

漏洞类别

  1. 快速注射攻击 💉 (CWE-74)

- 检测可能接受未经消毒的用户输入的提示 - 在提示描述中标识字符串连接模式 - 标记缺少输入验证 - 通过验证跟踪方法以减少误报

  1. 工具中毒攻击 ☠️ (CWE-494)

- 识别危险操作(文件系统、命令执行、数据库访问) - 检测易受路径遍历攻击的文件系统操作 - 标记可能易受SQL注入攻击的数据库操作 - 警告易受SSRF影响的外部API调用 - 检测到验证方法时降低严重性

  1. 有毒物质流动问题 ⚡ (CWE-693)

- 检测没有超时配置的异步操作 - 识别不受速率限制的昂贵操作 - 标记资源枯竭风险

  1. 一般安全问题 🛡️ (CWE-312、CWE-778)

- 秘密检测:标识硬编码凭据(API密钥、密码、令牌、承载令牌、AWS机密、私钥) - 审计日志:检测敏感操作中缺少的审核日志记录 - 识别敏感操作中缺失的授权控制 - 检测缺少受众限制 - 标记未经验证访问外部资源的工具

增强的检测功能

  • 输入验证跟踪:分析验证模式的方法(验证、消毒、检查、验证、白名单),以减少误报
  • CWE映射:将所有发现映射到行业标准分类的常见弱点枚举ID
  • 补救指南:提供可操作的代码示例和OWASP文档链接
  • 秘密图案:检测硬编码凭据的13种模式
  • 验证模式:用于识别输入验证的7种模式
  • 日志记录模式:检测审核日志记录的5种模式

严重级别

  • 关键的:需要紧急关注的直接安全风险
  • :应尽快解决的重大安全问题
  • 中等:值得审查的潜在安全问题
  • :轻微的安全考虑或最佳实践改进

安全扫描输出

--security 如果使用,JSON输出包括一个全面的 SecurityAnalysis 章节:

{
  "SecurityAnalysis": {
    "TotalFindings": 12,
    "CriticalCount": 2,
    "HighCount": 5,
    "MediumCount": 3,
    "LowCount": 2,
    "Findings": [
      {
        "Category": "GeneralSecurity",
        "Severity": "Critical",
        "CWE": "CWE-312",
        "Title": "Hardcoded Credentials Detected",
        "Description": "Method contains hardcoded secrets or credentials",
        "Location": "AuthService.GetApiKey",
        "Recommendation": "Use secure secret management (Azure Key Vault, AWS Secrets Manager)",
        "Evidence": "Pattern 'api_key' detected",
        "CodeExample": "// Use environment variables or secure vaults\nvar apiKey = Environment.GetEnvironmentVariable(\"API_KEY\");",
        "DocumentationLink": "https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_credentials"
      },
      {
        "Category": "ToolPoisoning",
        "Severity": "High",
        "CWE": "CWE-494",
        "Title": "Potentially Dangerous Tool Operation",
        "Description": "Tool contains dangerous operation pattern",
        "Location": "FileTools.DeleteFile",
        "Recommendation": "Implement strict input validation, path sanitization, and authorization checks",
        "Evidence": "Pattern 'Delete' detected",
        "CodeExample": "// Validate and sanitize file paths\nvar safePath = Path.GetFullPath(userInput);\nif (!safePath.StartsWith(allowedDirectory)) throw new SecurityException();",
        "DocumentationLink": "https://owasp.org/www-community/attacks/Path_Traversal"
      }
    ]
  }
}

SARIF 2.1.0出口

使用 --format sarif 对于行业标准静态分析结果交换格式:

mcp-discover-dotnet ./bin/Release/net10.0 ./output --security --format sarif

这会产生 security-report.sarif 兼容:

  • GitHub代码扫描
  • Azure DevOps安全分析
  • 声纳立方
  • 其他SAST工具

CSV导出

使用 --format csv 对于Excel兼容的表格导出:

mcp-discover-dotnet ./bin/Release/net10.0 ./output --security --format csv

列:类别、严重程度、CWE、标题、描述、位置、建议、证据

Markdown报告

随着 --markdown --security,该报告包括一个详细的安全部分,其中按严重程度和颜色编码的输出对调查结果进行了分组。

配置文件

创建JSON配置文件以自定义安全扫描行为:

{
  "MinimumSeverity": null,
  "ExcludeCategories": [],
  "Patterns": {
    "SecretsPatterns": [
      "api_key",
      "password",
      "custom_secret"
    ],
    "ValidationPatterns": [
      "validate",
      "sanitize"
    ],
    "LoggingPatterns": [
      "log",
      "audit"
    ]
  },
  "Thresholds": {
    "CriticalThreshold": 0,
    "HighThreshold": 5
  },
  "Suppressions": [
    {
      "Location": "TestClass.TestMethod",
      "Reason": "False positive - method is for testing only"
    }
  ],
  "IgnoreFiles": {
    "PromptInjection": [
      "**/Tests/**",
      "**/TestData/**"
    ],
    "GeneralSecurity": [
      "**/Mock*.dll"
    ]
  }
}

配置选项

最小 (空|“低”|“中”|“高”|“严重”)

  • 过滤低于此严重级别的发现
  • null 显示所有发现

排除类别 (字符串数组)

  • 跳过整个漏洞类别
  • 有效值:“快速注射”、“工具中毒”、“毒物流量”、“一般安全”

模式 (对象)

  • 秘密模式:检测硬编码凭据的其他模式
  • 验证模式:指示输入验证的模式(减少误报)
  • 记录模式:检测审计日志记录的模式

阈值 (对象)

  • 临界阈值:CI/CD故障前的最大关键发现( --fail-on-critical)
  • 高阈值:CI/CD故障前的最大高+发现值( --fail-on-high)

抑制 (对象数组)

  • 位置:要抑制的方法或类(例如,“MyClass.MyMethod”)
  • 理由:记录这一发现被隐瞒的原因

忽略文件 (对象)

  • 钥匙:漏洞类别名称
  • 价值:文件要忽略的glob模式数组
  • 支持通配符: ** (任何目录), * (任何字符)
  • 示例:

- "**/Tests/**" -忽略任何Tests目录中的所有文件 - "**/Mock*.dll" -忽略以“Mock”开头的DLL - "**/bin/Debug/**" -忽略调试版本

使用配置文件

# Basic usage with config
mcp-discover-dotnet ./bin/Release/net10.0 ./output --security --config security-config.json

# Override config severity with command-line flag
mcp-discover-dotnet ./bin/Release/net10.0 ./output --security --config security-config.json --min-severity High

# Combine with other options
mcp-discover-dotnet ./bin/Release/net10.0 ./output --security --config security-config.json --format sarif --verbose

CI/CD集成

退出代码

该工具使用退出代码进行构建自动化:

  • 退出0:成功(无失败或未超过阈值)
  • 出口1:失败(使用时超过阈值 --fail-on-* 旗帜)

GitHub操作示例

name: MCP Security Scan

on: [push, pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: '10.0.x'
      
      - name: Install MCP Discovery Tool
        run: dotnet tool install --global mcp-discover-dotnet
      
      - name: Build Application
        run: dotnet build -c Release
      
      - name: Run Security Scan
        run: |
          mcp-discover-dotnet ./bin/Release/net10.0 ./security-report \
            --security \
            --format sarif \
            --fail-on-critical \
            --config security-config.json
      
      - name: Upload SARIF to GitHub Security
        uses: github/codeql-action/upload-sarif@v2
        if: always()
        with:
          sarif_file: security-report/security-report.sarif

Azure DevOps管道示例

trigger:
  - main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: UseDotNet@2
  inputs:
    version: '10.0.x'

- script: dotnet tool install --global mcp-discover-dotnet
  displayName: 'Install MCP Discovery Tool'

- script: dotnet build -c Release
  displayName: 'Build Application'

- script: |
    mcp-discover-dotnet ./bin/Release/net10.0 ./security-report \
      --security \
      --format all \
      --fail-on-high \
      --verbose
  displayName: 'Security Scan'

- task: PublishBuildArtifacts@1
  condition: always()
  inputs:
    pathToPublish: 'security-report'
    artifactName: 'security-analysis'

基于阈值的门控

# Fail build if ANY critical vulnerabilities found
mcp-discover-dotnet ./bin ./output --security --fail-on-critical

# Fail build if ANY high or critical vulnerabilities found  
mcp-discover-dotnet ./bin ./output --security --fail-on-high

# Use config file to set numeric thresholds
# security-config.json: { "Thresholds": { "CriticalThreshold": 0, "HighThreshold": 5 } }
mcp-discover-dotnet ./bin ./output --security --config security-config.json --fail-on-high

快速启动测试服务器

该存储库包括一个完整的测试服务器,演示了所有MCP功能类型:

# Navigate to the test server
cd mcp-discover.tests

# Build (automatically runs discovery tool)
dotnet build -c Release

# Run the server
.\run.ps1

# View generated metadata
.\view-metadata.ps1

mcp-discover.tests/README.md 详细文档。

MCP属性参考

让你的。NET程序集可发现,请使用以下属性:

类级别属性

[McpServerToolType("group-name", "Display Title")]
public class MyTools { }

[McpServerResourceType("group-name", "Display Title")]
public class MyResources { }

[McpServerPromptType("group-name", "Display Title")]
public class MyPrompts { }

方法级别属性

[McpServerTool("tool-name", "Display Title")]
[Description("Detailed description of what this tool does")]
[McpAudience("developers", "qa")]
public static int MyTool(int param) { return param; }

[McpServerResource("resource-name", "Display Title")]
public string GetResource() { return "content"; }

[McpServerPrompt("prompt-name", "Display Title")]
public string GetPrompt() { return "prompt template"; }

元数据属性

[Description("Detailed description")]
[McpAudience("audience1", "audience2")]

输出示例

{
  "GeneratedAtUtc": "2025-11-22T10:30:00Z",
  "Assemblies": [
    {
      "AssemblyPath": "C:\\path\\to\\server.dll",
      "Classes": [
        {
          "TypeName": "MyApp.CalculatorTools",
          "Kind": "ToolType",
          "Description": "Math operations",
          "Audiences": ["developers"],
          "Members": [
            {
              "MethodName": "Add",
              "Kind": "Tool",
              "Name": "add",
              "Title": "Add Numbers",
              "Description": "Adds two integers",
              "Audiences": ["developers"]
            }
          ]
        }
      ]
    }
  ]
}

与构建过程集成

您可以将发现工具集成到MSBuild进程中:


  

    path\to\mcp-discover-dotnet.exe
    $(MSBuildProjectDirectory)\$(OutputPath)
    $(MSBuildProjectDirectory)\$(OutputPath)mcp-metadata
  

  
  

mcp-discover.tests/mcp-discover.tests.cproj 作为一个工作示例。

存储库结构

mcp.discovery.tool/
├── mcp-discover-dotnet/       # Discovery tool source code
│   ├── Program.cs             # Main scanning logic
│   └── mcp-discover-dotnet.csproj    # Tool project file
│
├── mcp-discover.tests/        # Test MCP server
│   ├── SampleServer.cs        # Example server implementation
│   ├── McpAttributes.cs       # Attribute definitions
│   ├── run.ps1                # Server runner script
│   ├── view-metadata.ps1      # Metadata viewer script
│   └── README.md              # Test server documentation
│
├── mcp.discovery.tool.sln     # Solution file
└── README.md                  # This file

用例

MCP开发

  • 自动化能力发现:在构建过程中生成能力元数据
  • 文档生成:提取并记录可用的工具/资源/提示
  • 验证:验证MCP属性是否正确应用
  • 动态发现:在运行时发现MCP服务器程序集中的功能

安全与合规

  • 漏洞检测:在部署之前识别MCP服务器中的安全风险
  • CI/CD安全门:具有关键漏洞的块构建
  • SARIF集成:将调查结果输入GitHub代码扫描、Azure DevOps、SonarQube
  • 合规报告:为安全审计生成CSV/Excel报告
  • CWE映射:使用行业标准分类跟踪漏洞

DevSeCops

  • 左移安全:在开发早期发现漏洞
  • 自动扫描:集成到构建管道中,以进行持续的安全分析
  • 假阳性减少:输入验证跟踪可减少噪声
  • 秘密检测:防止硬编码凭据到达生产环境
  • 信息系统安全度量:随着时间的推移跟踪关键/高/中/低发现

测试和质量保证

  • 安全性测试:验证MCP服务器实施的安全最佳实践
  • 回归检测:跨版本跟踪安全发现
  • 抑制管理:记录和管理已知的误报

运作原理

MCP发现

  1. 装配加载:使用隔离 AssemblyLoadContext 安全装载组件
  2. 反思:MCP属性的扫描类型和方法
  3. 元数据抽取:读取属性构造函数参数和属性
  4. 输出生成:将发现的元数据序列化为结构化格式

证券分析

  1. 模式匹配:在4个漏洞类别中应用20多种启发式方法
  2. 验证跟踪:识别具有输入验证的方法,以减少误报
  3. 秘密检测:扫描13种硬编码凭据模式
  4. 审计日志:检测敏感操作中缺少的安全日志记录
  5. CWE映射:将发现映射到常见弱点枚举ID
  6. 补救:提供代码示例和OWASP文档链接
  7. 过滤:应用基于严重性、类别和文件的筛选
  8. 出口:生成JSON、SARIF 2.1.0、CSV和Markdown报告
  9. CI/CD:根据可配置的严重性阈值返回退出代码

需求

  • .NET 10.0 SDK 或以后
  • Windows、Linux或macOS
  • 必须编译程序集。NET程序集(.dll文件)

贡献

欢迎投稿!需要改进的地方:

特性

  • 支持其他元数据属性
  • 更多漏洞检测启发式方法
  • 用于安全分析的自定义规则引擎
  • 与其他SAST工具集成

演出

  • 大型装配集的性能优化
  • 多装配分析的并行处理
  • 增量扫描未更改的文件

出口与整合

  • 其他输出格式(XML、HTML报告)
  • 其他CI/CD系统的集成示例(GitLab CI、Jenkins)
  • 用于内联安全警告的VS代码扩展
  • 用于程序化API访问的NuGet包

作者

来自Bunnings的echapman

相关资源

______________________________________________________________________

需要帮助? 在中检查测试服务器 mcp-discover.tests/ 一个完整的工作示例!

目录标签

目录标签

安全C#静态分析漏洞检测安全扫描本地部署.NET分析CI/CD集成

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP