Skip to main content
Glama
wrale

mcp-server-tree-sitter

by wrale

configure

Customize server settings by specifying a YAML config file, enabling parse tree caching, setting maximum file size, and adjusting log level for optimized code analysis using tree-sitter.

Instructions

Configure the server.

    Args:
        config_path: Path to YAML config file
        cache_enabled: Whether to enable parse tree caching
        max_file_size_mb: Maximum file size in MB
        log_level: Logging level (DEBUG, INFO, WARNING, ERROR)

    Returns:
        Current configuration
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cache_enabledNo
config_pathNo
log_levelNo
max_file_size_mbNo

Implementation Reference

  • The handler function for the 'configure' tool. It updates the server's configuration by loading from a YAML file if provided, and/or setting specific parameters like cache_enabled, max_file_size_mb, and log_level. Returns the current configuration as a dictionary.
    @mcp_server.tool()
    def configure(
        config_path: Optional[str] = None,
        cache_enabled: Optional[bool] = None,
        max_file_size_mb: Optional[int] = None,
        log_level: Optional[str] = None,
    ) -> Dict[str, Any]:
        """Configure the server.
    
        Args:
            config_path: Path to YAML config file
            cache_enabled: Whether to enable parse tree caching
            max_file_size_mb: Maximum file size in MB
            log_level: Logging level (DEBUG, INFO, WARNING, ERROR)
    
        Returns:
            Current configuration
        """
        # Get initial config for comparison
        initial_config = config_manager.get_config()
        logger.info(
            f"Initial configuration: "
            f"cache.max_size_mb = {initial_config.cache.max_size_mb}, "
            f"security.max_file_size_mb = {initial_config.security.max_file_size_mb}, "
            f"language.default_max_depth = {initial_config.language.default_max_depth}"
        )
    
        # Load config if path provided
        if config_path:
            logger.info(f"Configuring server with YAML config from: {config_path}")
            # Log absolute path to ensure we're looking at the right file
            abs_path = os.path.abspath(config_path)
            logger.info(f"Absolute path: {abs_path}")
    
            # Check if the file exists before trying to load it
            if not os.path.exists(abs_path):
                logger.error(f"Config file does not exist: {abs_path}")
    
            config_manager.load_from_file(abs_path)
    
        # Update specific settings
        if cache_enabled is not None:
            logger.info(f"Setting cache.enabled to {cache_enabled}")
            config_manager.update_value("cache.enabled", cache_enabled)
            tree_cache.set_enabled(cache_enabled)
    
        if max_file_size_mb is not None:
            logger.info(f"Setting security.max_file_size_mb to {max_file_size_mb}")
            config_manager.update_value("security.max_file_size_mb", max_file_size_mb)
    
        if log_level is not None:
            logger.info(f"Setting log_level to {log_level}")
            config_manager.update_value("log_level", log_level)
    
        # Return current config as dict
        return config_manager.to_dict()
  • The registration point where register_tools is called on the MCP server instance, which in turn defines and registers the 'configure' tool using the @mcp_server.tool() decorator inside the register_tools function.
    register_capabilities(mcp)
    register_tools(mcp, container)
  • The register_tools function that contains all tool registrations, including the 'configure' tool.
    def register_tools(mcp_server: Any, container: DependencyContainer) -> None:
        """Register all MCP tools with dependency injection.
    
        Args:
            mcp_server: MCP server instance
            container: Dependency container
        """

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/wrale/mcp-server-tree-sitter'

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