Metadata-Version: 2.5
Name: devport-doctor
Version: 0.2.1
Summary: Diagnose local development ports, processes, and connectivity issues with CLI and MCP support.
Project-URL: Homepage, https://github.com/jeromeprince777/DevPort-Doctor
Project-URL: Repository, https://github.com/jeromeprince777/DevPort-Doctor
Project-URL: Issues, https://github.com/jeromeprince777/DevPort-Doctor/issues
Project-URL: Changelog, https://github.com/jeromeprince777/DevPort-Doctor/blob/main/CHANGELOG.md
Author-email: Jerome Prince <jeromeprince777@gmail.com>
License: MIT
License-File: LICENSE
Keywords: cli,diagnostics,docker,localhost,mcp,networking,ports,wsl
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: System :: Networking
Requires-Python: >=3.11
Requires-Dist: mcp>=1.0.0
Requires-Dist: psutil>=6.0.0
Requires-Dist: pydantic>=2.8.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.7.0
Requires-Dist: typer>=0.12.0
Description-Content-Type: text/markdown

<div align="center">
  <img src="./assets/banner.svg" alt="DevPort Doctor Animated Banner" width="100%" />
</div>

# DevPort Doctor

Local-first CLI and MCP toolkit for diagnosing port conflicts, localhost connectivity failures, Docker port mappings, and WSL networking issues.

![DevPort Doctor Terminal Demo](https://raw.githubusercontent.com/jeromeprince777/DevPort-Doctor/main/docs/demo.svg)

## Why DevPort Doctor?

Most port utilities only kill processes (`killport`, `kill-port`) or print raw socket tables (`netstat`, `lsof`). **DevPort Doctor** performs **read-only, evidence-based diagnostics** across your local stack:

- **Process & Port Inspection** — List listening TCP ports, owning processes, and PIDs (`psutil`) while gracefully handling permission-restricted system sockets.
- **IPv4 vs. IPv6 Diagnostics** — Detect occupied ports, connection refusals, timeouts, and `127.0.0.1` vs. `::1` binding mismatches (`socket`).
- **Docker & WSL Awareness** — Inspect published vs. unpublished container ports and Windows-to-WSL listening sockets (`subprocess`, `shell=False`).
- **Multiple Output Formats** — Rich terminal reports, structured JSON (`--format json`), and sanitized Markdown exports (`--format markdown`) with automatic home-path and credential redaction.
- **MCP Integration** — Expose read-only diagnostic tools to AI coding agents over stdio (`devport mcp`) with zero external APIs.

## Installation

```bash
# Install globally as a CLI tool (once published to PyPI)
uv tool install devport-doctor

# Or run from source
git clone https://github.com/jeromeprince777/DevPort-Doctor.git
cd DevPort-Doctor
uv sync
uv run devport --help
```

## Usage

```bash
# Show version and help
devport --version
devport --help

# List all listening TCP ports (or filter by port)
devport list
devport list --port 3000

# Inspect a port's listeners and IPv4/IPv6 reachability
devport inspect 3000

# Run full evidence-based diagnostics
devport doctor 3000
devport doctor 3000 --host localhost
devport doctor 3000 --format json
devport doctor 3000 --format markdown

# Inspect Docker containers or WSL distributions
devport docker
devport wsl

# Check a Docker Compose file for port conflicts
devport compose
devport compose path/to/docker-compose.yml

# Continuously monitor a port for state or PID changes
devport watch 3000
devport watch 3000 --interval 1.0 --count 5

# Start the read-only MCP server (stdio)
devport mcp
```

### Example Output

```text
DevPort Doctor v0.1.0

Target: localhost:18789

[PASS] Host resolution
       ::1
       127.0.0.1
[WARN] TCP connection
       127.0.0.1:18789 (IPv4) -> OPEN
       ::1:18789 (IPv6) -> REFUSED
[PASS] Listening process
       127.0.0.1:18789 (IPv4) PID=23916 process=node.exe
[SKIP] Docker diagnostics
       Docker CLI was not found on PATH.
[SKIP] WSL diagnostics
       WSL is installed, but no Linux distributions are configured.

Likely cause:
Service is reachable on 127.0.0.1 (IPv4) only; ::1 (IPv6) failed (IPv4/IPv6 binding mismatch).

Recommendation:
Configure the server to bind to all interfaces (0.0.0.0 or ::), or connect explicitly via 127.0.0.1:18789.
```

## MCP Server Configuration

Add **DevPort Doctor** to your MCP client configuration (e.g., Antigravity, Claude Desktop, or Cursor):

```json
{
  "mcpServers": {
    "devport-doctor": {
      "command": "devport",
      "args": ["mcp"]
    }
  }
}
```

Exposed read-only tools: `list_ports`, `inspect_port`, `diagnose_port`, `inspect_docker_ports`, and `inspect_wsl_ports`.

## Architecture

```mermaid
flowchart TD
    A[CLI Interface] --> C[Diagnostic Engine]
    B[MCP Server] --> C
    C --> D[Port Inspector]
    C --> E[Connectivity Tester]
    C --> F[Docker Inspector]
    C --> G[WSL Inspector]
    D --> H[Diagnostic Rules]
    E --> H
    F --> H
    G --> H
    H --> I[Structured Results]
    I --> J[Rich Terminal Output]
    I --> K[JSON / Markdown Reports]
```

See [docs/architecture.md](docs/architecture.md), [docs/requirements.md](docs/requirements.md), and [ADR 0001](docs/decisions/0001-evidence-based-diagnostics.md) for design details.

## Supported Platforms & Known Limitations

- **Primary platform:** Windows 11 (verified locally + `windows-latest` CI).
- **Secondary platform:** Linux (verified via `ubuntu-latest` CI).
- **macOS:** Not yet tested or officially supported.
- **Docker & WSL:** Verified via unit tests with mocked command output and graceful fallback checks on Windows; live container/distro integration depends on local Docker Desktop / WSL2 setup.
- **Permissions:** Inspecting system-owned sockets (e.g., Windows `System` PID 4) may require elevated privileges; DevPort Doctor reports `Access denied` / `UNKNOWN` rather than failing.

## Development

```bash
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest
uv build
```

## Contributing & Security

- See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow and PR guidelines.
- See [SECURITY.md](SECURITY.md) for vulnerability reporting and security guarantees.

## License

[MIT](LICENSE)
