server.cpython-312.pyc•4.67 kB
�
l��g� � � � d dl Z d dlZd dlZd dlmZmZmZmZ d dlm Z d dl
mZ dZej j dd� Z e dd d
g�� Zej# � ed�
� fdedefd�� Zej# � ed�
� ed�
� edd�� fdededeeeeef defd�� Zdeeef defd�Zd� Zedk( r e� yy)� N)�List�Dict�Any�Optional)�FastMCP)�Fieldzhttps://api.github-chat.com�GITHUB_API_KEY� zgithub-chat-mcp�requestszmcp[cli])�dependencieszNThe GitHub repository URL to index (format: https://github.com/username/repo).)�description�repo_url�returnc �F � | st d� �| j d� st d� �t j t � d�ddid| i�� }|j
d k7 rd
|j � �S d| � d�S # t $ r%}d
t |� xs t |� � �cY d}~S d}~ww xY w)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�es �3/Users/sheing/kagimcp/src/github_chat_mcp/server.py�index_repositoryr&