Skip to main content
Glama

Amazon Rainforest Travel Guide

by Ajey95
main1.cpython-312.pyc6.29 kB
� $Mh�����ddlmZddlmZddlZddlZddlmZe�dZdZ dZ ed�Z d e fd �Z e j�d e d e fd ��Ze j�de d ee fd��Ze j�d ee fd��Ze j�de d ee fd��Ze j�de d ee fd��Ze j)d�de d e fd��Zedk(re j/�yy)�)�FastMCP)�ListN)� load_dotenv�85b3ce3597851110001cf6248242468606374428f88f4763f2aea5552� 3c55174be87b47f6800fe947cf913515�85ae2e3f221c38a28845f05b6bb9590e891f0bc2d12a81c474ae395c5�AmazonTravelGuide�placec��d}|td�}tj||��}|j�}d|vrd|vr |d|dfSt d|����)Nz1https://api.opentripmap.com/0.1/en/places/geoname)�name�apikey��params�lat�lonzCoordinates not found for )� OTM_API_KEY�httpx�get�json� ValueError)r �urlr�r�datas �4C:\Users\sister\Desktop\codebasics-mcp\mcp1\main1.py�get_coordinatesrs_�� =�C��{� 3�F� � � �#�f�%�A� �6�6�8�D� ��}��$���E�{�D��K�'�'��6�u�g�>�?� ?�� from_location�returnc�V� t|�\}}td�\}}d}dti}|�d|��|�d|��d�}tj|||��}|j �} | ddd d } d |�d | d dz d�d| ddz d�d�S#t $r} dt | ���cYd} ~ Sd} ~ wwxYw)zEGet route distance and time from source to Amazon Rainforest (Manaus)zManaus, Brazilz:https://api.openrouteservice.org/v2/directions/driving-car� Authorization�,)�start�end)r�headers�featuresr� properties�summaryzFrom z to Manaus: ~�distancei�z.1fz km, ~�durationiz hours by car.z"Unable to calculate route. Error: N)r� ORS_API_KEYrrr� Exception�str) r�src_lat�src_lon�dest_lat�dest_lonrr$rr�router'�es r�get_travel_router3s��� =�*�=�9����,�-=�>���(�J��"�K�0��%�Y�a��y�1�X�J�a��z�:R�S�� �I�I�c�&�'� :�������� �#�A�&�|�4�Y�?���}�o�]�7�:�3F��3M�c�2R�RX�Y`�ak�Yl�os�Ys�tw�Xx�yG�H� H�� �=�3�C��F�8�<�<��=�s�BB� B(� B#�B(�#B(�locationc�D� t|�\}}d}dd|�d|�d�dtd�}tj||��}|j �}t d |���|d D�cgc]}d |d vs� |d d ��c}Scc}w#t d t t��dgcYSxYw)z*Find hotels near a location using Geoapifyz"https://api.geoapify.com/v2/placeszaccommodation.hotelzcircle:r!z,5000�)� categories�filter�limit�apiKeyrzGeoapify response: r%r r&zError in get_nearby_hotels:z"No hotels found or error occurred.)r�GEOAPIFY_API_KEYrrr�printr,r2)r4rrrrr�hotelsr s r�get_nearby_hotelsr>0s���6�"�8�,���S�2��/���u�A�c�U�%�0��&�  �� �I�I�c�&� )������� �#�F�8�,�-�9?� �9K�m�9K��v�Y^�_k�Yl�Ol��l�#�F�+�9K�m�m��m��6� �+�S��V�4�4�5�5�s$�AA?� A:�- A:�7A?�:A?�?Bc� �gd�S)z6Precautions and suggestions before traveling to Amazon)z,Get vaccinated for yellow fever and malaria.z)Carry insect repellent and mosquito nets.z#Travel with a local guide or group.z'Avoid swimming in unknown water bodies.z'Stay hydrated and pack waterproof gear.�r@rr�get_precautionsrADs �� �rc �� t|�\}}d}ddt��i}d||ddddtd �}tj||� �}|j �}|D�cgc]}d |vs�|d s�|d ��c}Scc}w#d gcYSxYw) z7Get nearby adventure spots like hiking and nature sites�0https://api.opentripmap.com/0.1/en/places/radiusr �Bearer �'�znatural,hikingrr6)�radiusrr�rate�kinds�formatr9r rr zNo adventure spots found.�rrrrr� r4rrrr$rrrr s r�get_adventure_spotsrMOs���-�"�8�,���S�@��"�g�k�]�$;�<������%���!�  �� �I�I�c�&� )���v�v�x��+/�U�4�%�6�U�?�u�V�}��f� �4�U�U��U��-�+�,�,�s*�AA6� A1�!A1�'A1�.A6�1A6�6A=c��� t|�\}}d}ddt��i}d||dddtd�}tj||� �}|j �}|D�cgc]}d |vs�|d s�|d ��c}Scc}w#d gcYSxYw) z1Get famous foods or cultural places near locationrCr rDrEzfoods,cultural,historicr6r)rGrrrIr9rJr rr z%Could not retrieve local attractions.rKrLs r�get_monuments_and_foodrOfs���9�"�8�,���S�@��"�g�k�]�$;�<�����.���!� �� �I�I�c�&� )���v�v�x��+/�U�4�%�6�U�?�u�V�}��f� �4�U�U��U��9�7�8�8�s*�AA5� A0� A0�&A0�-A5�0A5�5A<zhello://{name}r c��d|�d�S)z Greet userzHello z-! Ready for your Amazon rainforest adventure?r@)r s r� greet_userrQ|s���D�6�F� G�Gr�__main__)�mcp.server.fastmcpr�typingrr�os�dotenvrr*r;r�mcpr,r�toolr3r>rArMrO�resourcerQ�__name__�runr@rr�<module>r\s^��&�� � �� � � G� �3�� F� � �!�"��@�3�@����� =�C� =�C� =� � =� ����6��6��S� �6� �6�&������c��� ������-�#�-�$�s�)�-� �-�,����9�S�9�T�#�Y�9� �9�*�����H�S�H�S�H� �H� �z���G�G�I�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/Ajey95/MCP'

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