Skip to main content
Glama

MCP Server Basic Example

by ugundhar
weather.cpython-313.pyc3.36 kB
� j�h�����SSKJr SSKrSSKJr \"S5rSrSrS\S\ \\4S-4S jr S \ S\4S jr \R5S \S\4S j5r \RS5S\S\4Sj5rg)�)�AnyN)�FastMCP�weatherzhttps://api.weather.govzweather-app/1.0�url�returnc��n# �[SS.n[R"5IShv�N nURXSS9IShv�N nUR 5 UR 5sSSS5IShv�N $NNN7N ![ a SSS5IShv�N gf=f!,IShv�N (df  g=f7f)z9Make a request to the NWS API with proper error handling.zapplication/geo+json)z User-Agent�AcceptNg>@)�headers�timeout)� USER_AGENT�httpx� AsyncClient�get�raise_for_status�json� Exception)rr �client�responses �-E:\mcpcourse\mcpcrashcourse\server\weather.py�make_nws_requestr s����!�(��G�� � �"�"�f� �#�Z�Z��d�Z�K�K�H� � %� %� '��=�=�?� #�"�"�K�#�� � �� #�"�"�  �� #�"�"�s��#B5�A4�B5�B�A:�A6�#A:�" B5�.A8�/B5�6A:�8B5�: B�B� B5�B�B5�B�B�B2�!B$ �" B2�.B5�featurec ���USnSURSS5SURSS5SURSS5S URS S 5S URS S5S3 $)z/Format an alert feature into a readable string.� propertiesz Event: �event�Unknownz Area: �areaDescz Severity: �severityz Description: � descriptionzNo description availablez Instructions: � instructionz!No specific instructions providedz )r)r�propss r� format_alertr!s��� �L� !�E��� � �'�9�-�.�/��y�y��Y�/�0�1��9�9�Z��3�4�5��i�i� �/I�J�K�L��y�y��0S�T�U�V �  � ��statec���# �[SU3n[U5IShv�N nU(aSU;agUS(dgUSVs/sHn[U5PM nnSRU5$NLs snf7f)z\Get weather alerts for a US state. Args: state: Two-letter US state code (e.g. CA, NY) z/alerts/active/area/N�featuresz*Unable to fetch alerts or no alerts found.z No active alerts for this state.z --- )� NWS_API_BASErr!�join)r#r�datar�alertss r� get_alertsr*&sw����N�.�u�g� 6�C�!�#�&� &�D� �:�T�)�;� � � �1�37� �3C� D�3C��l�7�#�3C�F� D� �>�>�&� !�!� '��E�s!�A0�A)�$A0�A+�A0�+A0zecho://{message}�messagec� �SU3$)zEcho a message as a resourcezResource echo: �)r+s r� echo_resourcer.:s���W�I� &�&r")�typingrr �mcp.server.fastmcpr�mcpr&r �str�dictrr!�toolr*�resourcer.r-r"r�<module>r6s���� �&��i���)� � � � �� ��S�#�X���(=� �  �$�  �3�  �����"�C�"�C�"� �"�&��� �!�'�3�'�3�'�"�'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/ugundhar/mcp-server'

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