cli.cpython-311.pyc•3.34 kB
�
\C�g� �
�D � d dl Z d dlZd dlmZ d dlmZ ddlmZ d dlZd dl Z ddl
mZ e j � � d� � � Z
e
� � � e j d e j d �
� � �� � e j d e j � � �� � e j d
� � deded
efd�� � � � � � � � Ze
� � � e j d e j d �
� � �� � defd�� � � � Zedk r e
� � dS dS )� N)�Path)�Optional� )�ABIAnalyzer)�MCPGeneratorc � � dS )zMCP Server Generator CLIN� r � �//Users/arjun/repos/sparkmango/mcp_server/cli.py�clir
s � � �Dr
�abi_fileT)�exists)�type�
output_dir�
contract_namec �� � t j d� � }|st j dd�� � dS t | � � 5 }t j |� � }ddd� � n# 1 swxY w Y t |� � }|� � � }t |t |� � ||�� � }t j |�
� � � � t j d|� �� � dS )z+Generate an MCP server from a contract ABI.�OPENAI_API_KEYz5Error: OPENAI_API_KEY environment variable is not setT)�errN)�analysisr r �openai_api_keyzMCP server generated in )�os�getenv�click�echo�open�json�loadr �analyzer r �asyncio�run�generate) r
r r r �f�abi�analyzerr � generators r r! r! s, � � �Y�/�0�0�N�� �
�
�J�PT�U�U�U�U���
�h��� �1��i��l�l��� � � � � � � � � � ���� � � � � �3���H����!�!�H� ���
�#�#�#�%� � � �I� �K� �"�"�$�$�%�%�%� �J�6�*�6�6�7�7�7�7�7s �A�A#�&A#� cache_dirc �� � t | � � }|� � � st j d� � dS |� d� � D ]}|� � � �t j d� � dS )z&Clear the method implementation cache.zCache directory does not existNz*.pyz
Cache cleared)r r r r �glob�unlink)r&