dev-env-mcp
by omnicoder9
README.md
# dev-env-mcp
A Python stdio MCP server for inspecting local repositories and debugging Maven test failures. The assistant can read source, inspect Git changes, and run tests and Checkstyle against a fresh snapshot of the working tree. Edits are made through the developer’s editor or the assistant’s existing editing tools.
## Install and connect
Use Python 3.11 or later and Git. The Maven tools also require a running Docker engine configured for Linux containers. From the server repository, with a Python virtual environment active, run:
```sh
python -m pip install -e .
docker build -f Dockerfile -t dev-env-maven:local examples/free-shipping
```
The image build runs the trusted sample’s Maven build with network access and caches its dependencies. Subsequent MCP test and lint calls use that cache offline. For a different Maven project, build the Dockerfile with that trusted project's directory as the context and supply the resulting tag with `--image TAG`. Use a context that excludes secrets and generated output. Rebuild the image when the build needs new dependencies. Each server process uses one runner image.
Register the server with a stdio-capable MCP client. Adapt these absolute paths to your checkout and virtual environment. On Windows the launcher is typically `.venv\Scripts\dev-env-mcp.exe`.
```json
{
"mcpServers": {
"dev-env": {
"command": "/absolute/path/to/.venv/bin/dev-env-mcp",
"args": [
"--project", "shipping=/absolute/path/to/dev-env-mcp/examples/free-shipping",
"--project", "server=/absolute/path/to/dev-env-mcp"
]
}
}
}
```
Repeat `--project NAME=PATH` for each directory the assistant may access. For Git operations, register the checkout root containing its own `.git` entry. The example `shipping` directory is a standalone Maven project inside the `server` checkout.
## Debug the example
Select the `debug_failing_test` MCP prompt with project `shipping`, or ask the assistant:
> Investigate the failing shipping test. Show the expected and actual behavior, propose the smallest fix, and verify it on a working copy.
The documented rule grants free shipping at a subtotal of **at least $50**. Surefire identifies `ShippingPolicyTest.exactThresholdQualifies`, where the service returns false for 5,000 cents. Searching for `shipsFree` leads to `ShippingPolicy.java`. Changing `subtotalCents > 5000` to `subtotalCents >= 5000` includes the threshold and preserves the behavior on either side. Rerun `ShippingPolicyTest#exactThresholdQualifies`, then the full suite and Checkstyle.
To exercise this sequence over MCP, including the edit and Git diff, run the integration test. It makes a disposable Git checkout and leaves the fixture ready for another investigation.
```sh
DEV_ENV_DOCKER_TEST=1 python -m unittest discover -s tests -v
```
In PowerShell set `$env:DEV_ENV_DOCKER_TEST = "1"` before running the Python command. Omit the environment variable for the inspection, Git, and boundary tests that run without Docker.
## Tools
| Tool | Inputs and result |
| --- | --- |
| `list_projects` | Lists the configured project names. |
| `read_file` | Takes `project`, relative `path`, optional one-based `start_line` and `max_lines`. Returns a page of UTF-8 text and a continuation line. |
| `search_code` | Takes `project`, a case-sensitive literal `query`, and optional `limit`. Returns matching paths, line numbers, excerpts, and a truncation flag. |
| `run_tests` | Takes `project` and an optional `test` class or `Class#method` selector. Runs Maven’s test phase and updates the test report resource. |
| `run_linter` | Takes `project`. Runs the Maven Checkstyle check goal using the project’s configuration. |
| `get_git_status` | Takes `project`. Returns the branch and short working-tree status. |
| `get_git_diff` | Takes `project` and optional `staged`. Defaults to the unstaged patch. |
Command results include `exit_code`, `output`, `truncated`, and `timed_out`. A nonzero Maven exit code carries the build or assertion diagnostics. Check the outcome before treating a run as verification.
## Resources
Discover project names at `dev://projects/index`. Substitute a registered name for `{project}` in the resource templates.
| URI | Contents |
| --- | --- |
| `dev://projects/{project}/tree` | Project-relative directory and file paths |
| `dev://projects/{project}/docs` | READMEs and text documentation under docs directories |
| `dev://projects/{project}/build` | Maven, Gradle, and Checkstyle configuration files |
| `dev://projects/{project}/test-reports` | Up to 8 KiB of Surefire text from the latest test run in this session, or a diagnostic if no report was produced |
| `dev://projects/{project}/history` | The latest 20 Git commit IDs, dates, and subjects |
## Execution and limits
- Register working directories controlled by your local account. The Git tools invoke the host Git CLI and trust the checkout’s Git administrative data, including repository-local configuration and linked worktree metadata. Git output can include any tracked file in that repository.
- File inspection and build snapshots omit symlinks, special files, generated directories such as `target` and `node_modules`, and dot-prefixed entries except `.mvn`. File tools use forward-slash relative paths on all hosts. Source snapshots include uncommitted and untracked visible files.
- Each Maven run gets a temporary copy in a non-root Linux container with networking disabled, a read-only root filesystem, bounded temporary storage, two CPUs, a 1.5 GiB memory limit, and a 256-process limit. The server streams the snapshot into Docker. The checkout, host credentials, and Docker socket are outside the build container.
- The server serializes builds, allows 180 seconds per Maven command and 30 seconds per Git command, and retains the last 24,000 output bytes. Reads and searches cap text files at 2 MiB. Read pages, search results, and directory resources have a 16,000-character budget. Searches and snapshots have a 64 MiB budget, and directory walks stop at 20,000 entries.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues