port-sentry
An MCP server that gives AI coding agents superpowers over network ports โ find free ports, identify port hogs, and kill zombie processes without ever leaving the chat.
๐ฏ Why?
AI coding agents constantly try to start dev servers on ports that are already in use, leading to cascading failures and wasted tokens. While tools like lsof and netstat exist for humans, there is no MCP server that gives agents structured, actionable port intelligence โ forcing them to parse raw shell output or guess random port numbers.
Target audience: Developers using AI coding agents (Claude Code, Cursor, Codex, Copilot) who frequently run dev servers, databases, and microservices locally and are tired of 'port already in use' errors derailing their agent workflows.
โจ Features
- โจ List all ports currently in use with owning process name, PID, and command line
- โจ Find the next N available ports within a specified range
- โจ Check if a specific port is available or occupied
- โจ Kill the process occupying a specific port (with safety confirmations)
- โจ Wait/poll for a port to become free with configurable timeout
๐ Quick Start
# Install
pip install port-sentry
# Run
port-sentry --help
๐ฆ Installation
From Source
git clone https://github.com/YOUR_USERNAME/port-sentry.git
cd port-sentry
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest -v
๐ฌ Demo
The GIF above was recorded using Charm VHS:
vhs < demo.tape
๐ Usage
# Show help
port-sentry --help
# Common usage examples
port-sentry --example
๐๏ธ Architecture
graph LR
A[Input] --> B[Core Engine]
B --> C[Output]
B --> D[Plugins]
D --> E[Extensions]
๐ค Contributing
Contributions are welcome! Please:
- Fork the repo
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
MIT ยฉ 2026 โ See LICENSE for details.
If this project helped you, please โญ star it!