Skip to main content
Glama

Anomaly Detection MCP Server

by Javoo-bot
utils.cpython-311.pyc5.23 kB
� �� h� ���ddlZddlZddlmZmZddlZd d�Zd d�Zd�Z gd�Z d �Z e d kre��e d ��dSdS)�N)�datetime� timedelta�data/sensor_data.csv�`c�n� �tjtj�|��d���t ddd��� � fd�t |��D��}d�t |��D��}d�t |��D��}d�t |��D��}d }t |d z |d z��D];}|t |��kr&d tj� d d��z||<�<tj |dg|z|||d���}|� |d���|S)z0Generate sample sensor data with some anomalies.T)�exist_oki��c�<��g|]}�td|z���z��S)�)�minutes)r)�.0�i� start_times ��;C:\Users\jlmenendez\Desktop\test\anomaly_detection\utils.py� <listcomp>z(generate_sample_data.<locals>.<listcomp>s-���U�U�U�Q�*�y��a��8�8�8�8�U�U�U�c�T�g|]%}dtj�dd��z��&S)g6@rg333333�?��np�random�normal�r �_s rrz(generate_sample_data.<locals>.<listcomp>s/��O�O�O�q�4�"�)�*�*�1�c�2�2�2�O�O�Orc�T�g|]%}dtj�dd��z��&S)g�F@rg�?rrs rrz(generate_sample_data.<locals>.<listcomp>s/��L�L�L�A��r�y�'�'��3�/�/�/�L�L�Lrc�T�g|]%}dtj�dd��z��&S)g��@rg�������?rrs rrz(generate_sample_data.<locals>.<listcomp>s/��N�N�N�a����)�)�!�S�1�1�1�N�N�Nr�0��g�A@rg�?�S001)� timestamp� sensor_id� temperature�humidity�pressureF)�index) �os�makedirs�path�dirnamer�range�lenrrr�pd� DataFrame�to_csv) �filename� num_samples� timestampsr"r#r$� noon_indexr�dfrs @r�generate_sample_datar4s\����K������)�)�D�9�9�9�9��$��1�%�%�J�U�U�U�U�%� �BT�BT�U�U�U�J�P�O�E�+�<N�<N�O�O�O�K�L�L��{�9K�9K�L�L�L�H�N�N�5��;M�;M�N�N�N�H��J� �:��>�:��>� 2� 2�=�=�� �s�;��� � �!�B�I�$4�$4�Q��$<�$<�<�K��N�� ��#� ��K�/�&� � �  � � � �B��I�I�h�e�I�$�$�$� �Irc�*�tj|��S)zLoad sensor data from CSV file.)r,�read_csv)r/s r�load_sensor_datar7+s�� �;�x� � � rc ��t|d��}dt|���d|�d�}|dkrT||d}|���D]0\}}|d|d�d|d �d |d �d |d d�d� z }�1n|dz }|S)z0Format detection results into a readable report.� is_anomalyzW Anomaly Detection Report ======================== Total samples analyzed: z Anomalies detected: z Anomaly Details: rz - Timestamp: r z Sensor: r!z Temperature: r"u°C Deviation: � anomaly_scorez.2fz z' No anomalies detected in the data.)�sumr+�iterrows)�results� anomaly_count�report� anomalies�idx�rows r� format_reportrC0s����� �-�.�.�M��!��\�\���'� ���F��q����G�L�1�2� �!�*�*�,�,� � �H�C�� ���k�"����;����� �&����o�&� ���� �F�F� � �<�<�� �Mr��reset_hvac_system�recalibrate_sensor�activate_backup_cooling�notify_maintenance_team�adjust_temperature_thresholdc�@�|tvrd|�d�Sdddddd�}||S) z(Simulate executing a correction command.zError: Unknown command '�'z0HVAC system has been reset. System restarting...zESensor recalibration initiated. This will take 5 minutes to complete.zOBackup cooling system activated. Temperature should normalize in 10-15 minutes.zAMaintenance team has been notified. Ticket #MT-2025-0124 created.u7Temperature threshold adjusted from 30.0°C to 32.0°C.rD)�correction_commands)�commandr=s r�execute_commandrNWsJ���)�)�)�4�'�4�4�4�4�P�e�#t�#f�(a� ��G� �7� �r�__main__z#Sample data generated successfully!)rr)r)�pandasr,�numpyrrrr&r4r7rCrLrN�__name__�print�rr�<module>rUs�����������(�(�(�(�(�(�(�(� � � � �!�!�!�!�H!�!�!�!� ���:���� � � �  �z�������� �E� /�0�0�0�0�0��r

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/Javoo-bot/mcp_server'

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