ashwinjo/cyperf-ce-mcp-rest
If you are the rightful owner of cyperf-ce-mcp-rest and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The REST Powered Cyperf CE Controller is a FastAPI-based web application designed to manage Keysight Cyperf CE Client and Server Tests via SSH.
REST Powered Cyperf CE Controller
A FastAPI-based web application to control Keysight Cyperf CE Client and Server Tests via SSH.
Features
- Start/stop Cyperf server and client remotely via REST API
- SSH authentication via private key or username/password
- Dockerized for easy deployment
- Collects and returns test statistics
Requirements
- Python 3.11+
- Docker (for containerized deployment)
- Access to remote machines with Cyperf installed
Environment Variables
The application is configured via environment variables (or a .env file):
| Variable | Description | Example |
|---|---|---|
| SERVER_IP | IP address of the Cyperf server | 100.25.44.178 |
| CLIENT_IP | IP address of the Cyperf client | 34.218.246.113 |
| SSH_USERNAME | SSH username for both server and client | ubuntu |
| SSH_KEY_PATH | Path to SSH private key (inside container) | /home/ubuntu/vibecode.pem |
| SSH_PASSWORD | (Optional) SSH password for authentication | yourpassword |
- If
SSH_PASSWORDis set, the app uses username/password authentication. - If not, it uses the SSH key at
SSH_KEY_PATH.
Local Development
-
Install dependencies:
pip install -r requirements.txt -
Create a
.envfile:SERVER_IP=100.25.44.178 CLIENT_IP=34.218.246.113 SSH_USERNAME=ubuntu SSH_KEY_PATH=/path/to/vibecode.pem # SSH_PASSWORD=yourpassword # Uncomment to use password auth -
Run the app:
uvicorn main:app --reload
Docker Usage
Build the image:
docker build -t cyperf-app .
Run the container:
docker run -d -p 8000:8000 \
-e SERVER_IP=100.25.44.178 \
-e CLIENT_IP=34.218.246.113 \
-e SSH_USERNAME=ubuntu \
-e SSH_KEY_PATH=/home/ubuntu/vibecode.pem \
-v /path/to/vibecode.pem:/home/ubuntu/vibecode.pem:ro \
cyperf-app
- To use password authentication, add
-e SSH_PASSWORD=yourpasswordand omit the-v/SSH_KEY_PATHoptions.
Using a .env file:
docker run -d -p 8000:8000 --env-file .env \
-v /path/to/vibecode.pem:/home/ubuntu/vibecode.pem:ro \
cyperf-app
API
- The API is served at:
http://localhost:8000/api/ - Interactive docs:
http://localhost:8000/docs
SSH Authentication
- Key-based: Mount your private key into the container and set
SSH_KEY_PATH. - Password-based: Set
SSH_PASSWORD(do not setSSH_KEY_PATH).
MCP (Model Context Protocol) Support
This application now supports MCP (Model Context Protocol) for integration with MCP clients like Claude Desktop, Cursor, and other AI assistants.
MCP Server Setup
The MCP server wraps the FastAPI endpoints and exposes them as tools that can be used by MCP clients.
Available MCP Tools:
- start_cyperf_server - Start a Cyperf CE server
- start_cyperf_client - Start a Cyperf CE client
- get_server_stats - Get server statistics
- get_client_stats - Get client statistics
- get_server_stats_image - Get server stats as image
- get_client_stats_image - Get client stats as image
- stop_server - Stop all servers
Running with Docker Compose (MCP + FastAPI):
-
Create environment file:
# .env file SERVER_IP=100.25.44.178 CLIENT_IP=34.218.246.113 SSH_USERNAME=ubuntu SSH_KEY_PATH=/home/ubuntu/vibecode.pem SSH_KEY_HOST_PATH=/path/to/your/vibecode.pem # SSH_PASSWORD=yourpassword # Optional: for password auth -
Start both services:
docker-compose -f docker-compose.mcp.yml up -dThis starts:
- FastAPI service on
http://localhost:8000 - MCP server ready for stdio connection
- FastAPI service on
Running MCP Server Standalone:
# Build the image
docker build -f Dockerfile.mcp -t cyperf-mcp .
# Run MCP server
docker run -it --rm \
-e SERVER_IP=100.25.44.178 \
-e CLIENT_IP=34.218.246.113 \
-e SSH_USERNAME=ubuntu \
-e SSH_KEY_PATH=/home/ubuntu/vibecode.pem \
-v /path/to/vibecode.pem:/home/ubuntu/vibecode.pem:ro \
cyperf-mcp mcp
Using with MCP Clients:
HTTP Streamable (Recommended):
Option 1: SSE (Server-Sent Events) Server
The dedicated SSE server provides the most robust streaming experience:
# Start your main FastAPI app first
uvicorn main:app --host 0.0.0.0 --port 8000 &
# Start the MCP SSE server
python mcp_sse_server.py --host 0.0.0.0 --port 8001
Claude Desktop Configuration for SSE:
{
"mcpServers": {
"cyperf-ce-controller": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"],
"env": {
"MCP_SERVER_URL": "http://localhost:8001/sse"
}
}
}
}
Option 2: Direct HTTP Endpoint
Your FastAPI app includes a /api/mcp endpoint for simple HTTP-based MCP:
Claude Desktop Configuration for HTTP:
{
"mcpServers": {
"cyperf-ce-controller": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"],
"env": {
"MCP_SERVER_URL": "http://localhost:8000/api/mcp"
}
}
}
}
Direct stdio (Alternative):
Add to your claude_desktop_config.json:
{
"mcpServers": {
"cyperf-ce-controller": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--env-file", "/path/to/.env",
"-v", "/path/to/vibecode.pem:/home/ubuntu/vibecode.pem:ro",
"cyperf-mcp", "mcp"
]
}
}
}
Direct Python Execution:
# Make sure FastAPI is running first
uvicorn main:app --host 0.0.0.0 --port 8000 &
# Run MCP server
python mcp_server.py
MCP Usage Examples:
Once connected to an MCP client, you can:
-
Start a server test:
Use the start_cyperf_server tool with port 5202 and csv_stats enabled -
Connect a client:
Use start_cyperf_client with the test_id from server, server IP, and run for 120 seconds -
Get statistics:
Use get_server_stats or get_client_stats with the test_id -
Visualize data:
Use get_server_stats_image to get a visual table of the statistics
Testing the MCP Endpoints:
Testing the SSE Server:
# Test SSE server health
curl http://localhost:8001/health
# Test SSE endpoint (requires SSE client or tools like curl with --no-buffer)
curl -X POST http://localhost:8001/sse \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-N \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
# If you get the "Not Acceptable" error, make sure to include the Accept header:
curl -X POST http://localhost:8001/sse \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-N \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "test-client",
"version": "1.0.0"
}
}
}'
Testing the Direct HTTP Endpoint:
You can test the MCP endpoint directly with curl:
# Test MCP initialization
curl -X POST http://localhost:8000/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "test-client",
"version": "1.0.0"
}
}
}'
# List available tools
curl -X POST http://localhost:8000/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}'
# Call a tool (start server)
curl -X POST http://localhost:8000/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "start_cyperf_server",
"arguments": {
"port": 5202,
"csv_stats": true
}
}
}'
License
MIT