server.cpython-311.pyc•5.27 kB
�
l��g� � � � d dl Z d dlZd dlZd dlmZmZmZmZ d dlm Z d dl
mZ dZej
� dd� � Z e dd d
g�� � Ze� � � ed�
� � fdedefd�� � Ze� � � ed�
� � ed�
� � edd�� � fdededeeeeef defd�� � Zdeeef defd�Zd� Zedk r e� � dS dS )� 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 �Z � | st d� � �| � d� � st d� � �t j t � d�ddid| i�� � }|j d k r
d
|j � �S d| � d�S # t $ r+}d
t |� � pt |� � � �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&