Used in documentation examples for DNS lookups and hostname resolution tests
Provides HTTP GET request capabilities for testing endpoints, checking response headers, and verifying SSL/TLS connectivity
Runs as a containerized service with security controls including resource limits, network isolation, and minimal capabilities
Built using Flask framework to expose MCP protocol over HTTP with JSON-RPC 2.0 transport
Used in documentation examples for API testing with curl and as a target for connectivity tests
Used in documentation examples as a target for traceroute and network diagnostic commands
Integrates with Mattermost Azure OpenAI bot via MCP aggregator, enabling natural language network diagnostics and security scanning commands in chat
Integrates with Azure OpenAI bot through Mattermost for natural language command execution
Implemented using Python 3.11 with the MCP Python SDK for executing whitelisted network and system CLI commands
MCP CLI Command Server
A Model Context Protocol (MCP) server that provides safe, controlled access to common network and system CLI commands. This server enables AI assistants to execute whitelisted commands like nmap, ping, dig, and curl programmatically.
What is MCP?
The Model Context Protocol (MCP) is an open protocol that enables AI assistants like Claude to securely interact with local tools and services. This server implements MCP to provide CLI command execution capabilities.
Features
Network Diagnostic Tools (4 tools)
cli_ping - Ping hosts to check connectivity and measure latency
cli_traceroute - Trace network route to destination hosts
cli_mtr - Combined ping and traceroute diagnostic (MTR)
cli_netcat_test - Test port connectivity using netcat
Network Scanning Tools (2 tools)
cli_nmap_ping_scan - NMAP host discovery on network ranges
cli_nmap_port_scan - NMAP port scanning with service detection
DNS Tools (3 tools)
cli_dig - DNS lookups with multiple record type support
cli_host - DNS host command for quick lookups
cli_whois - WHOIS lookups for domains and IP addresses
HTTP Tools (1 tool)
cli_curl_get - HTTP GET requests with curl
Quick Start
Using Docker (Recommended)
Configuration
Edit docker-compose.yml to configure:
Using with Claude Desktop
Add to your Claude Desktop MCP configuration (~/.claude/mcp.json):
Using with MCP Aggregator
The MCP Aggregator automatically discovers this server when configured:
Tools will be available as cli_* (e.g., cli_ping, cli_nmap_port_scan)
Testing
API Endpoints
GET /health- Health checkPOST /mcp- MCP HTTP transport (JSON-RPC 2.0) - recommendedGET /mcp/list_tools- List available tools (REST)POST /mcp/call_tool- Execute a tool (REST)
Security
Whitelist-Only Approach
No Arbitrary Commands: Only predefined, whitelisted commands are allowed
Argument Validation: All arguments validated with regex patterns
No Shell Metacharacters: Blocks
;,&&,||,|,$, backticks, etc.Timeout Enforcement: All commands have maximum timeout limits
Input Validation
IP Addresses: Validated with regex (0-255 per octet)
Hostnames: RFC-compliant hostname validation
Ports: Range check (1-65535)
URLs: Protocol and format validation
CIDR Notation: IP and prefix validation
Resource Limits
CPU: Limited to 0.5 CPU cores
Memory: Limited to 512MB
Timeouts: Command-specific (5-600 seconds)
Non-Root User: Runs as unprivileged user (uid 1000)
Docker Security
No New Privileges:
security_opt: no-new-privilegesMinimal Capabilities: Only NET_RAW and NET_ADMIN for network tools
Network Isolation: Runs on isolated Docker network
Health Checks: Automated container health monitoring
Audit Logging
All commands logged with timestamps
Includes tool name, arguments, and execution time
Exit codes and errors logged for troubleshooting
Requirements
Docker & Docker Compose
Network connectivity for external scans
Sufficient permissions for network tools (NET_RAW, NET_ADMIN capabilities)
Port
3017 - HTTP server for MCP protocol
Architecture
Language: Python 3.11
Framework: Flask + MCP Python SDK
Transport: HTTP with JSON-RPC 2.0
CLI Tools: nmap, ping, curl, dig, traceroute, whois, host, netcat, mtr
Installed CLI Tools
The Docker container includes these CLI tools:
nmap - Network mapping and port scanning
iputils-ping - ICMP ping utility
curl - HTTP client
dnsutils (dig, nslookup, host) - DNS utilities
traceroute - Network path tracing
whois - Domain/IP WHOIS lookup
netcat-traditional - TCP/UDP connectivity testing
mtr-tiny - Combined ping and traceroute
Troubleshooting
Container won't start
Permission errors
Commands fail with validation errors
Ensure hostnames are valid (RFC-compliant)
IP addresses must be in dotted-quad format (192.168.1.1)
Ports must be 1-65535
No shell metacharacters allowed in arguments
Timeout errors
Increase timeout parameter in tool arguments
Check network connectivity from container
Some commands have maximum timeout limits (security)
Common Use Cases
Network Troubleshooting
Check if hosts are reachable with ping
Trace network routes to diagnose connectivity issues
Test port connectivity with netcat
Security Scanning
Discover active hosts on network with nmap
Scan ports for open services
Identify service versions
DNS Diagnostics
Look up DNS records with dig
Verify DNS configuration
Check domain ownership with WHOIS
API Testing
Test HTTP endpoints with curl
Check response headers
Verify SSL/TLS connectivity
Development
Integration with Mattermost Bot
When integrated with the Mattermost Azure OpenAI bot via the MCP aggregator:
Bot discovers tools automatically (5-minute refresh)
Tools appear as
cli_*functionsUse natural language: "Can you ping 8.8.8.8?"
Bot executes command and returns results in chat
Example conversation:
License
MIT License - See LICENSE file for details
Contributing
Contributions welcome! Please:
Fork the repository
Create a feature branch
Make your changes
Submit a pull request
Support
For issues and questions:
GitHub Issues: https://github.com/jbmurphy/mcp-cli/issues
MCP Documentation: https://modelcontextprotocol.io
Security Notice
⚠️ Important: This server executes network and system commands. While security measures are in place (whitelisting, validation, timeouts), use caution when exposing to untrusted networks or users.
Best Practices:
Run on isolated Docker network
Monitor command execution logs
Review firewall rules for outbound scanning
Limit access to trusted users/systems
Keep container updated with security patches
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Provides safe, controlled access to network and system diagnostic tools including ping, nmap, dig, traceroute, curl, and whois for troubleshooting connectivity, scanning ports, and performing DNS lookups through whitelisted commands with security validation.