About MCP Port Cleaner Server
MCP Port Cleaner Server is a Node.js MCP server for developers resolving port conflicts. It can inspect processes using a port and terminate them, with cross-platform scanning and validated inputs.
Key features
- 01Scan processes using a port
- 02Show process details
- 03Terminate port-occupying processes
- 04Validate port input
Use cases
- 01Identify the process blocking a development port
- 02Clear a port before starting a development service
MCP support
It exposes the `port_scan` and `port_clean` tools to MCP clients for inspecting port users and terminating them.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Port Cleaner Server
Node.js server implementing Model Context Protocol (MCP) for port cleanup operations in development environments.
Features
- Finds and terminates processes occupying specified ports
- Scans and lists all processes occupying specified ports (cross-platform support)
- Safe input parameter validation using Zod schema
- Detailed error handling and response formatting
- Standard MCP protocol compliance for tool registration and request processing
Tools
port_scan
Description: Scans and lists all processes occupying a specified port (cross-platform support).
Input Parameters:
{
"port": {
"type": "integer",
"description": "scan process by specify port",
"minimum": 1,
"maximum": 65535
}
}
Response:
- Success: Returns list of processes with details (PID, name, user, protocol)
- Failure: Returns error information
- Port not occupied: Returns appropriate notification
port_clean
Description: Finds and terminates processes occupying a specified port to resolve development environment port conflicts.
Input Parameters:
{
"port": {
"type": "integer",
"description": "clean process by specify port",
"minimum": 1,
"maximum": 65535
}
}
Response:
- Success: Returns list of terminated process IDs
- Failure: Returns error information
- Port not occupied: Returns appropriate notification
Usage Examples
With Claude Desktop or Trae.cn
Docker Configuration
TODO
NPX Configuration
{
"mcpServers": {
"port-cleaner": {
"command": "npx",
"args": [
"-y",
"mcp-server-port-cleaner"
]
}
}
}
or install globally:
npm install -g mcp-server-port-cleaner
and then:
{
"mcpServers": {
"port-cleaner": {
"command": "mcp-server-port-cleaner"
}
}
}
Implementation Details
The server implements the following components:
- PortCleanerService: Core business logic for port cleanup operations
- PortScannerService: Cross-platform port scanning functionality
- MCP Server Integration: Standard MCP protocol implementation with:
- Tool registration (
port_clean,port_scan) - Request handling
- Input validation
- Tool registration (
- Error Handling: Comprehensive error handling at both service and server levels
Error Handling
The server provides detailed error responses in all failure scenarios:
- Invalid input parameters
- Process termination failures
- Unexpected runtime errors
Development Notes
- The service uses platform-specific commands:
- Linux/Unix:
lsof,kill,netstat - Windows:
netstat,tasklist,taskkill
- Linux/Unix:
- Cross-platform compatibility implemented with process detection
- The cleanup implementation terminates processes with SIGKILL (-9)
License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.