Skip to main content
Glama
mcp_api.cpython-313.pyc4.2 kB
� q��g� ���SSKJrJrJr SSKJr SSKJrJrJ r J r \"SS/S9r "SS\5r "S S \5r S qS qS r\ R#S \ S9\"S54S\ 4Sjj5rS\\\ 4S\ 4SjrS\\\ 4S\ 4Sjrg )�)� APIRouter� HTTPException�Body)� BaseModel)�List�Dict�Any�Optionalz/mcp�MCP)�prefix�tagsc�8�\rSrSr%Sr\\S'\\\4\S'Sr g)� MCPAction�zModel for an MCP action request� action_type�payload�N) �__name__� __module__� __qualname__�__firstlineno__�__doc__�str�__annotations__rr �__static_attributes__r��*/Users/kz/vcs/sui-ai/mcp_server/mcp_api.pyrrs��)��� �#�s�(�^�rrc�L�\rSrSr%Sr\\S'Sr\\ \S'Sr \\\S'Sr g)� MCPResponse� zModel for an MCP response�statusN�data�errorr) rrrrrrrr"r r r#rrrrrr s&��#� �K��D�(�3�-���E�8�C�=�rrNc� �UqUqg)zAConfigure the router with the vector store and document processorN)� vector_store� doc_processor)�vs�dps r� configurer)s���L��Mrz/action)�response_model.�actionc��z# �[b[c [SSS9eURS:Xa[ UR 5IShv�N $URS:Xa[ UR 5IShv�N $[SSUR3S 9$NHN![an[S[U5S 9sSnA$SnAff=f7f) zHandle MCP action requestsNi�zServer not properly initialized)� status_code�detail�retrieve_documents�index_documentsr#zUnknown action type: �r!r#) r%r&rrr/rr0r� Exceptionr)r+�es r� handle_actionr4s������}�4���4U�V�V� � � � �!5� 5�+�F�N�N�;�;� ;� � � �#4� 4�(����8�8� 8���-�f�.@�.@�-A�B�� � <�8�� � ����a�&� � �� �sp�B;�(B�B �B�B;� (B�1B�2B�5B;�6B� B;� B�B� B8�B3�-B8�.B;�3B8�8B;r�returnc���# �URS5nURSS5nU(d [SSS9$[RU5n[R X25n[SUU[ U5S.S 9$7f) z#Retrieve documents based on a query�query�top_k�r#z/Query is required for retrieve_documents actionr1�success)� documentsr7� total_results�r!r")�getrr&� get_embeddingr%�search�len)rr7r8�query_embedding�resultss rr/r/3s��� �K�K�� �E� �K�K��� #�E� ���C� � � $�1�1�%�8�O��!�!�/�9�G� �� �� ��\� � ��s�A6A8c��# �URSS5n[RU5nU(d [SSS0SS9$[R U5 [R S5 [S [U5S [U5S 3S .S 9$7f)z Index documents from a directory� directory�docs�warning� indexed_countrzNo documents found to index)r!r"r#z./data/faiss_index.binr:zSuccessfully indexed z documents)rH�messager=)r>r&�process_documentsrr%r0�saverA)rrEr;s rr0r0Ms����� � �K��0�I��/�/� �:�I� ���!�1�%�/� � �� � ��+����.�/� �� ��^�.�s�9�~�.>�j�I� � ��s�B B )�fastapirrr�pydanticr�typingrrr r �routerrrr%r&r)�postr4rr/r0rrr�<module>rQs���2�2��,�,� �&��w� /��� ��  �)� �� �� �� ���Y�{��3�,0��I� � � �4� �*�d�3��8�n����4�4��S��>��k�r

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ProbonoBonobo/sui-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server