home / mcp / python mcp server

Python MCP Server

Provides a Python-based MCP server that coordinates test discovery, skeleton test generation, Maven test execution, and report analysis for Java/Maven projects.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "amyfan7-se333-final-mcp": {
      "command": "python",
      "args": [
        "server.py"
      ]
    }
  }
}

You are running an MCP server that exposes tools to automate test generation, analyze test coverage, and check code style for Java/Maven projects. It is designed to be driven by an MCP-aware client, enabling you to discover public methods, generate skeleton tests, execute tests with Maven, and review coverage and style results in an iterative loop until your goals are met.

How to use

You use an MCP client to connect to the MCP server and orchestrate a workflow that discovers public methods, generates tests, runs tests, analyzes coverage, and checks style. The client repeatedly calls the server tools to improve test coverage and code quality, updating tests and code as needed and then re-running checks.

How to install

Prerequisites you need to have before starting:

  • Python 3.x available on PATH
  • Java JDK available on PATH
  • Maven (mvn) available on PATH
  • JaCoCo XML at A2/target/site/jacoco/jacoco.xml
  • Checkstyle XML at A2/target/checkstyle-result.xml
  • MCP client / VS Code MCP integration

Install and run the MCP server

Clone or obtain the project files, then set up the Python environment and verify tool availability.

Install Python dependencies

pip install fastmcp

Verify required tools are available

java -version
mvn -v

Start the MCP server from the project root

python server.py

Configure your MCP client to connect to the server via SSE transport (the server starts with an SSE transport).

Available tools

generate_tests

Create a skeleton JUnit test class for a given Java source file by extracting class and public method names and writing a corresponding test class to the tests directory.

get_all_public_methods

Recursively scan a Java project to collect all lines that begin with the keyword public, returning a list of raw method signatures, constructors, or public fields.

analyze_coverage

Parse JaCoCo XML to identify methods with less than 100% instruction coverage, returning a structured summary of uncovered methods with counts.

run_checkstyle

Execute the Maven build to generate JaCoCo and Checkstyle reports and capture the stdout for review.

analyze_checkstyle

Parse the Checkstyle XML to list style violations with file, line, column, severity, and message.

run_tests

Run the test suite (Maven) and return the resulting output.

git_add_all

Stage all changes in the repository for commit.

git_commit

Create a commit with a descriptive message detailing changes made during the iteration.

git_pull_request

Open or update a pull request to integrate the changes into the target branch.

git_push

Push the committed changes to the remote repository.

git_status

Display the current Git status showing modified, added, and untracked files.