MCP-Client-Server-with-LLM-Command-Execution
Machine Command Processor (MCP) is a client-server system that uses LLMs to convert natural language queries into shell commands.
Machine Command Processor (MCP)
A client-server system that uses LLMs to convert natural language queries into shell commands. The system consists of three main components: a client that processes natural language queries through Groq's LLM API, a server that executes shell commands, and a shared protocol for communication.
Features
- Natural language to shell command conversion using Groq's LLM API
- WebSocket-based client-server communication
- Command execution safety checks
- Comprehensive logging system
- Asynchronous operation using Python's asyncio
- Structured message protocol with UUID tracking
Prerequisites
- Python 3.7+
- Groq API key
- WebSocket support
- Required Python packages:
- websockets
- groq
- asyncio
- logging
Installation
- Clone the repository
- Install required packages:
pip install websockets groq
- Set up your Groq API key:
export GROQ_API_KEY='your-api-key'
Components
MCP Client (mcp_client.py
)
- Handles user input
- Connects to Groq API for command generation
- Communicates with server via WebSocket
- Processes and displays results
MCP Server (mcp_server.py
)
- Executes shell commands
- Implements command safety checks
- Manages WebSocket connections
- Returns command execution results
Protocol (mcp_protocol.py
)
- Defines message structure
- Handles message serialization/deserialization
- Provides message creation utilities
Usage
- Start the server:
python mcp_server.py
- In a separate terminal, start the client:
python mcp_client.py
- Enter natural language queries when prompted. For example:
Enter your query: list all files in the current directory
Security Features
- Blocked dangerous commands including:
- sudo
- rm -rf
- mkfs
- dd
- format
- Command validation before execution
- Logged operations for audit trails
Logging
The system maintains two log files:
mcp_client.log
: Client-side operations and LLM interactionsmcp_server.log
: Server-side operations and command execution
Contributing
[Add contribution guidelines here]
Related MCP Servers
View all os_automation servers →DesktopCommanderMCP
by wonderwhy-er
Desktop Commander MCP is a tool that allows users to search, update, manage files, and run terminal commands using AI, without incurring API token costs.
Daytona
by daytonaio
Daytona MCP Server allows AI agents to manage and interact with Daytona sandboxes, execute commands, perform file operations, and generate preview links for web applications.
apple-mcp
by supermemoryai
This is a collection of Apple-native tools for the Model Context Protocol (MCP) that integrates with various Apple applications to automate tasks and manage communications.
mcp-shrimp-task-manager
by cjo4m06
MCP Shrimp Task Manager is an intelligent task management system based on Model Context Protocol (MCP), designed to enhance programming workflows for AI Agents.
Cua Agent
by trycua
cua-mcp-server is a Model Context Protocol (MCP) server for the Computer-Use Agent (CUA), enabling integration with Claude Desktop and other MCP clients.
kubectl-mcp-server
by rohitg00
Kubectl MCP Server is a Model Context Protocol server for Kubernetes, enabling AI assistants to interact with Kubernetes clusters using natural language.
mcp-datetime
by ZeparHyfar
A datetime formatting service implemented as an MCP server for the Claude Desktop Application.