MCP Terminal Server
About
A lightweight FastAPI server that can run as a Windows service and exposes an endpoint to execute shell commands and stream their output
Details
- Author
- cwmoore-ai
- Downloads
- 322
- Categories
- Developer Tools
Jump to
- Run as a Windows service or in debug mode
- Execute shell commands and stream output in real-time
- API key authentication and rate limiting
- Configurable via environment variables or configuration file
- Robust error handling and logging
- Automatic process restart on failure
Install via the provided PowerShell script (install_service.ps1) with optional parameters for API key, port, host, and log level. Configure through environment variables or a JSON config file. Manage the service using service.py commands (install, start, stop, restart, remove, debug). Use the test client (test_client.py) or call the API endpoints directly (POST /run, GET /health) with the API key in the X-API-Key header.
MCP Terminal Server
A lightweight FastAPI server that can run as a Windows service and exposes an endpoint to execute shell commands and stream their output.
Features
- Run as a Windows service or in debug mode
- Execute shell commands and stream their output in real-time
- API key authentication
- Rate limiting
- Configurable via environment variables or configuration file
- Robust error handling and logging
- Automatic process restart on failure
Installation
Prerequisites
- Windows operating system
- Python 3.7 or higher
- Administrator privileges (for service installation)
Install Steps
1. Clone this repository or download the source code
2. Open PowerShell as Administrator
3. Navigate to the project directory
4. Run the installation script:
.\install_service.ps1
This will:
- Install required Python dependencies
- Generate a random API key (or use the one you provide)
- Create a configuration file
- Install and start the Windows service
Installation Options
You can customize the installation with the following parameters:
.\install_service.ps1 -ApiKey "your-api-key" -Port 8080 -Host "127.0.0.1" -LogLevel "debug"
Available parameters:
- -ApiKey: Custom API key for authentication
- -Port: Port number for the server (default: 8000)
- -Host: Host address to bind to (default: 0.0.0.0)
- -LogLevel: Log level (debug, info, warning, error, critical)
- -ConfigFile: Path to a custom configuration file
Configuration
The server can be configured through:
1. Environment variables
2. Configuration file (config.json)
3. Command-line arguments during installation
Configuration File
A sample configuration file (config.json.sample) is provided. You can copy this to config.json and modify it:
{
"host": "0.0.0.0",
"port": 8000,
"log_level": "info",
"log_file": "mcp_terminal_server.log",
"max_log_size_mb": 10,
"log_backup_count": 5,
"restart_on_failure": true,
"max_restart_attempts": 5,
"restart_delay_seconds": 10,
"shutdown_timeout_seconds": 30,
"working_directory": null
}
Environment Variables
You can also configure the server using environment variables:
- MCP_TERMINAL_API_KEY: API key for authentication
- MCP_HOST: Host address to bind to
- MCP_PORT: Port number for the server
- MCP_LOG_LEVEL: Log level
- MCP_LOG_FILE: Path to log file
- MCP_MAX_LOG_SIZE_MB: Maximum log file size in MB
- MCP_LOG_BACKUP_COUNT: Number of log backup files to keep
- MCP_RESTART_ON_FAILURE: Whether to restart the server on failure
- MCP_MAX_RESTART_ATTEMPTS: Maximum number of restart attempts
- MCP_RESTART_DELAY_SECONDS: Delay between restart attempts
- MCP_SHUTDOWN_TIMEOUT_SECONDS: Timeout for graceful shutdown
- MCP_WORKING_DIRECTORY: Working directory for the server
Service Management
Service Commands
The service can be managed using the following commands:
```powershell
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





