Skip to main content
Glama

Malaysia Prayer Time MCP Server

config.cpython-311.pyc12.7 kB
� ���g���~�UdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z ddlmZmZgd�Ze eeed<gZe eeed <eGd �d ����ZeGd �d ����ZeGd�d����Ze���ade ee fddfd�ZdS)a  Configuration management for the Malaysia Prayer Time MCP Server. This module provides a configuration system with: - Environment variable overrides - YAML/JSON file loading - Value validation - Configuration locking - Default values - Type safety using dataclasses Usage: # Load from environment variables config.load_from_env() # Load from file config.load_from_file('config.yaml') # Manual configuration config.configure({ 'cache': {'ttl': 7200}, 'http': {'timeout': 5} }) �N)�Path)�Lock)�Dict�Any�Optional�ClassVar�Final)� dataclass�field)z ./config.yamlz ./config.ymlz ./config.json�DEFAULT_CONFIG_PATHS�REQUIRED_ENV_VARSc��eZdZUdZed���Zeed<ed���Ze ed<ed���Z e ed<ed ���Z e eed <d d �Z d S)� CacheConfiga Cache configuration settings. Attributes: type: Cache backend type ('memory' or 'redis') ttl: Default cache TTL in seconds max_size: Maximum number of items in memory cache redis_url: Redis connection URL (only used when type='redis') �memory��default�typei�ttli��max_sizeN� redis_url�returnc���|jdvrtd���|jdkrtd���|jdkrtd���|jdkr|jstd���d Sd S) �Validate configuration values.)r�redisz&Cache type must be 'memory' or 'redis'rzCache TTL must be non-negative�zCache max_size must be positiverz-Redis URL required when cache type is 'redis'N)r� ValueErrorrrr��selfs �Q/Users/aman/2) personal/mcp-server-malaysia-prayer-time/src/waktu_solat/config.py� __post_init__zCacheConfig.__post_init__>s��� �9�/� /� /��E�F�F� F� �8�a�<�<��=�>�>� >� �=�1� � ��>�?�?� ?� �9�� � ��� ��L�M�M� M� � � � ��rN)�__name__� __module__� __qualname__�__doc__r r�str�__annotations__r�intrrrr �r!rrr-s������������h�'�'�'�D�#�'�'�'��u�T�"�"�"�C��"�"�"��E�$�'�'�'�H�c�'�'�'�$�u�T�2�2�2�I�x��}�2�2�2� N� N� N� N� N� Nr!rc���eZdZUdZed���Zeed<ed���Zeed<ed���Z eed<ed���Z e ed <ed ���Z e ed <dd�Zd S)� HTTPConfigaC HTTP client configuration settings. Attributes: timeout: Request timeout in seconds max_retries: Maximum number of retry attempts pool_connections: Maximum number of connections in pool base_url: Base URL for API requests verify_ssl: Whether to verify SSL certificates � r�timeout�� max_retries�pool_connectionszhttps://api.waktusolat.app�base_urlT� verify_sslrNc���|jdkrtd���|jdkrtd���|jdkrtd���|j�d��std���dS) rrzHTTP timeout must be positiverz Max retries must be non-negativez!Pool connections must be positive)zhttp://zhttps://z,Base URL must start with http:// or https://N)r.rr0r1r2� startswithrs rr zHTTPConfig.__post_init__`s��� �<�!� � ��<�=�=� =� � �a� � ��?�@�@� @� � �1� $� $��@�A�A� A��}�'�'�(?�@�@� M��K�L�L� L� M� Mr!r")r#r$r%r&r r.r)r(r0r1r2r'r3�boolr r*r!rr,r,Ms�������� � ��5��$�$�$�G�S�$�$�$��u�Q�'�'�'�K��'�'�'�!�E�"�-�-�-��c�-�-�-��E�">�?�?�?�H�c�?�?�?��u�T�*�*�*�J��*�*�*� M� M� M� M� M� Mr!r,c�<�eZdZUdZee���Zeed<ee���Z eed<e ��Z e e ed<edd���Z eed<dd �Zedd ���Zed eeefd dfd���Zdd�Zddeed d fd�Zd eeefd d fd�Zd S)�Configz� Main configuration container. This class manages all configuration settings and provides methods for loading from different sources. Attributes: cache: Cache-related settings http: HTTP client settings )�default_factory�cache�http�_lockF)r�init� _initializedrNc��d|_dS)z#Mark as initialized after creation.TN)r>rs rr zConfig.__post_init__�s�� ����r!c�L�|t��t�����S)z(Create a default configuration instance.�r:r;)rr,)�clss rrzConfig.default�s!���s����Z�\�\�:�:�:�:r!� config_dictc��tdi|�di����}tdi|�di����}|||���S)a Create a configuration instance from a dictionary. Args: config_dict: Configuration dictionary Returns: New Config instance Raises: ValueError: If configuration values are invalid r:r;rAr*)r�getr,)rBrC� cache_config� http_configs r� from_dictzConfig.from_dict�s[��#�B�B�[�_�_�W�b�%A�%A�B�B� � �?�?�;�?�?�6�2�#>�#>�?�?� ��s��K�8�8�8�8r!c�\�|j5d�tD��}|r%tdd�|�������t t jd|jj����|j_t t jd|jj ����|j_ t jd|jj ��|j_ t jd|jj ��|j_ t t jd|j j ����|j _ t t jd |j j����|j _t t jd |j j����|j _t jd |j j��|j _t jd t#|j j�������d v|j _ddd��dS#1swxYwYdS)z� Load configuration from environment variables. Environment variables should be prefixed with WAKTU_SOLAT_ Example: WAKTU_SOLAT_CACHE_TTL=7200 c�:�g|]}tj|���|��Sr*)�os�getenv)�.0�vars r� <listcomp>z(Config.load_from_env.<locals>.<listcomp>�s%��S�S�S�C�B�I�c�N�N�S�C�S�S�Sr!z(Missing required environment variables: z, �WAKTU_SOLAT_CACHE_TTL�WAKTU_SOLAT_CACHE_MAX_SIZE�WAKTU_SOLAT_CACHE_TYPE�WAKTU_SOLAT_REDIS_URL�WAKTU_SOLAT_HTTP_TIMEOUT�WAKTU_SOLAT_HTTP_MAX_RETRIES�!WAKTU_SOLAT_HTTP_POOL_CONNECTIONS�WAKTU_SOLAT_HTTP_BASE_URL�WAKTU_SOLAT_HTTP_VERIFY_SSL)�true�1�yesN)r<r �EnvironmentError�joinr)rKrLr:rrrrr;r.r0r1r2r'r3�lower)r� missing_varss r� load_from_envzConfig.load_from_env�s!���Z�# .�# .�S�S�+<�S�S�S�L�� �&�X�t�y�y��?V�?V�X�X���� !���+B�D�J�N�!S�!S�T�T�D�J�N�"%�� �6�� �8K�L�L�#�#�D�J� �!�i�(@�$�*�/�R�R�D�J�O�#%�9�'���)=�$�$�D�J� � !$�� �4�d�i�6G�H�H�!�!�D�I� �%(�� �8�$�)�:O�P�P�%�%�D�I� !�*-�� �7���9S���*�*�D�I� &� "$��+�T�Y�-?�"�"�D�I� �$&�9�-�s�4�9�3G�/H�/H�$�$��e�g�g�-�$.�D�I� �C# .�# .�# .�# .�# .�# .�# .�# .�# .�# .�# .�# .����# .�# .�# .�# .�# .�# .s�H H!�!H%�(H%�pathc���|�>tD]'}t|�����r|}n�(td���t|�����5}|�d��rt j|��}ntj |��}ddd��n #1swxYwY|j 5|� |��ddd��dS#1swxYwYdS)a Load configuration from a YAML or JSON file. Args: path: Path to config file. If None, searches default locations. Raises: FileNotFoundError: If no config file found ValueError: If config file format is invalid NzNo configuration file foundz.json) r r�exists�FileNotFoundError�open�endswith�json�load�yaml� safe_loadr<�_update_from_dict)rra� default_path�frCs r�load_from_filezConfig.load_from_file�sr�� �<� 4� G� G� �� �%�%�,�,�.�.��'�D��E��(�(E�F�F�F� �$�Z�Z�_�_� � � 0�!��}�}�W�%�%� 0�"�i��l�l� � �"�n�Q�/�/� �  0� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0���� 0� 0� 0� 0� �Z� 0� 0� � "� "�;� /� /� /� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0���� 0� 0� 0� 0� 0� 0s$�"?B-�-B1�4B1�?C"�"C&�)C&c�~�d|vrtdi|d��}||_d|vrtdi|d��}||_dSdS)z5Update configuration from dictionary with validation.r:r;Nr*)rr:r,r;)rrCrFrGs rrkzConfig._update_from_dict�sb�� �k� !� !�&�>�>��W�)=�>�>�L�%�D�J� �[� � �$�;�;�{�6�':�;�;�K�#�D�I�I�I� !� r!r")rr8)N)r#r$r%r&r rr:r(r,r;rr<rr>r6r � classmethodrrr'rrHr`rrnrkr*r!rr8r8osi������� � ���{�;�;�;�E�;�;�;�;��u�Z�8�8�8�D�*�8�8�8� �D�F�F�E�8�D�>�"�"�"���u�5�9�9�9�L�$�9�9�9�!�!�!�!��;�;�;��[�;��9�D��c��N�9�x�9�9�9��[�9�"*.�*.�*.�*.�X0�0�8�C�=�0�D�0�0�0�0�8$�T�#�s�(�^�$��$�$�$�$�$�$r!r8rCrc�p�tjrtd���t�|��adS)z� Update the global configuration from a dictionary. Args: config_dict: Configuration dictionary Raises: ValueError: If configuration values are invalid RuntimeError: If called after server has started zoConfiguration cannot be modified after initialization. Set all configuration values before starting the server.N)�configr>� RuntimeErrorr8rH)rCs r� configurert�s@���� �� G� � � �� � �k� *� *�F�F�Fr!)r&rKrgri�pathlibr� threadingr�typingrrrrr � dataclassesr r r �listr'r(r rr,r8rrrrtr*r!r�<module>rzs������2 � � � � � � � � � � � �������������7�7�7�7�7�7�7�7�7�7�7�7�7�7�(�(�(�(�(�(�(�(�*�*�*��e�D��I�&����')��5��c��#�(�(�(� �N�N�N�N�N�N�N� ��N�> �M�M�M�M�M�M�M� ��M�B �{$�{$�{$�{$�{$�{$�{$� ��{$�~ ��� � ��+�4��S��>�+�d�+�+�+�+�+�+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/amanasmuei/mcp-server-malaysia-prayer-time'

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