server.cpython-310.pyc•3.23 kB
o
���g� � @ s d dl Z d dlZd dlZd dlmZmZmZmZ d dlm Z d dl
mZ dZej
�dd�Ze dd d
gd�Ze�� edd
�fdedefdd��Ze�� edd
�edd
�eddd�fdededeeeeef defdd��Zdeeef defdd�Zdd� Zedkr�e� dS dS ) � N)�List�Dict�Any�Optional)�FastMCP)�Fieldzhttps://api.github-chat.comZGITHUB_API_KEY� zgithub-chat-mcp�requestszmcp[cli])�dependencieszNThe GitHub repository URL to index (format: https://github.com/username/repo).)�description�repo_url�returnc
C s� z1| st d��| �d�st d��tjt� d�ddid| id�}|jd kr+d
|j� �W S d| � d�W S tyN } zd
t|�pAt |�� �W Y d}~S d}~ww )zrIndex a GitHub repository to analyze its codebase. This must be done before asking questions about the repository.zRepository URL cannot be empty.�https://github.com/�FRepository URL must be in the format: https://github.com/username/repoz/verify�Content-Type�application/jsonr ��headers�json�� zError indexing repository: z!Successfully indexed repository: z2. You can now ask questions about this repository.�Error: N)
�
ValueError�
startswithr �post�GITHUB_CHAT_API_BASE�status_code�text� Exception�str�repr)r �response�e� r"