MCP Terminal Server
This server allows you to securely execute terminal commands with controlled access and resource management:
Command Execution: Run shell commands and capture their output (stdout, stderr) along with exit codes
Security Controls: Restrict commands to a predefined list to prevent unauthorized actions and command injection
Resource Management: Set limits on execution time (timeout) and maximum output size to prevent resource exhaustion
Customizable Settings: Configure allowed commands and resource limits on a per-request basis
Communication: Uses the Model Context Protocol (MCP) for interaction
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Terminal Server list files in the current directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Related MCP server: MCP Terminal
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 uvInstall the Package using UV:
uv pip install mcp-terminalConfigure 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" },
"startTime": { "type": "string" },
"endTime": { "type": "string" }
}
}
}
}
}Message Format
Request:
{
"type": "execute",
"data": {
"command": "echo 'hello world'"
}
}Response:
{
"type": "result",
"data": {
"command": "echo 'hello world'",
"exitCode": 0,
"stdout": "hello world\n",
"stderr": "",
"startTime": "2024-01-20T12:34:56.789Z",
"endTime": "2024-01-20T12:34:56.790Z"
}
}Error:
{
"type": "error",
"data": {
"message": "command not allowed"
}
}Security Considerations
Command Validation:
Only allowed commands can be executed
Shell operators are blocked
Command injection attempts are prevented
Resource Protection:
Command timeouts prevent hanging
Output size limits prevent memory exhaustion
Error handling for all failure cases
Best Practices:
Always set
allowed-commandsin productionUse conservative timeout and size limits
Monitor command execution logs
Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Available Tools
1 toolrun_commandC
Run a terminal command with security controls.
Inputs: command (required), allowedCommands, maxOutputSize, timeoutMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as running terminal commands with security controls, making it distinct by default.
The single tool follows a clear verb_noun pattern (run_command), which is consistent and predictable. Since there are no other tools to compare against, it inherently maintains perfect naming consistency.
A single tool for a terminal server is too few for the apparent scope, as terminal operations typically involve multiple actions (e.g., list files, navigate directories, monitor processes). This minimal set feels thin and incomplete for the domain.
The tool surface is severely incomplete for a terminal server domain. While run_command covers command execution, there are obvious gaps such as listing files, checking system status, or managing processes, which will likely cause agent failures in typical terminal workflows.
Maintenance
Related MCP Connectors
Termalin's hosted MCP server. Claude, ChatGPT or any MCP client runs commands, moves files over SFTP, queries databases and reads server metrics and monitoring alerts on your servers, keylessly through Termalin Connectors: no SSH key is handed over and no inbound port is opened. Per-host command policy and an audit log. Needs a termal.in Pro or Team account (new accounts start with a 14-day Pro trial).
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Related MCP Servers
- AlicenseAqualityAmaintenanceA secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.1202MIT
- AlicenseCqualityDmaintenanceA server that enables AI assistants to execute terminal commands and retrieve outputs via the Model Context Protocol (MCP).326MIT
- AlicenseCqualityDmaintenanceA secure server that implements the Model Context Protocol (MCP) to enable controlled execution of authorized shell commands with stdin support.1MIT
- AlicenseBqualityCmaintenanceA secure Model Context Protocol server that allows AI assistants to execute terminal commands with controlled directory access and command permissions. It features a robust security architecture including whitelisting, session IDs, and categorized command levels to ensure safe system interaction.8MIT