main.cpython-311.pyc•3.42 kB
�
��h� � � � d dl mZ d dlmZ d dlZd dlZd dlmZ ej ej d�� � ej
e� � Z ed� � Z
dae
� � � ded efd
�� � Zd� Zd� Zed
k r e� � dS dS )� )�FastMCP)�AgentN)�get_llmz4%(asctime)s - %(name)s - %(levelname)s - %(message)s)�level�formatzbrowser-use�task�returnc � �R K � t � d| � �� � t | t �� � }|� � � � d{V ��}d|� �S # t
$ rF}t � dt |� � � �� � dt |� � � �cY d}~S d}~ww xY w)z�Run a browser automation task described in natural language using browser_use Agent, it can perform many tasks like browsing the web, searching the web, and more.
Args:
task: Natural language description of the task to perform
zStarting browser task: )r �llmNzTask completed: zError in async browser task: zError performing task: )�logger�infor r �run� Exception�error�str)r �agent�result�es �4/home/pietro/browser-use-mcp/browser_use_mcp/main.py�run_browser_use_taskr s� � � � � 2����4�d�4�4�5�5�5��4�S�)�)�)���y�y�{�{�"�"�"�"�"�"��*�&�*�*�*��� 2� 2� 2����=�S��V�V�=�=�>�>�>�1��Q���1�1�1�1�1�1�1�1�����2���s �AA �
B&� ;B!�B&�!B&c � � t j d�� � } | � ddt dd�� � | � � � S )zParse command line arguments.zBrowser Use MCP Server)�descriptionz--modelz-mNzGSpecify the model to use. Overrides the default model for the provider.)�type�default�help)�argparse�ArgumentParser�add_argumentr �
parse_args)�parsers r r r ( sV � �
�
$�1I�
J�
J�
J�F�
�����
��
V� � � � � ������ c �> � t � � } t | j �� � anB# t $ r5}t
� dt |� � � �� � Y d}~dS d}~ww xY wt
� d� � t �
d�� � dS )z%Entry point for the command-line tool)�
model_namezError initializing LLM: N� zStarting browser-use-mcp server�stdio)� transport)r r �modelr �
ValueErrorr r r r
�mcpr )�argsr s r �mainr+ 6 s� � ��<�<�D�
����,�,�,����� � � ����8��A���8�8�9�9�9��q�q�q�q�q��������� �K�K�1�2�2�2��G�G�g�G�����s �&