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
| Name | Required | Description | Default |
|---|---|---|---|
| cache_enabled | No | ||
| config_path | No | ||
| log_level | No | ||
| max_file_size_mb | No |
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()
- src/mcp_server_tree_sitter/server.py:154-155 (registration)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)
- src/mcp_server_tree_sitter/tools/registration.py:17-23 (registration)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 """