Skip to main content
Glama

qudi MCP Integration

by dirkenglund
instrument_tools.cpython-311.pyc9.31 kB
� �+�h�'��P�dZddlZddlmZmZmZmZddlmZGd�d��Z dS)z� Instrument control tools for qudi MCP integration Handles instrument loading, parameter management, and control operations through qudi's instrument abstraction layer. �N)�Dict�List�Any�Optional�)�RunLevelc�\�eZdZdZd�Zdedeeefdeeeffd�Zdeeefdeeeffd�Z deeefdeeeffd �Z deeefdeeeffd �Z deeefdeeeffd �Z deeefdeeeffd �Z d edeeeffd�ZdS)�InstrumentToolsz'Instrument control and management toolsc�F�||_tjd��|_dS)Nzqudi-mcp.instruments)�server�logging� getLogger�logger)�selfr s �^/Users/englund/Projects/QPG-MIT/qudi-iqo-modules-QPG/mcp_integration/tools/instrument_tools.py�__init__zInstrumentTools.__init__s ���� ��'�(>�?�?�� � � ��name� arguments�returnc��K�|j|j|j|j|jd�}||vrdd|��iS|||���d{V��S)zRoute instrument tool calls)zinstrument.listzinstrument.loadzinstrument.get_parameterszinstrument.set_parameterzinstrument.get_status�errorzUnknown instrument tool: N)�_list_instruments�_load_instrument�_get_parameters�_set_parameter� _get_status)rrr�tool_maps r� handle_toolzInstrumentTools.handle_toolsy���� $�5�#�4�)-�)=�(,�(;�%)�%5�  � �� �x� � ��?��?�?�@� @�#�X�d�^�I�.�.�.�.�.�.�.�.�.r�argsc ���K�|jjtjkr9ddddd�ddddd�d ddd d�d d dd d�ddddd�ddddd�g|jjjdd�Sg|jjjdd�S)zList available instruments�laser_controller�laser� availablez0Main laser controller for quantum dot excitation)r�type�status� description�gate_dac�dacz+Gate voltage DAC for quantum device control�bias_daczBias voltage DAC�photon_counter�counterzSingle photon counting module� spectrometerzHigh resolution spectrometer�temperature_controller� temperaturezCryostat temperature controllerzSimulated instrument list)� instruments�runlevel�messagez9qudi station not connected - use dry-run mode for testing)r r1r�DRY_RUN�value)rr s rrz!InstrumentTools._list_instruments$s����� �;� �8�#3� 3� 3� !3� '�"-�'Y� ��!+� %�"-�'T� ��!+� %�"-�'9� ��!1� )�"-�'F� ��!/� .�"-�'E� ��!9� -�"-�'H� ��?% �L!�K�0�6�6�Q)�)�) �Z�� �,�2�R� � � rc���K�|�d��}|sddiS|jjtjkr@|dd|�|��d�|jj|<d|d|��|jjjd �Sdd d �S) z!Load and initialize an instrument�instrument_namer�instrument_name is required� simulated�loaded)rr%r&� parameters�successzSimulated loading of )r&� instrumentr2r1z>Real instrument loading not yet implemented - use dry-run mode)r&r2)�getr r1rr3�_get_simulated_parametersr0r4)rr r6s rrz InstrumentTools._load_instrument[s������(�(�#4�5�5��� <��:�;� ;� �;� �8�#3� 3� 3�(�#�"�"�<�<�_�M�M� 8�8�D�K� #�O� 4�$�-�D�?�D�D� �K�0�6� �� ��W� � � rc���K�|�d��}|sddiS||jjvrdd|�d�iS|jjtjkr+|�|��}|||jjjdd�SddiS) z,Get instrument parameters and current valuesr6rr7� Instrument � not loadedzSimulated parameter values)r<r:r1r2z*Real parameter reading not yet implemented)r=r r0r1rr3r>r4)rr r6r:s rrzInstrumentTools._get_parametersxs������(�(�#4�5�5��� <��:�;� ;� �$�+�"9� 9� 9��G�?�G�G�G�H� H� �;� �8�#3� 3� 3��7�7��H�H�J�-�(� �K�0�6�7� �� � �A� � rc��K�|�d��}|�d��}|�d��}t|||dug��sddiS|jj�||��\}}|sdd|��iS|jjt jkrd|||d |�d |��|d �S|jjt jkrdd iSd|||d |�d |��|d �S)z/Set instrument parameter with safety validationr6�parameter_namer4Nrz7instrument_name, parameter_name, and value are requiredzSafety violation: r;zDry-run: Would set z = )r&r<� parameterr4r2� safety_checkz?LIVE mode parameter setting requires approval (not implemented)zSimulated: Set ) r=�allr �safety_checker�validate_parameterr1rr3�LIVE)rr r6rCr4�is_safer2s rrzInstrumentTools._set_parameter�sA�����(�(�#4�5�5�����"2�3�3������!�!���O�^�U�$�5F�G�H�H� X��V�W� W� �;�5�H�H��Y^�_�_����� =��;�'�;�;�<� <� �;� �8�#3� 3� 3�#�-�+��K��K�K�E�K�K� '� �� � �;� �8�=� 0� 0��Z�� �  �)�'��C��C�C�E�C�C�#�  � � rc ���K�|�d��}|sRd�|jj���D��t |jj��|jjjd�S||jjvrdd|�d�iS|jj|}||�dd��|�d d��t |�d i����|jjjd �S) zGet instrument statusr6c�B�i|]\}}||�dd����S)r&�unknown�r=)�.0r�instrs r� <dictcomp>z/InstrumentTools._get_status.<locals>.<dictcomp>�s<��$�$�$�#��e��%�)�)�H�i�8�8�$�$�$r)�all_instruments� loaded_countr1rr@rAr&rMr%r:)r<r&r%r:r1)r=r r0�items�lenr1r4)rr r6r<s rrzInstrumentTools._get_status�s �����(�(�#4�5�5��� �$�$�'+�{�'>�'D�'D�'F�'F�$�$�$�!$�D�K�$;� <� <� �K�0�6� �� � �$�+�"9� 9� 9��G�?�G�G�G�H� H��[�,�_�=� �)� �n�n�X�y�9�9��N�N�6�9�5�5��j�n�n�\�2�>�>�?�?�� �,�2�  � � rr6c ��ddddd�dddd d�d d dd d�d dddd�d�ddddd�ddddd�ddddd�d�dddddd�iddddd�ddddd�d�ddd d!d�ddd"dd�dddd#d�d$�d%d&d"d'd�dd(ddd�d)�d*�}|�|d+dd,dd d�i��S)-z7Get simulated parameters for different instrument typesg�?�mWgg$@)r4�unit�min�maxg�@�nmg��@gP�@gI@�mAgY@g9@�Cg4@g>@)�power� wavelength�currentr/�Vg�g@)� gate1_voltage� gate2_voltage� gate3_voltage� bias_voltageg�i��Hzri@Bg�������?�sg����MbP?)� count_rate�integration_timegy@g@�@g{�G�z�?gN@)�center_wavelength� resolutionrig������@�Kg�r@�W)r/� heater_power)r"r(r*r+r-r.� generic_param�aurN)rr6�parameter_setss rr>z)InstrumentTools._get_simulated_parameters�so�� $'��S��N�N�(-�t�E�RW�X�X�%)�4��E�R�R�)-�s�4�PT�U�U� !�!�,/��D�QT�!U�!U�+.��D�QT�!U�!U�+.��D�QT�!U�!U��� �#�s�4�PS� T� T��)-�d�1�W�U�U�.1�3�u�UY�$Z�$Z��� 05�d�5�Y_�%`�%`�(+�T�$�s�S�S�.1�3�u�UY�$Z�$Z��� *-�c�$�u�U�U�*-�s�3�t� T� T�'�'�1 � ��<�!�!�/� �s�D��U�S�S�4 � � � rN)�__name__� __module__� __qualname__�__doc__r�strrrrrrrrrr>�rrr r s�������1�1�@�@�@�/�c�/�d�3��8�n�/��c�SV�h��/�/�/�/� 5 �D��c��N�5 �t�C��H�~�5 �5 �5 �5 �n �4��S��>� �d�3��8�n� � � � �: �$�s�C�x�.� �T�#�s�(�^� � � � �0' ��c�3�h��' �D��c��N�' �' �' �' �R �d�3��8�n� ��c�3�h�� � � � �6# ��# ��c�3�h��# �# �# �# �# �# rr ) rur �typingrrrr�safetyrr rwrr�<module>rzs���������,�,�,�,�,�,�,�,�,�,�,�,�������j �j �j �j �j �j �j �j �j �j 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/dirkenglund/qudi-mcp-integration'

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