
rinardnick/mcp-terminal
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
An MCP server that provides secure terminal access for Claude and other LLMs
Обзор
A secure terminal execution server implementing the Model Context Protocol (MCP). This server provides controlled command execution capabilities with security features and resource limits. - : Execute shell commands with output capture and error handling - : Restrict allowed commands and prevent command injection - : - Command timeouts - Maximum output size limits - : - Standard MCP message format - Capability advertisement - Streaming output support The MCP Inspector tool can be used to test the server implementation: 3. : Edit your Claude Desktop config file (typically at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS): The server implements the Model Context Protocol (MCP) with the following capabilities: - Only allowed commands can be executed - Shell operators are blocked - Command injection attempts are prevented - Command timeouts prevent hanging - Output size limits prevent memory exhaustion - Error handling for all failure cases 3.
README
Показан фрагмент оригинального README. Открыть оригинал.
MCP Terminal Server
A secure terminal execution server implementing the Model Context Protocol (MCP). This server provides controlled command execution capabilities with security features and resource limits.
Features
- Command Execution: Execute shell commands with output capture and error handling
- Security Controls: Restrict allowed commands and prevent command injection
- Resource Controls:
- Command timeouts
- Maximum output size limits
- MCP Protocol Support:
- Standard MCP message format
- Capability advertisement
- Streaming output support
Development
Local Setup
# Clone the repository
git clone https://github.com/RinardNick/mcp-terminal.git
cd mcp-terminal
# Create and activate virtual environment using uv
uv venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
# Install development dependencies
uv pip install -e ".[dev]"
Publishing to PyPI
# Build the package
uv pip install build
python -m build
# Upload to PyPI
uv pip install twine
python -m twine upload dist/*
Testing with MCP Inspector
The MCP Inspector tool can be used to test the server implementation:
# Install inspector
npm install -g @modelcontextprotocol/inspector
# Test server
npx @modelcontextprotocol/inspector python3 src/mcp_terminal/server.py --allowed-commands "python,pip,git,ls,cd"
Running Tests
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_terminal.py
# Run with coverage
pytest --cov=mcp_terminal tests/
Using with Claude Desktop
Once the package is published to PyPI:
-
Install UV (if not already installed):
pip install uv -
Install the Package using UV:
uv pip install mcp-terminal -
Configure Claude Desktop: Edit your Claude Desktop config file (typically at
~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS):{ "mcpServers": { "terminal": { "command": "uv", "args": [ "pip", "run", "mcp-terminal", "--allowed-commands", "python,pip,git,ls,cd", "--timeout-ms", "30000", "--max-output-size", "1048576" ] } } }
Protocol Implementation
The server implements the Model Context Protocol (MCP) with the following capabilities:
Capabilities Advertisement
{
"protocol": "1.0.0",
"name": "terminal",
"version": "1.1.0",
"capabilities": {
"execute": {
"description": "Execute a terminal command",
"parameters": {
"command": {
"type": "string",
"description": "The command to execute"
}
},
"returns": {
"type": "object",
"properties": {
"exitCode": { "type": "number" },
"stdout": { "type": "string" },
"stderr": { "type": "string" },
Установка
npx @modelcontextprotocol/inspector python3 src/mcp_terminal/server.py --allowed-commands "python,pip,git,ls,cd"Конфигурация
{
"mcpServers": {
"terminal": {
"command": "uv",
"args": [
"pip",
"run",
"mcp-terminal",
"--allowed-commands",
"python,pip,git,ls,cd",
"--timeout-ms",
"30000",
"--max-output-size",
"1048576"
]
}
}
}