SSH MCP Server
by RobertBergman
The SSH MCP Server is a centralized management system for network devices. It leverages an SSH API to execute commands on network switches and provides advanced features for network monitoring, configuration validation, and reporting.
Last updated: N/A
SSH MCP Server
The SSH MCP (Management Control Plane) Server is a centralized management system for network devices. It leverages an SSH API to execute commands on network switches and provides advanced features for network monitoring, configuration validation, and reporting.
Features
Device Management
- Inventory of network devices with metadata (location, role, model, OS version)
- Grouping of devices by function, location, or custom attributes
- Device status tracking and availability monitoring
Command Execution
- Execute show commands on devices via the SSH API
- Schedule periodic command execution for monitoring
- Concurrent command execution across multiple devices
- Command templating with variable substitution
Data Processing
- Parse command output into structured data
- Store historical command outputs in the database
- Compare outputs across devices or time
- Detect changes in device configurations and states
Reporting
- Generate reports on device inventory, command outputs, configuration changes
- Custom report templates with different output formats (HTML, JSON, CSV)
- Scheduled report generation and distribution
Requirements
- Python 3.8+
- PostgreSQL 12+
- Redis (for task queue)
- SSH API Service (for device communication)
Installation
- Clone the repository:
git clone https://github.com/your-org/ssh-mcp-server.git
cd ssh-mcp-server
- Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration settings
- Set up the database:
# Create PostgreSQL database
createdb mcp_server
# Run Alembic migrations
alembic upgrade head
- Start the server:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
Configuration
The application can be configured through environment variables or the .env
file:
DATABASE_URL
: PostgreSQL connection stringREDIS_HOST
andREDIS_PORT
: Redis connection detailsSSH_API_URL
: URL of the SSH API serviceSECRET_KEY
: Secret key for JWT authentication- See
.env.example
for all available configuration options
API Documentation
When the server is running, API documentation is available at:
- Swagger UI: http://localhost:8000/api/v1/docs
- ReDoc: http://localhost:8000/api/v1/redoc
Development
Running Tests
pytest
Creating a New Migration
After making changes to the models:
alembic revision --autogenerate -m "Description of changes"
alembic upgrade head
Architecture
The application follows a modular architecture with the following components:
- API Layer: FastAPI routes for HTTP endpoints
- Service Layer: Business logic and operations
- Data Models: Database models using SQLAlchemy
- Schemas: Pydantic models for request/response validation
- Background Tasks: Celery workers for asynchronous processing
Security
- JWT token-based authentication
- Role-based access control
- Encrypted storage of device credentials
- HTTPS for all communications