Skip to main content
Glama

DeepSource MCP Server

by sapientpants

DeepSource MCP 服务器

与 DeepSource 集成的模型上下文协议 (MCP) 服务器为 AI 助手提供对代码质量指标、问题和分析结果的访问权限。

概述

DeepSource MCP 服务器使 AI 助手能够通过模型上下文协议 (MCP) 与 DeepSource 的代码质量分析功能进行交互。这种集成使 AI 助手能够:

  • 检索代码指标和分析结果
  • 访问和过滤问题
  • 检查质量状态
  • 分析项目质量随时间的变化

特征

  • DeepSource API 集成:通过 GraphQL API 连接到 DeepSource
  • MCP 协议支持:实现 AI 助手集成的模型上下文协议
  • 质量指标和阈值:使用阈值检索和管理代码质量指标
  • 安全合规性报告:访问 OWASP Top 10、SANS Top 25 和 MISRA-C 合规性报告
  • 依赖项漏洞:访问有关依赖项的安全漏洞信息
  • TypeScript/Node.js :使用 TypeScript 构建,以实现类型安全和现代 JavaScript 功能
  • 跨平台:适用于 Linux、macOS 和 Windows
  • 强大的错误处理:针对网络、身份验证和解析问题的全面错误处理

与 Claude Desktop 一起使用

  1. 编辑claude_desktop_config.json
    • 打开 Claude 桌面
    • 前往Settings -> Developer -> Edit Config
    • 将以下配置之一添加到mcpServers部分
  2. 重新启动 Claude Desktop 以应用更改

示例查询

连接后,您的 AI 助手可以使用 DeepSource 数据进行如下查询:

What issues are in the JavaScript files of my project?

这将使用带有过滤器的project_issues工具:

{ "projectKey": "your-project-key", "path": "src/", "analyzerIn": ["javascript"], "first": 10 }

要过滤分析运行:

Show me the most recent Python analysis runs

这将使用带有过滤器的project_runs工具:

{ "projectKey": "your-project-key", "analyzerIn": ["python"], "first": 5 }

对于代码质量指标:

What's my code coverage percentage? Is it meeting our thresholds?

这将使用quality_metrics工具:

{ "projectKey": "your-project-key", "shortcodeIn": ["LCV", "BCV", "CCV"] }

对于安全合规性报告:

Are we compliant with OWASP Top 10 security standards?

这将使用compliance_report工具:

{ "projectKey": "your-project-key", "reportType": "OWASP_TOP_10" }

设置阈值:

Update our line coverage threshold to 80%

这将使用update_metric_threshold工具:

{ "projectKey": "your-project-key", "repositoryId": "repo-id", "metricShortcode": "LCV", "metricKey": "AGGREGATE", "thresholdValue": 80 }

环境变量

服务器支持以下环境变量:

  • DEEPSOURCE_API_KEY (必需):用于身份验证的 DeepSource API 密钥
  • LOG_FILE (可选):日志写入文件的路径。如果未设置,则不会写入任何日志
  • LOG_LEVEL (可选):写入的最低日志级别(DEBUG、INFO、WARN、ERROR)。默认为 DEBUG

带有日志记录的示例配置:

