Skip to main content
Glama

weather-mcp

by vasstavkumar
main.cpython-311.pyc3.87 kB
� 1F�g���`�ddlmZddlmZddlZddlZe��ed��ZdZdZdZ e� ��de fd ���Z e� ��d e fd ���Ze� ��d e fd ���Zed kre�d���dSdS)�)�FastMCP)� load_dotenvN�implementationzThttps://api.tomorrow.io/v4/weather/realtime?location={city}&apikey={weather_api_key}zZhttps://api.tomorrow.io/v4/weather/history/recent?location={city}&apikey={weather_api_key}z.https://api.postalpincode.in/pincode/{pincode}�pincodec��t|��} tjt�|�����}|���S#tjj$r}dt|��icYd}~Sd}~wwxYw)z� Gets the place name for the given pincode. Args: pincode (str): The pincode to get the place name for. Returns: dict: The place data. )r�errorN)�str�requests�get�pin_to_place_url�format�json� exceptions�RequestException)r�response�es �5/Users/vasstavkumarchava/modelcontextprotocol/main.py� pintoplacers����'�l�l�G�!��<� 0� 7� 7�� 7� H� H�I�I���}�}����� � � /�!�!�!���Q��� � � � � � � �����!���s�AA�B�&A<�6B�<B�cityc��ddd�} tjt�|t jd�����|���}|���S#tjj$r}dt|��icYd}~Sd}~wwxYw) z� Get the realtime weather forecasts for the location. Args: city (str): The city to get the weather for. Returns: dict: The weather data. �application/json�deflate, gzip, br��acceptzaccept-encoding�weather_api_key�rr��headersrN) r r �realtime_weather_urlr �os�getenvrrrr �rrrrs r�realtime_weatherr##s���%�.���G� !��<� 4� ;� ;��WY�W`�ar�Ws�Ws� ;� t� t�F�G�G�G���}�}����� � � /�!�!�!���Q��� � � � � � � �����!�����AA�B �1B�B �B c��ddd�} tjt�|t jd�����|���}|���S#tjj$r}dt|��icYd}~Sd}~wwxYw) a Get the historical weather forecasts for the location, including hourly history for the last 24 hours, and daily history for the last day. Args: city (str): The city to get the weather for. Returns: dict: The weather data. rrrrrrrN) r r �hourly_weather_urlr r r!rrrr r"s r�hourly_weatherr'<s���%�.���G�!��<� 2� 9� 9�t�UW�U^�_p�Uq�Uq� 9� r� r�}D�E�E�E���}�}����� � � /�!�!�!���Q��� � � � � � � �����!���r$�__main__�stdio)� transport)�mcp.server.fastmcpr�dotenvrr r �mcprr&r �tool�intrr r#r'�__name__�run��r�<module>r4s&��&�&�&�&�&�&������� � � � ����� � � � � ��g�����m��q��C�������!��!�!�!� ��!�$�����!�3�!�!�!� ��!�0�����!��!�!�!� ��!�* �z����G�G�g�G�������r3

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/vasstavkumar/weather-mcp-server'

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