Skip to main content
Glama
config_handler.py1.13 kB
from configupdater import ConfigUpdater from pathlib import Path # ---------------------------- # Load configuration file # ---------------------------- config = ConfigUpdater() path = Path(__file__).resolve().parents[2] / "config.ini" config.read(path) # ---------------------------- # Functions # ---------------------------- def get_config_value(section: str, key: str, fallback='') -> str: """ Returns a configuration value from the given section and key. """ return config.get(section, key, fallback=fallback).value def set_config_value(section: str, key: str, value: str) -> None: """ Set a configuration value in the given section. (The changes are only applied in memory, not persisted on disk! To persist call save_config()) """ config.set(section, key, value) def save_config() -> None: """ Write the current config state to the config.ini file. """ with open(path, 'w') as config_file: config.write(config_file) def reload_config() -> None: """ Force reload of config.ini values into memory. """ global config config.read(path)

Latest Blog Posts

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/lgndluke/REI3-Tickets-MCP-Server'

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