Skip to main content
Glama
LGDiMaggio

Predictive Maintenance MCP Server

by LGDiMaggio

train_anomaly_model

Train an anomaly detection model using healthy vibration data to identify machinery faults. Supports unsupervised and semi-supervised modes with optional hyperparameter tuning.

Instructions

    Train ML-based anomaly detection model on healthy data (UNSUPERVISED/SEMI-SUPERVISED).

    Complete pipeline:
    1. Extract features from healthy signals (segmentation + time-domain features)
    2. Standardize features (StandardScaler - fitted on training data only)
    3. Dimensionality reduction (PCA with specified variance explained)
    4. Train novelty detection model (OneClassSVM or LocalOutlierFactor) on HEALTHY DATA ONLY
    5. Optional hyperparameter tuning using validation data (semi-supervised)
    6. Save model, scaler, and PCA transformer

    **Training Mode:**
    - UNSUPERVISED: Train only on healthy data with automatic hyperparameters
    - SEMI-SUPERVISED: Train on healthy data, tune hyperparameters using validation set (healthy + fault)

    **Note:** This is NOT supervised learning. OneClassSVM/LOF are trained ONLY on healthy data.
    Fault data (if provided) is used ONLY for hyperparameter tuning after training.

    **Validation Strategy:**
    - If healthy_validation_files provided: Use those explicitly (no split)
    - If healthy_validation_files NOT provided: Automatic 80/20 split of training data
    - If fault_signal_files provided: Enable semi-supervised mode (hyperparameter tuning)

    Args:
        healthy_signal_files: List of CSV files with healthy machine data (for training)
        sampling_rate: Sampling frequency in Hz (auto-detect from metadata if None)
        segment_duration: Segment duration in seconds (default: 0.1)
        overlap_ratio: Overlap ratio 0-1 (default: 0.5)
        model_type: 'OneClassSVM' or 'LocalOutlierFactor' (default: 'OneClassSVM')
        pca_variance: Cumulative variance to explain with PCA (default: 0.95)
        fault_signal_files: Optional list of fault signals for HYPERPARAMETER TUNING (semi-supervised)
        healthy_validation_files: Optional list of healthy signals for validation (specificity check).
                                  If not provided, 20% of training data will be used.
        model_name: Name for saved model files (default: 'anomaly_model')
        ctx: MCP context for progress/logging

    Returns:
        AnomalyModelResult with model paths and performance metrics
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
healthy_signal_filesYes
sampling_rateNo
segment_durationNo
overlap_ratioNo
model_typeNoOneClassSVM
pca_varianceNo
fault_signal_filesNo
healthy_validation_filesNo
model_nameNoanomaly_model

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_typeYesType of model: 'OneClassSVM' or 'LocalOutlierFactor'
num_training_samplesYesNumber of healthy samples used for training
num_features_originalYesNumber of original features
num_features_pcaYesNumber of PCA components (features after dimensionality reduction)
variance_explainedYesCumulative variance explained by PCA components
model_paramsYesBest model hyperparameters
model_pathYesPath to saved model file (.pkl)
scaler_pathYesPath to saved scaler file (.pkl)
pca_pathYesPath to saved PCA file (.pkl)
validation_accuracyNoOverall balanced accuracy on healthy + fault validation data
validation_detailsNoValidation details with healthy and fault metrics
validation_metricsNoDetailed validation metrics (healthy/fault accuracy breakdown)
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fully discloses the behavioral traits: complete pipeline steps, training mode logic, data usage (healthy only for training, fault for tuning), and validation strategy. It leaves no ambiguity about the process.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is longer but well-structured with headers, pipeline steps, and bulleted lists. It is front-loaded with purpose and pipeline, making it easy to scan. Every sentence adds value, though some rephrasing could reduce length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity and absence of annotations, the description is exceptionally complete. It covers the entire training workflow, data handling, validation strategy, and expected output (AnomalyModelResult). No important gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must carry full weight. It provides detailed explanations for all parameters, including defaults, optionality, and how they affect training (e.g., pca_variance, model_type). This compensates for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it trains an ML-based anomaly detection model on healthy data using unsupervised or semi-supervised methods. It distinguishes itself from sibling tools like 'predict_anomalies' by focusing on training, not prediction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use the tool (training anomaly model) and details the two modes (unsupervised/semi-supervised). It does not explicitly compare to other tools but provides clear context for use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LGDiMaggio/predictive-maintenance-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server