Skip to main content
Glama

Argus

by athapong
main.cpython-313.pyc37.1 kB
� !{�g�x����SrSSKJrJr SSKJr SSKJr SSKrSSK r SSK J r J r J r JrJr SSKrSSKrSSKJr SSKrSSKrSSKJrJr SSKrSS KJr SSKJs Jr SSK r SSK!r"SSK#r#SS K$J%r% SSK&r&SS K'J'r' SfS jr(S \)4Sjr*S \)4Sjr+SfSjr,SfSjr-\("5 "SS\5r."SS\5r/"SS\5r0"SS\5r1"SS\5r2"SS\5r3"SS\5r4"S S!\5r5\"S"/S#QS$S%9r6S&11S'kS(.1S)k1S*kS(.1S+k1S,kS(.1S-k1S.kS(.S/.r7/S0QS1S2//S3QS4S2/S/.r8SgS5\9S6\ \.S \94S7jjr:ShS5\9S6\ \.S8\ \9S \94S9jjr;SiS:\9S;\9S \94S<jjr<S=\ \ \9\=4S \ \.4S>jr>SgS?\9S@\ \9SA\ \9SB\ \9S \94 SCjjr?S?\9S \\9\44SDjr@S?\9S \\9\44SEjrAS?\9S \\9\44SFjrBS?\9S \\9\C44SGjrDSjSH\\9\C4SI\CS \ \94SJjjrES?\9SK\9S \\9\44SLjrFS?\9S \\9\44SMjrGS?\9S \\9\44SNjrHS?\9S \\9\44SOjrISP\\9\4S \\9\44SQjrJ\6R�5SSSR.S5\9S6\ \ \9\=4S8\ \9S \94SSjj5rL\6R�5SSSR.S5\9ST\ \9S6\ \ \9\=4S8\ \9S \=\9\944 SUjj5rM\6R�5SSV.S5\9S6\ \ \9\=4S \ \94SWjj5rN\6R�5SSSSSX.S5\9S@\ \9SA\ \9SB\ \9S6\ \ \9\=4S \94 SYjj5rO\6R�5SSZSS[.S5\9S8\ \9S\\PS6\ \ \9\=4S \ \=4 S]jj5rQ\6R�5S2SSS^.S5\9S_\9S6\ \ \9\=4S8\ \9S \\9\44 S`jj5rR\6R�5SSV.S5\9S6\ \ \9\=4S \\9\44Sajj5rS\6R�5Sb\9S \94Scj5rU\6R�5SSSSd.S5\9SK\ \9S6\ \ \9\=4S8\ \9S \\9\44 Sejj5rVg)kz2Repository analysis and security assessment tools.�)�FastMCP�server)�types)� BaseModelN)�List�Optional�Union�Dict�Any)�Path)�Repo�GitCommandError)�Enum)�Counter)�datetime�returnc�j�[5(d [5 [5(d [5 gg)z(Ensure all required tools are installed.N)�is_pmd_installed� install_pmd�is_trivy_installed� install_trivy���U/Users/athapongkaewsalapoom/Development/experimental/mcp/argus/src/panopticon/main.py�ensure_dependenciesrIs'�� � � �� � � � ��� rc�T�[R"SS/SS9 g![a gf=f)zCheck if PMD is installed.�pmd� --versionT��capture_outputF�� subprocess�run�FileNotFoundErrorrrrrrVs/�������{�+�D�A��� ����� �� '�'c�T�[R"SS/SS9 g![a gf=f)zCheck if Trivy is installed.�trivyrTrFr!rrrrr^s/��������-�d�C��� ����r%c� �[R"5R5nUS:Xa[R"/SQSS9 gUS:XGa�SnSUSUS 3n[ R RS 5n[ R"USS 9 [R"S S S 9n[RRX$R5 [R!URS5nUR#U5 SSS5 SSS5 [ R R%USUS35n[ R R%US5n[ R&"U[ R("U5R*[(R,-5 [ R R/U5(a[ R0"U5 [ R2"Xg5 U[ R4S;aH[7[ R RS5S5nUR9SUS35 SSS5 gg[;SU35e!,(df  GN_=f!,(df  GNi=f!,(df  g=f)z Install PMD.�darwin)�brew�installrT��check�linuxz 7.0.0-rc4z:https://github.com/pmd/pmd/releases/download/pmd_releases/z /pmd-bin-z.zipz ~/.local/bin��exist_okF��suffix�delete�rNzpmd-bin-z/bin/pmdr�PATHz ~/.bashrc�az export PATH="z:$PATH" �Unsupported operating system: )�platform�system�lowerr"r#�os�path� expanduser�makedirs�tempfile�NamedTemporaryFile�urllib�request� urlretrieve�name�zipfile�ZipFile� extractall�join�chmod�stat�st_mode�S_IEXEC�exists�remove�symlink�environ�open�write� Exception) r9� pmd_version�pmd_url� install_dir�tmp_file�zip_ref� pmd_script�pmd_link�bashrcs rrrfs��� �_�_� � $� $� &�F� ������1��>� �7� �!� �N�{�m�[d�ep�dq�qu�v���g�g�(�(��8� � � � �K�$�/�� (� (��u� E�� �N�N� &� &�w� � � >��������4���"�"�;�/�5�F� �W�W�\�\�+��+��h�/O�P� ��7�7�<�<� �U�3�� ����R�W�W�Z�0�8�8�4�<�<�G�H� �7�7�>�>�(� #� #� �I�I�h� � � � �:�(� �b�j�j��0� 0��b�g�g�(�(��5�s�;�v�� � ��{�m�9�E�F�<�;� 1��8���A�B�B�!5�4��F� E��<�;�s1�A I#�'I�9I#�#I5� I �I#�# I2�5 Jc��[R"5R5nUS:Xa[R"/SQSS9 g US:Xav[R"/SQSS9 [R"/SQSSS9 [R"/S QSSS9 [R"/S QSS9 [R"/S QSS9 g [ S U35e)zInstall Trivy.r))r*r+zaquasecurity/trivy/trivyTr,r.)�sudo�apt-getr+�wgetzapt-transport-https�gnupgz lsb-release) r_z-qO�-z8https://aquasecurity.github.io/trivy-repo/deb/public.key�|�gpgz --dearmorrbr]�teez/usr/share/keyrings/trivy.gpg�>z /dev/null)r-�shell) �echoz-deb [signed-by=/usr/share/keyrings/trivy.gpg]z-https://aquasecurity.github.io/trivy-repo/debz$(lsb_release -sc)�mainrbr]rdz"/etc/apt/sources.list.d/trivy.list)r]r^�update)r]r^r+r'z-yr7N)r8r9r:r"r#rS)r9s rrr�s��� �_�_� � $� $� &�F� ������F�d�S� �7� ���� �� � ��� � �T�  #� ��� � �T�  #� ���4�D�A����D�D�Q��8���A�B�Brc� �\rSrSr%\\S'Srg)�GitLabCredentials��api_keyrN)�__name__� __module__� __qualname__�__firstlineno__�str�__annotations__�__static_attributes__rrrrkrk�s�� �Lrrkc�H�\rSrSr%\\S'Sr\\\S'Sr \\\S'Sr g)�AnalyzeRepositoryInput��repo_urlN�gitlab_credentials�branchr� rnrorprqrrrsryrrkrzrtrrrrvrv�s&���M�6:���!2�3�:� �F�H�S�M� rrvc�X�\rSrSr%\\S'\\\S'Sr\\ \S'Sr \\\S'Sr g)�InspectFilesInput�rx� file_pathsNryrzr) rnrorprqrrrsrryrrkrzrtrrrr}r}�s0���M��S� ��6:���!2�3�:� �F�H�S�M� rr}c�4�\rSrSr%\\S'Sr\\\S'Sr g)�EnumerateBranchesInput�rxNryr) rnrorprqrrrsryrrkrtrrrr�r��s���M�6:���!2�3�:rr�c�p�\rSrSr%\\S'Sr\\\S'Sr\\\S'Sr \\\S'Sr \\ \S'Sr g) � DiffInput��rxN�source�target� file_pathryr) rnrorprqrrrsr�rr�r�ryrkrtrrrr�r��sB���M� �F�H�S�M� � �F�H�S�M� �#�I�x��}�#�6:���!2�3�:rr�c�\�\rSrSr%\\S'Sr\\\S'Sr \\\S'Sr \\\S'Sr g) �SecurityScanInput��rxNryr'� scan_typerzr) rnrorprqrrrsryrrkr�rzrtrrrr�r��s4���M�6:���!2�3�:�&�I�x��}�&� �F�H�S�M� rr�c�R�\rSrSr%\\S'\\S'Sr\\\S'Sr \\\S'Sr g)�CodeQualityInput��rx�languageNryrzrr{rrrr�r��s+���M��M�6:���!2�3�:� �F�H�S�M� rr�c�R�\rSrSr%Sr\\S'Sr\\\S'Sr \\ \\S'Sr g)�TeamsWebhookConfig��z&Microsoft Teams webhook configuration.�urlN�channel� mention_usersr) rnrorprq�__doc__rrrsr�rr�rrtrrrr�r��s+��0� �H�!�G�X�c�]�!�)-�M�8�D��I�&�-rr�zRepository Tools)� GitPython�gitdb�requests�pylint�bandit�WARNING)� dependencies� log_levelz.go>�func �import (�package )� extensions�markers>�.kt�.java�.scala>r�� import java� public class>�.py�.pyi�.pyx>�def �from �class �import >�.js�.ts�.jsx�.tsx>�function�let �const r�)�go�java�python� javascript)�gocycloz golangci-lintr'rr')r�r�r'�eslintrxryc���U(dU$SU;alURS5(a URSSURS35$URS5(a URSSURS35$U$)zIConvert repository URL to include authentication if credentials provided.z gitlab.comzhttps://zhttps://oauth2:�@zgit@zgit@gitlab.com:z @gitlab.com/)� startswith�replacerm)rxrys r�get_authenticated_urlr�s��� ����x�� � � �z� *� *��#�#�J�/�BT�B\�B\�A]�]^�0_�`� `� � � �� (� (��#�#�$5��I[�Ic�Ic�Hd�dp�7q�r� r� �Orrzc���USU(a UROSSU=(d S3n[R"UR55R 5SSn[ R R[R"5SU35n[X5n[ R RU5(a�[U5nUR(d`UR5RU:XaBUR5R!5 U(aUR"R%U5 U$[&R("USS9 [ R*"USS 9 U(a[R,"XeUS 9 U$[R,"Xe5 U$! [&R("USS9 Ne=f![.a1n[&R("USS9 [/S [1U535eSnAff=f) zHClone or retrieve an existing repository from cache and return its path.�:��defaultN� � repo_cache_T)� ignore_errorsr/)rzzRepository cloning failed: )rm�hashlib�sha256�encode� hexdigestr;r<rHr?� gettempdirr�rMr �bare�remoter��fetch�git�checkout�shutil�rmtreer>� clone_fromrSrr) rxryrz� cache_key� repo_hash�temp_dir�authenticated_url�repo�es r� clone_repor�s����*�A�<N�0�8�8�TV�W�WX�Y_�Yl�cl�Xm�n�I����y�/�/�1�2�<�<�>�s��C�I��w�w�|�|�H�/�/�1�[�� �3L�M�H�-�h�K�� �w�w�~�~�h��� 8���>�D��9�9�����!2�!2�6G�!G�� � � �#�#�%���H�H�%�%�f�-��� �M�M�(�$� 7� �K�K��4�(�@� � �O�O�-�� G��� �O�O�-� 8���� 8� �M�M�(�$� 7�� �@�� � �h�d�3��5�c�!�f�X�>�?�?��@�s1�A;F�>F�)F;�F;�F8�; G6�,G1�1G6r<�prefixc���Sn[R"U5nUR5 [U5H�upEUR S5(aMU[ U5S- :HnU(aSOSnU(aSOSn[R RX5n X!U-U-S-- n[R RU 5(dM�U[X�U-5- nM� U$) z/Generate a tree-like directory structure stringr��.git�u └── u ├── z u│ � ) r;�listdir�sort� enumerater��lenr<rH�isdir�get_directory_tree) r<r��output�entries�i�entry�is_last�current_prefix� next_prefix� entry_paths rr�r�1s��� �F��j�j���G� �L�L�N��g�&��� � � �F� #� #� ��s�7�|�a�'�'��)0��l�� '�f�X� ��W�W�\�\�$�.� ��>�)�E�1�D�8�8�� �7�7�=�=�� $� $� �(��k�5I�J� J�F�'� �Mr�credsc��U(dg[U[5(a [US9$[U[5(a [S0UD6$g)z8Convert various credential formats to GitLabCredentials.N)rmr)� isinstancerrrk�dict)r�s r�create_gitlab_credentialsr�Gs>�� ���%���� ��/�/��%���� �)�5�)�)� r� repo_pathr�r�r�c��[U5nU(aURU5nOURRnU(aURU5nO*UR(aURSOSnU(dgU(aURR XeSU5nOURR Xe5nU(aU$S$![ anS[U53sSnA$SnAf[anS[U53sSnA$SnAff=f)z&Get diff between two commits/branches.rNz)No previous commit found to compare with.z--zNo changes found.zGit diff failed: zError generating diff: ) r �commit�head�parentsr��diffrrrrS) r�r�r�r�r�� source_commit� target_commitr�r�s r�get_diff_changesr�Qs���2��I��� � �K�K��/�M� �I�I�,�,�M� � �K�K��/�M�8E�8M�8M�M�1�1�!�4�SW�M� �B� ��8�8�=�=��t�Y�O�D��8�8�=�=��>�D��t�4�!4�4�� �,�"�3�q�6�(�+�+�� �2�(��Q���1�1��2�s=�A<C �?AC �C � D � C'�!D �' D �4 D�D �D c�0�[R"SSSSU/SSSS9n[R"UR5$![R anSSUR 30sS nA$S nAf[Ra SS 0s$[a SS 0s$f=f) z.Run Trivy vulnerability scanner on repository.r'�fsz--format�jsonT)r �textr-�errorzTrivy scan failed: NzFailed to parse Trivy outputz0Trivy not installed. Please install Trivy first.) r"r#r�loads�stdout�CalledProcessError�stderr�JSONDecodeErrorr$�r��resultr�s r�run_trivy_scanr ps��� M���� �d�J�� � :����  �� �z�z�&�-�-�(�(�� � (� (�;��.�q�x�x�j�9�:�:�� � � �9��7�8�8� �M��K�L�L�M�s'�;>�B�A(�"B�(B� B�Bc�b�[R"/SQUSSS9n/SSS.nUR(a�URR5R S5nSnUHvnU(dM UR 5n[ U5S:�dM-[ US5nUSnUS n US RUUU S .5 XG- nUS :�dMiUS ==S- ss'Mx [ U5S:�aU[ U5- US'U$![a SS0s$[an SS[U 530sSn A $Sn A ff=f)z.Run cyclomatic complexity analysis on Go code.)r�z-avgz-over=10�.T)�cwdr rr)�cyclomatic_complexity�average_complexity�high_complexity_functionsr������������r)� complexityr��file� rr�rrzbgocyclo not installed. Please install with: go install github.com/fzipp/gocyclo/cmd/gocyclo@latestzFailed to run gocyclo: N) r"r#r�strip�splitr��int�appendr$rSrr) r�r �metrics�lines�total_complexity�line�partsr� function_namer�r�s r�run_gocyclo_analysisr"�sK��(=���� 0����  ��&(�"#�)*� �� �=�=��M�M�'�'�)�/�/��5�E� � ����4� �J�J�L�E��5�z�Q��%(��q��]� �(-�b� � �$)�"�I� �� 7�8�?�?�*4�(5�$-�A�� )�6�(�%��?�#�$?�@�A�E�@�� �5�z�A�~�0@�3�u�:�0M��,�-���� ���}�~�~� �=��2�3�q�6�(�;�<�<��=�s6�A%C;�+C;� 8C;�2C;�;D.� D.�D)�#D.�)D.c ���[R"SSS9nURnSSS5 [R"SSSUSS S S S W/ S S S9n[ US5nUR 5nSSS5 SW0[R"U5 $!,(df  Nn=f!,(df  N9=f![R"U5 f=f![a SS0s$[anSS[U530sSnA$SnAff=f)z@Run PMD static code analysis on Java code and return raw output.z.xmlFr1Nrr-z-dz-Rzrulesets/java/quickstart.xml�-f�xml�-rT�r rr4� raw_outputrzAPMD not installed. Please install PMD from https://pmd.github.io/zFailed to run PMD: ) r?r@rDr"r#rQ�readr;�unlinkr$rSrr)r�rW� output_pathr �f� xml_contentr�s r�run_pmd_analysisr.�s���9� � (� (��u� E��"�-�-�K�F�������i��4��e��k�  � ��  �� #��k�3�'�1��f�f�h� �(� �+�.� �I�I�k� "�-F� E��$(�'�� �I�I�k� "�� �^��\�]�]� �9��.�s�1�v�h�7�8�8��9�si�C � B �(C � B.�B�* B.�5C � B�C � B+�'B.�.C�C � C<� C<�"C7�1C<�7C<c ��^�[5n0nSn[R"U5H�upEnSU;aMUH�n[RR XG5n[RR U5upY[RR U5S:�aMh[R5Hdup�X�S;dM[USSS9n U RS5m[U4S jU S 55n U S:�aX==S - ss'US - nS S S 5 Mf M� M� US:�aUR5H up�X�- X*'M U$!,(df  M�=f! M�=f) zr Detect programming languages used in the repository. Returns a dictionary of language -> confidence score (0-1). rr�i@Br�r4�utf-8��encodingic3�8># �UHnUT;dM Sv� M g7f)r�Nr)�.0�marker�contents �r� <genexpr>�.detect_repository_languages.<locals>.<genexpr>�s#����/B�?R�V�/5��/@�01�q�?R�s� � r�r�N) rr;�walkr<rH�splitext�getsize�LANGUAGE_PATTERNS�itemsrQr)�sum)r�� file_count�language_confidence� total_files�root�_�filesrr��ext�lang�patternsr,� marker_count�countr6s @r�detect_repository_languagesrJ�sR��� ��J����K��'�'�)�,���� �T�>� ��D���� � �T�0�I��W�W�%�%�i�0�F�A��w�w���y�)�I�5��#4�"9�"9�";����<�0�0� !�!�)�S�7�C�q�&'�f�f�T�l�G�+.�/B�x� �?R�/B�,B�L�+�a�/� *� 0�A� 5� 0� +�q� 0� � D�C�#<�� -�6�Q��%�+�+�-�K�D�(-�(;� � %�.� ��D�C��!� �s+� E� AE �E� E �E�E�E � languages�min_confidencec��[5nUR5H1up4XA:�dM UR[R U/55 M3 [ U5$)z;Get appropriate analysis tools based on detected languages.)�setr=ri�ANALYSIS_TOOLS�get�list)rKrL�selected_toolsrF� confidences r�get_analysis_toolsrT�sK���U�N�%�O�O�-��� � '� � !� !�.�"4�"4�T�2�">� ?�.� �� �rr�c���0nUS:Xa[U5US'U$US:Xa[U5US'U$US:Xa[U5US'[U5US'U$US:Xa[ U5US 'U$) z%Run language-specific analysis tools.r�r�r�rr�r�r�r�r�)r"r.�run_pylint_analysis�run_bandit_analysis�run_eslint_analysis)r�r��resultss r�run_language_specific_analysisrZs����G��4��1�)�<�� �� �N� �V� �)�)�4���� �N� �X� �/� �:����/� �:���� �N� �\� !�/� �:���� �Nrc���[R"SSU/SSS9nUR(a [R"UR5$SS0$![ anSS[ U530sSnA$SnAff=f) z#Run Pylint analysis on Python code.r�z--output-format=jsonTr'rzNo output from pylintzPylint analysis failed: N�r"r#rrrrSrrr s rrVrVss��>���� �-�y� 9��� �� -3�M�M�t�z�z�&�-�-�(�a��I`�?a�a�� �>��3�C��F�8�<�=�=��>�s$�A A� A� A4�A/�)A4�/A4c���[R"SSSSU/SSS9nUR(a [R"UR5$SS0$![ anSS [ U530sS nA$S nAff=f) z,Run Bandit security analysis on Python code.r�r&r$rTr'rzNo output from banditzBandit analysis failed: Nr\r s rrWrW!sv��>���� �t�T�6�9� 5��� �� -3�M�M�t�z�z�&�-�-�(�a��I`�?a�a�� �>��3�C��F�8�<�=�=��>�s$�A A�A� A6�A1�+A6�1A6c���[R"SSSU/SSS9nUR(a [R"UR5$SS0$![ anSS[ U530sS nA$S nAff=f) z2Run ESLint analysis on JavaScript/TypeScript code.r�r$rTr'rzNo output from eslintzESLint analysis failed: Nr\r s rrXrX-st��>���� �t�V�Y� /��� �� -3�M�M�t�z�z�&�-�-�(�a��I`�?a�a�� �>��3�C��F�8�<�=�=��>�s$�A A� A� A5�A0�*A5�0A5� scan_resultsc���URS/5n[U5[SU55[SU55[SU55[SU55S.$)z,Format Trivy scan results for Teams message.�vulnerabilitiesc3�R# �UHoRS5S:XdMSv� M g7f)�severity�CRITICALr�N�rP�r4�vs rr7�'format_trivy_results.<locals>.<genexpr>?s ���V�?�a�e�e�J�6G�:�6U���?���'� 'c3�R# �UHoRS5S:XdMSv� M g7f)rc�HIGHr�Nrerfs rr7rh@s ���N��!�%�%� �2C�v�2M�A�A��ric3�R# �UHoRS5S:XdMSv� M g7f)rc�MEDIUMr�Nrerfs rr7rhAs ���R��A�E�E�*�4E��4Q�a�a��ric3�R# �UHoRS5S:XdMSv� M g7f)rc�LOWr�Nrerfs rr7rhBs ���L�o����z�1B�e�1K�1�1�o�ri)zTotal Vulnerabilities�Critical�High�Medium�Low)rPr�r>)r_ras r�format_trivy_resultsrt9sa��"�&�&�'8�"�=�O�"%�_�!5��V�?�V�V��N��N�N��R��R�R��L�o�L�L�  �r)ryrzc��[U5n[XU5n[U5nU$![anS[ U53sSnA$SnAff=f)z� Generate a tree representation of a repository's file structure. Args: repo_url: Repository URL to analyze gitlab_credentials: Optional GitLab token string or credentials dict branch: Optional branch name to clone zRepository analysis failed: N)r�r�r�rSrr)rxryrzr�r��treer�s r�analyze_repository_structurerwEsN��7�)�*<�=���x��7� �!�)�,��� �� �7�-�c�!�f�X�6�6��7�s�#&� A� A�A�Arc��[SUSUSU35 [U5n[XU5n0nUHsn[RR XW5n[RR U5(dSXg'ML[USSS9n U R5Xg'SSS5 Mu U$!,(df  M�=f![an S [U 53Xg'Sn A M�Sn A ff=f![an S S [U 530sSn A $Sn A ff=f) z:Extract and return contents of specified repository files.z.inspect_repository_files called with repo_url=z , file_paths=z, gitlab_credentials=zError: File not foundr4r0r1NzError reading file: rzRepository inspection failed: ) �printr�r�r;r<rH�isfilerQr)rSrr) rxrryrzr�r�rYr�� full_pathr,r�s r�inspect_repository_filesr|Ws�� � :�8�*�M�R\�Q]�]r�tF�sG� H�I�D�)�*<�=���x��7� ���#�I���� � �Y�:�I��7�7�>�>�)�,�,�'<��"�� E��)�S�7�;�q�)*����G�&�<�;�$��� <�;��� E�';�C��F�8�%D��"�� E�� �D��9�#�a�&��B�C�C��D�sl�A'C$�> B<� B*�B<�$C$�* B9 �4B<�7C$�9B<�< C!�C�C$�C!�!C$�$ D�.D�=D�D)ryc���[U5n[X5n[U5nURVs/sHoURPM nnU$s snf![ anS[ U53/sSnA$SnAff=f)z,Retrieve all branch names from a repository.zBranch enumeration failed: N)r�r�r �branchesrDrSrr)rxryr�r�r�rzr~r�s r�enumerate_branchesrusq�� 8�)�*<�=���x�/� ��I���/3�m�m�<�m�F�K�K�m��<����=�� �8�-�c�!�f�X�6�7�7��8�s.�/A�A �A� A� A2�A-�'A2�-A2)r�r�r�ryc��[U5n[X5n[XaX#5$![anS[ U53sSnA$SnAff=f)a2 Compare changes between git commits or branches. Args: repo_url: Repository URL source: Source branch/commit (default: current HEAD) target: Target branch/commit (default: previous commit) file_path: Specific file to compare (optional) gitlab_credentials: Optional GitLab credentials zComparison failed: N)r�r�r�rSrr)rxr�r�r�ryr�r�r�s r�compare_git_changesr��sJ��$.�)�*<�=���x�/� �� �6�E�E�� �.�$�S��V�H�-�-��.�s�!$� A� A�A�Ar)rz� max_countryr�c� �[U5n[XU5n[U5nU(aURR U5 /nUR US9H�nUR URURRSURRS3URR5URR5S.5 M� U$![an SS[!U 530/sSn A $Sn A ff=f)z� Get commit history for a repository branch. Args: repo_url: Repository URL branch: Branch name (default: current branch) max_count: Maximum number of commits to return gitlab_credentials: Optional GitLab credentials )r�z <re)�hash�author�date�messagerzFailed to get commit history: N)r�r�r r�r�� iter_commitsr�hexshar�rD�email�committed_datetime� isoformatr�rrSrr) rxrzr�ryr�r�r��commitsr�r�s r�get_commit_historyr��s��� F�)�*<�=���x��7� ��I��� � �H�H� � �f� %����'�'�)�'�<�F� �N�N�� � �#�]�]�/�/�0��6�=�=�3F�3F�2G�q�I��1�1�;�;�=�!�>�>�/�/�1� � �=���� �F��:�3�q�6�(�C�D�E�E��F�s�CC� D�(C>�8D�>D)r�ryrzr�c���[U5n[XU5nUS:waSS0$[U5nU[U5S.$![anSS[ U530sSnA$SnAff=f)z6Perform security scanning on a repository using Trivy.r'rz Only Trivy scanning is supported)� trivy_scan�summaryzSecurity scan failed: N)r�r�r rtrSrr)rxr�ryrzr�r�r_r�s r�security_scan_repositoryr��sz��<�)�*<�=���x��7� � �� ��?�@� @�%�i�0� �&�+�L�9� � �� �<��1�#�a�&��:�;�;��<�s� <�<� A �A�A �A c��[U5n[X5n[U5nURHnUR 5 M UR Vs/sHofR PM snUR5RVs/sH0owR RS5(aM$UR PM2 snURR S.nSUS.$s snfs snf![an SS[U 53S.sSn A $Sn A ff=f) z� Fetch all branches from a repository and ensure they are up to date. Args: repo_url: Repository URL to fetch from gitlab_credentials: Optional GitLab credentials Returns: Dictionary containing branch information or error z/HEAD)�localr��current�success)�statusr~rzFailed to fetch branches: �r�rN) r�r�r �remotesr��headsrDr��refs�endswith� active_branchrSrr) rxryr�r�r�r�rz�refr~r�s r�fetch_all_branchesr��s��� �)�*<�=���x�/� ��I����l�l�F� �L�L�N�#� 15� � �;� �f�k�k� �;�+/�;�;�=�+=�+=�`�+=�C�X�X�EV�EV�W^�E_�x�s�x�x�+=�`��)�)�.�.� �� � � � �� <��`�� � ��1�#�a�&��:� � �� �sB�AC'�C�)C'�#C"�.C"�>C'� C'�' D �1D�D �D � pmd_outputc� �SU3$)Na�As a seasoned software engineer, meticulously review the code quality analysis results generated by PMD. Craft a comprehensive, professional, and technically detailed summary that encompasses the following aspects: 1. Provide an overall assessment of the codebase's health, highlighting the general adherence to coding standards and best practices. 2. Identify and emphasize the most critical issues that demand immediate attention, detailing their potential impact on system stability, performance, and security. 3. Analyze and describe any recurring patterns or trends in the issues found, offering insights into common pitfalls or areas of weakness in the code. 4. Offer specific, actionable recommendations for improvement, suggesting concrete steps to remediate identified issues and enhance code quality. 5. Prioritize the issues in a logical order for addressing them, balancing urgency, impact, and effort required for resolution. PMD output: r)r�s r�analyze_pmd_violationsr�s��� � � �r)r�ryrzc��[U5n[XU5nU(d[U5nU(dSSS.$OUR5S0n[ U5nU(dSSS.$SU0S.nUR 5Hup�U S:�dM [ XY5US U 'M [U5US 'U$![an SS [U 53S.sS n A $S n A ff=f) a0 Analyze code quality with automatic language detection and tool selection. Args: repo_url: Repository URL language: Optional language override gitlab_credentials: Optional GitLab credentials branch: Optional branch name to clone Returns: Dictionary containing analysis results rz+No supported programming languages detectedr�g�?z7No suitable analysis tools found for detected languagesr�)r�rK�analysis皙�����?r�� security_scanzCode quality analysis failed: N) r�r�rJr:rTr=rZr rSrr) rxr�ryrzr�r��detected_languages�toolsrYrFrSr�s r�analyze_code_qualityr�s��&+ �)�*<�=���x��7� ��!<�Y�!G� �%�%�J���&� #+�.�.�"2�C�!8� �#�#5�6���!�R�� � �+�� �� !3� 8� 8� :� �D��S� �,J�9�,[�� �#�D�)�!;� $2�)�#<��� ���� � ��5�c�!�f�X�>� � �� �s.�4B)�)B)�!B)�$B)�) C�3C �C� C)rN)N)NN)r�)r�)Wr��mcp.server.fastmcprr�mcp.server.fastmcp.resourcesr�pydanticrr;r"�typingrrr r r r?r��pathlibr r�r�r�r rr�enumr�xml.etree.ElementTree�etree� ElementTree�ETr8�urllib.requestrArJ� collectionsr�rerr�boolrrrrrkrvr}r�r�r�r�r��mcpr<rOrrr�r�r�r�r�r�r r"r.�floatrJrTrZrVrWrXrt�toolrwr|rr�rr�r�r��promptr�r�rrr�<module>r�s���8�.�.�� ��3�3�� ��� �%� ��"�"��� �� ��d ��$���D��!C�FC�D��� ��!�Y�!� !� �!� ;�Y�;�;� �;�!� �!� !�y�!� .��.� ���� ���g�4� � 1�>� � .�9�� 5�<����( 0� �G� �+��W�%� �� �C� �X�FW�=X� �dg� �!@��!@�(�;L�2M�!@�^f�gj�^k�!@�wz�!@�F�S��#��s��,�X�e�C��I�.>�%?��H�M^�D_��2��2�X�c�]�2�H�S�M�2�^f�gj�^k�2�wz�2�>M�c�M�d�3��8�n�M�"*=�C�*=�D��c��N�*=�X9��9��S�#�X��9�B(�3�(�4��U� �3C�(�T �$�s�E�z�"2� �E� �TX�Y\�T]� ��c��S��T�#�s�(�^��& >�3� >�4��S��>� >� >�3� >�4��S��>� >� >�3� >�4��S��>� >� �t�C��H�~� �$�s�C�x�.� �����dh�CG�7�c�7�x�PU�VY�[_�V_�P`�Ga�7�rz�{~�r�7�LO�7� �7�"����w{�VZ�D�#�D�4��9�D�Zb�ch�il�nr�ir�cs�Zt�D�FN�OR�FS�D�_c�dg�il�dl�_m�D� �D�:����Z^� 8�C� 8�X�e�C�QU�I�FV�=W� 8�cg�hk�cl� 8� � 8�����!� �#�59� .��.� �S�M�.� �S�M�.���}� .� !��s�D�y�!1�2� .�  � .� �.�2����!��59� #F��#F� �S�M�#F��#F�!��s�D�y�!1�2� #F�  �$�Z� #F� �#F�J�����59� � <��<��<�!��s�D�y�!1�2�<� �S�M� <�  �#�s�(�^� <� �<�.����Z^�$ �C�$ �X�e�C�QU�I�FV�=W�$ �cg�hk�mp�hp�cq�$ � �$ �L���� �s� �s� �� �����#�59� � = ��= ��s�m�= �!��s�D�y�!1�2�= � �S�M� = �  �#�s�(�^� = � �= r

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/athapong/argus'

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