We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/arthurcolle/openai-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
file_tools.cpython-312.pyc•8.18 KiB
�
�6�g� �
� � d Z ddlZddlZddlmZmZmZmZ ddlm Z m
Z
ej e� Z
e dddd d
d�dd
d�ddd�d�dgd�d�� d,dedee dee defd�� Z e dddd dd�d dd�d dd�d�g d�d�dd�� ded ed!edefd"�� Z e d#d$dd d%d�d d&d�d'�dd(gd�dd�� ded(edefd)�� Zd*e
ddfd+�Zy)-zFile operation tools.� N)�Dict�List�Optional�Any� )�tool�ToolRegistry�ViewznReads a file from the local filesystem. The file_path parameter must be an absolute path, not a relative path.�object�stringz%The absolute path to the file to read)�type�description�numberzSThe number of lines to read. Only provide if the file is too large to read at once.z\The line number to start reading from. Only provide if the file is too large to read at once)� file_path�limit�offsetr )r
�
properties�required�file)�namer �
parameters�categoryr r �returnc � � t j d| � d|� d|� d�� t j j | � sd| � �S t j j | � sd| � �S t
| ddd �
� 5 }|�c|�at |� D ] }t |d� � g }t |� D ]# }t |d� }|� n|j |� �% dj |� }n|j � }ddd� |S # 1 sw Y S xY w# t $ r0}t j d
| � �� d
t |� � �cY d}~S d}~ww xY w)ao Read contents of a file.
Args:
file_path: Absolute path to the file
limit: Maximum number of lines to read
offset: Line number to start reading from
Returns:
File contents as a string
Raises:
FileNotFoundError: If the file doesn't exist
PermissionError: If the file can't be read
zReading file: z (offset=z, limit=�)�#Error: File path must be absolute: �Error: File not found: �r�utf-8�replace��encoding�errorsN� zError reading file: )�logger�info�os�path�isabs�exists�open�range�next�append�join�read� Exception� exception�str) r r r �f�_�lines�line�content�es �Q/Users/agent/claude-code-reverse/python-agent/claude_code/lib/tools/file_tools.py� view_filer; sC � �L �K�K�.���9�V�H�H�U�G�1�M�N�
�7�7�=�=��#�4�Y�K�@�@�
�7�7�>�>�)�$�(���4�4�/�
�)�S�7�9�
E� #��� �V�%7��v�� "�A���D�M�"� ���u�� '�A���4�=�D��|���L�L��&� '�
�'�'�%�.���&�&�(�� #�"