Diffblue Cover MCP Server

Diffblue Cover MCP Server

Enables AI development environments to call the Diffblue Cover CLI tool to automatically generate unit tests for Java code.

Category
访问服务器

README

MCP Server for Diffblue Cover CLI

This repository provides a Model Context Protocol (MCP) Server for the Diffblue Cover CLI tool (dcover), making it callable and manageable by various AI development environments that adhere to the MCP specification (like the Gemini CLI).

Core Component: The MCP Server covermcp/server.py

The Python script serves as the universal adapter for the dcover create command.

Prerequisites

Before configuring the server with any host environment, ensure you have the following installed:

  1. Diffblue Cover CLI: Thedcover command must be installed and accessible in your system's PATH.
    • You can verify this by running dcover version in your terminal.
  2. uv: A Python project and package manager (https://docs.astral.sh/uv/)

Installing the MCP server

The project uses FastMCP to develop and deploy the MCP server. To install this server, you can use uv run fastmcp install claude-code --server-spec main.py (for example), other LLM tools are supported out of the box:

$ uv run fastmcp install --help
Usage: fastmcp install COMMAND

Install MCP servers in various clients and formats.

╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ claude-code     Install an MCP server in Claude Code.                                                                  │
│ claude-desktop  Install an MCP server in Claude Desktop.                                                               │
│ cursor          Install an MCP server in Cursor.                                                                       │
│ gemini-cli      Install an MCP server in Gemini CLI.                                                                   │
│ mcp-json        Generate MCP configuration JSON for manual installation.                                               │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

This command will install the MCP server for all projects, which you may not want. If this is the case, then you can be targeted in your installation if you use the mcp-json option to augment a .mcp.json file in the project:

{
  "mcpServers": {
    "Diffblue Cover": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "fastmcp",
        "run",
        "/path/to/cover-mcp/main.py"
      ]
    }
  }
}

This also allows you to specify environment variables. Currently, there are two that you can specify:

  • DIFFBLUE_COVER_CLI : the location of the installed dcover command line
  • DIFFBLUE_COVER_OPTIONS : use these dcover options as well as those supplied by the LLM

To use these variables in the .mcp.json file above, you would do so like this:

{
  "mcpServers": {
    "Diffblue Cover": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "fastmcp",
        "run",
        "/path/to/cover-mcp/main.py"
      ],
      "env": {
        "DIFFBLUE_COVER_CLI": "/path/to/dcover",
        "DIFFBLUE_COVER_OPTIONS": "--verbose --active-profiles=test"
      }
    }
  }
}

This will run the equivalent to /path/to/dcover --batch create <entry points provided by the LLM> --verbose --active-profiles=test

Note: No attempt is made to disambiguate the options provided options.

Developmental Notes

FastMCP contains a tool called "MCP Inspector" which can be used to interact with the MCP server without needing the LLM interaction. To run this developmental server, you can use uv run fastmcp dev. The configuration lives in the file fastmcp.json which provides (among other things) the entry point for the server.

$ uv run fastmcp dev --help    
Usage: fastmcp dev [OPTIONS] [ARGS]

Run an MCP server with the MCP Inspector for development.

╭─ Parameters ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ SERVER-SPEC --server-spec  Python file to run, optionally with :object suffix, or None to auto-detect fastmcp.json      │
│ --with-editable            Directory containing pyproject.toml to install in editable mode (can be used multiple times) │
│ --with                     Additional packages to install (can be used multiple times)                                  │
│ --inspector-version        Version of the MCP Inspector to use                                                          │
│ --ui-port                  Port for the MCP Inspector UI                                                                │
│ --server-port              Port for the MCP Inspector Proxy server                                                      │
│ --python                   Python version to use (e.g., 3.10, 3.11)                                                     │
│ --with-requirements        Requirements file to install dependencies from                                               │
│ --project                  Run the command within the given project directory                                           │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Project Layout

The project and the dependencies are managed by uv, see the documentation for the usage instructions.

Running Tests

There are unit tests (in the test directory) which you can run with uv run coverage run -m pytest and then get a coverage report with uv run coverage report --omit "test/*" (python includes the coverage of the test files by default -- not that useful).

Linting/Formatting

To run the linter, run uv run ruff check. If successful, you will see a message "All checks passed!". If not, you should address the issues picked up. More information can be found at the Ruff Linter Documentation

To format the code, run uv run ruff format, this should be run before committing any changes. More information can be found at the Ruff Formatter Documentation.

References

  • https://gofastmcp.com/
  • https://docs.astral.sh/uv/
  • https://docs.astral.sh/ruff/

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选