{ "mcpServers": { "deepsource": { "command": "npx", "args": [ "-y", "deepsource-mcp-server@1.1.0" ], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key", "LOG_FILE": "/tmp/deepsource-mcp.log", "LOG_LEVEL": "DEBUG" } } } }

Docker

{ "mcpServers": { "deepsource": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DEEPSOURCE_API_KEY", "-e", "LOG_FILE=/tmp/deepsource-mcp.log", "-v", "/tmp:/tmp", "sapientpants/deepsource-mcp-server" ], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key", "LOG_FILE": "/tmp/deepsource-mcp.log" } } } }

NPX

{ "mcpServers": { "deepsource": { "command": "npx", "args": [ "-y", "deepsource-mcp-server@1.1.0" ], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key" } } } }

可用工具

DeepSource MCP 服务器提供以下工具:

  1. projects :列出所有可用的 DeepSource 项目
    • 参数:
      • 无必需参数
  2. project_issues :通过过滤从 DeepSource 项目中获取问题
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • 分页参数:
        • offset (可选)- 分页时要跳过的项目数
        • first (可选)- 返回的项目数(默认为 10)
        • after (可选)- 用于向前分页的光标
        • before (可选)- 向后分页的光标
        • last (可选) - 在“before”光标之前返回的项目数(默认值:10)
      • 过滤参数:
        • path (可选)- 通过特定文件路径过滤问题
        • analyzerIn (可选) - 通过特定分析器过滤问题 (例如,[“python”、“javascript”])
        • tags (可选)- 按标签过滤问题
  3. project_runs :列出 DeepSource 项目的分析运行,并进行过滤
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • 分页参数:
        • offset (可选)- 分页时要跳过的项目数
        • first (可选)- 返回的项目数(默认为 10)
        • after (可选)- 用于向前分页的光标
        • before (可选)- 向后分页的光标
        • last (可选) - 在“before”光标之前返回的项目数(默认值:10)
      • 过滤参数:
        • analyzerIn (可选) - 通过特定的分析器过滤运行 (例如,[“python”、“javascript”])
  4. run :通过 runUid 或 commitOid 获取特定分析运行
    • 参数:
      • runIdentifier (必需)- 用于标识运行的 runUid(UUID)或 commitOid(提交哈希)
  5. recent_run_issues :获取特定分支上最近运行的分析中的问题,并支持分页
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • branchName (必需)- 获取最新运行的分支名称
      • 分页参数:
        • first (可选)- 返回的问题数(默认为 10)
        • after (可选)- 用于向前分页的光标
        • last (可选) - 光标前返回的问题数 (默认值:10)
        • before (可选)- 向后分页的光标
    • 返回:
      • 有关分支上最近一次运行的信息
      • 项目中的当前问题(注意:问题是存储库级别的,而不是运行特定的)
      • 分页信息,包括光标和页面状态
      • 关于运行和分支的元数据
  6. dependency_vulnerabilities :从 DeepSource 项目获取依赖漏洞
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • 分页参数:
        • offset (可选)- 分页时要跳过的项目数
        • first (可选)- 返回的项目数(默认为 10)
        • after (可选)- 用于向前分页的光标
        • before (可选)- 向后分页的光标
        • last (可选) - 在“before”光标之前返回的项目数(默认值:10)
  7. quality_metrics :通过过滤从 DeepSource 项目获取质量指标
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • shortcodeIn (可选) - 通过特定的短代码过滤指标 (例如,[“LCV”, “BCV”])
    • 返回如下指标:
      • 线路覆盖率 (LCV)
      • 分支机构覆盖率 (BCV)
      • 文档覆盖率 (DCV)
      • 重复代码百分比 (DDP)
      • 每个指标包括当前值、阈值和通过/失败状态
  8. update_metric_threshold :更新特定质量指标的阈值
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • repositoryId (必需)- GraphQL 存储库 ID
      • metricShortcode (必需)- 要更新的指标的短代码
      • metricKey (必需)- 指标的语言或上下文键
      • thresholdValue (可选) - 新的阈值,或为 null 以删除阈值
    • 示例:设置 80% 线路覆盖率阈值:metricShortcode="LCV", metricKey="AGGREGATE", thresholdValue=80
  9. update_metric_setting :更新质量指标的设置
    • 参数:
      • projectKey (必需)- DeepSource 项目的唯一标识符
      • repositoryId (必需)- GraphQL 存储库 ID
      • metricShortcode (必需)- 要更新的指标的短代码
      • isReported (必需)- 是否应报告该指标
      • isThresholdEnforced (必需)- 是否应强制执行阈值(可能会检查失败)
  10. compliance_report :从 DeepSource 项目获取安全合规性报告
  • 参数:
    • projectKey (必需)- DeepSource 项目的唯一标识符
    • reportType (必需) - 要获取的合规性报告类型( OWASP Top 10SANS Top 25MISRA-C
  • 返回全面的安全合规性数据,包括:
    • 按类别和严重程度统计的安全问题
    • 合规状态(通过/未通过)
    • 显示随时间变化的趋势数据
    • 改善安全态势的分析和建议

发展

  1. 克隆存储库:
git clone https://github.com/sapientpants/deepsource-mcp-server.git cd deepsource-mcp-server
  1. 安装依赖项:
pnpm install
  1. 构建项目:
pnpm run build
  1. 配置 Claude 桌面
{ "mcpServers": { "deepsource": { "command": "node", "args": [ "/path/to/deepsource-mcp-server/dist/index.js" ], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key" } } } }

先决条件

  • Node.js 20 或更高版本
  • pnpm 10.7.0 或更高版本
  • Docker(用于容器构建)

脚本

  • pnpm run build构建 TypeScript 代码
  • pnpm run start启动服务器
  • pnpm run dev以开发模式启动服务器
  • pnpm run test - 运行测试
  • pnpm run lint - 运行 ESLint
  • pnpm run format - 使用 Prettier 格式化代码

故障排除

启用调试日志记录

如果您遇到问题,请启用调试日志记录以查看详细信息:

  1. LOG_FILE环境变量设置为应写入日志的文件路径
  2. LOG_LEVEL设置为DEBUG (这是默认值)
  3. 检查日志文件以获取详细的错误信息

示例配置:

{ "mcpServers": { "deepsource": { "command": "npx", "args": ["-y", "deepsource-mcp-server@1.1.0"], "env": { "DEEPSOURCE_API_KEY": "your-api-key", "LOG_FILE": "/tmp/deepsource-mcp.log", "LOG_LEVEL": "DEBUG" } } } }

然后检查日志文件:

tail -f /tmp/deepsource-mcp.log

常见问题

  1. 身份验证错误:确保您的DEEPSOURCE_API_KEY正确且具有必要的权限
  2. 没有出现日志:验证LOG_FILE路径是否可写以及父目录是否存在
  3. 工具错误:检查日志文件以获取详细的错误消息和堆栈跟踪

执照

麻省理工学院

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

与 DeepSource 集成的模型上下文协议服务器,为 AI 助手提供对代码质量指标、问题和分析结果的访问权限。

  1. 概述
    1. 特征
      1. 与 Claude Desktop 一起使用
        1. 示例查询
        2. 环境变量
        3. Docker
        4. NPX
      2. 可用工具
        1. 发展
          1. 先决条件
          2. 脚本
        2. 故障排除
          1. 启用调试日志记录
          2. 常见问题
        3. 执照

          Related MCP Servers

          • A
            security
            F
            license
            A
            quality
            A Model Context Protocol server that enables AI models to interact with SourceSync.ai's knowledge management platform for managing documents, ingesting content from various sources, and performing semantic searches.
            Last updated -
            25
            14
            • Apple
            • Linux
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enables AI agents to retrieve and understand entire codebases at once, providing tools to analyze local workspaces or remote GitHub repositories.
            Last updated -
            9
            TypeScript
            MIT License
            • Linux
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enhances AI-generated code quality through comprehensive analysis across 10 critical dimensions, helping identify issues before they become problems.
            Last updated -
            3
            Python
            Apache 2.0
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            A comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.
            Last updated -
            16
            TypeScript

          View all related MCP servers

          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/sapientpants/deepsource-mcp-server'

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