Skip to main content
Glama

Desktop MCP

by budaesandrei
desktop.cpython-312.pyc5.76 kB
� 3�h�� �,�ddlmZmZddlZddlZddlmZddlmZm Z m Z ddl m Z ddl mZddlmZddlZddlZedd g� �Zej)d ee d � �dee fd��Zej-de ee fd� �ddedede ee ffd��Zy)�)� APIRouter� HTTPExceptionN)�Image)�List�Dict�Any)� ScreenInfoOut)� ContextMode)� RectRequestz/desktop�Desktop)�prefix�tagsz/screens�get_screen_info)�response_model� operation_id�returnc��K�tj�D�cgc]}tdi|j����}}|Scc}w�w)ayGet information about all connected screens/monitors. Returns detailed information about each connected display including position, resolution, and physical dimensions. This information is essential for determining screenshot coordinates and understanding multi-monitor layouts. Returns: List of screen objects, each containing: - x, y: Screen position in virtual desktop coordinates - width, height: Screen resolution in pixels - name: Display name/identifier - is_primary: Boolean indicating if this is the primary display - width_mm, height_mm: Physical dimensions in millimeters Example: For 3 horizontally aligned 1920x1080 screens: - Screen 1: x=0, y=0, width=1920, height=1080 - Screen 2: x=1920, y=0, width=1920, height=1080 - Screen 3: x=3840, y=0, width=1920, height=1080 �)� screeninfo� get_monitorsr �__dict__)�x�screenss �*B:\projects\desktop-mcp\app\api\desktop.pyrrs>����.5?�4K�4K�4M�N�4M�q�}�*�q�z�z�*�4M�G�N� �N��O�s �>�9� >z /screenshot�desktop_take_screenshot�rect� context_modec���K�t|j�j} |j|j|j |j f}tjd|��}|j\}}|d}||kDs||kDrZt||z ||z �}t||z�} t||z�} |j| | ftjj�}t!j"�} |j%| d|ddd��t'j(| j+��j-d�} d d d d | d �d�giS#t.$r} t1ddt3| ������d} ~ wwxYw�w)a�Take a screenshot of a specific region across all connected screens. Captures a rectangular region from the virtual desktop spanning all monitors. Use get_screen_info() first to determine proper coordinates for targeting specific screens or regions. Images are automatically compressed to optimize for AI processing while maintaining visual clarity. Args: rect: Rectangle coordinates defining the capture area - x, y: Top-left corner of the region in virtual desktop coordinates - width, height: Dimensions of the capture region in pixels context_mode: Image quality/size mode (default: "minimal") - "minimal": 600px max, 30% quality - for basic UI detection - "normal": 800px max, 50% quality - for detailed UI inspection - "detailed": 1200px max, 70% quality - for pixel-perfect UI analysis Returns: Dictionary containing base64-encoded WEBP image data optimized for AI analysis. Usage Examples: - Single screen (1920x1080): x=0, y=0, width=1920, height=1080 - Second screen (horizontally aligned): x=1920, y=0, width=1920, height=1080 - Custom region: x=500, y=300, width=800, height=600 Note: Coordinates are based on the virtual desktop layout returned by get_screen_info(). For multi-monitor setups, screens may be arranged horizontally, vertically, or in custom configurations affecting the coordinate system. Use this at minimal settings unless absolutely necessary to avoid filling the chat context. Raises: HTTPException: If screenshot capture fails or coordinates are invalid. T)� allScreens�region�max_dim�WEBP�quality�)�formatr#�optimize�methodzutf-8�context�image�base64z image/webp)�type� media_type�data)r+�sourcei�zScreenshot capture failed: )� status_code�detailN)r �upper�valuer�y�width�height� pyautogui� screenshot�size�min�int�resizer� Resampling�LANCZOS�io�BytesIO�saver*� b64encode�getvalue�decode� Exceptionr�str)rr�settingsr r7r4r5r!�ratio� new_width� new_height�buffer� img_base64�es rrr,su����H�<�-�-�/�0�6�6�H�\��&�&�$�&�&�$�*�*�d�k�k�:���)�)�T�&�I� �"��� ��v��9�%�� �7�?�f�w�.���%���6�)9�:�E��E�E�M�*�I��V�e�^�,�J�#�*�*�I�z�+B�E�DT�DT�D\�D\�]�J����������v�x� �7J�UY�bc��d��%�%�f�o�o�&7�8�?�?��H� � �#� (�&2� *��� �  � �� �\���6Q�RU�VW�RX�QY�4Z�[�[��\�s)�"E7�D'E � E7� E4�E/�/E4�4E7)�minimal)�fastapirrr>r*�PILr�typingrrr�app.schemas.screeninfor �app.schemas.enumsr �app.schemas.rectr rr6�router�getr�postrErr�r�<module>rXs���,� � ��"�"�0�)�(��� �*�I�;� 7�����J�t�M�':�IZ��[��t�M�2��\��6���]�4��S��>�Ha��b�D\� �D\�3�D\�W[�\_�ad�\d�We�D\�c�D\rW

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/budaesandrei/desktop-mcp'

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