Skip to main content
Glama
wrale

mcp-server-tree-sitter

by wrale

register_project_tool

Register a project directory for code exploration by specifying the path, name, and description. Enables context-aware code analysis using tree-sitter for intelligent codebase access.

Instructions

Register a project directory for code exploration.

    Args:
        path: Path to the project directory
        name: Optional name for the project (defaults to directory name)
        description: Optional description of the project

    Returns:
        Project information
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
nameNo
pathYes

Implementation Reference

  • The core handler function for the MCP tool 'register_project_tool'. It registers a new project using the project_registry, scans the project files to detect languages, handles errors with ProjectError, and returns the project information as a dictionary.
    @mcp_server.tool()
    def register_project_tool(
        path: str, name: Optional[str] = None, description: Optional[str] = None
    ) -> Dict[str, Any]:
        """Register a project directory for code exploration.
    
        Args:
            path: Path to the project directory
            name: Optional name for the project (defaults to directory name)
            description: Optional description of the project
    
        Returns:
            Project information
        """
        try:
            # Register project
            project = project_registry.register_project(name or path, path, description)
    
            # Scan for languages
            project.scan_files(language_registry)
    
            return project.to_dict()
        except Exception as e:
            raise ProjectError(f"Failed to register project: {e}") from e
  • The registration point where register_tools is called on the MCP server instance, which in turn defines and registers the 'register_project_tool' handler along with all other tools.
    register_capabilities(mcp)
    register_tools(mcp, container)
  • Helper API function 'register_project' that performs similar project registration logic, used in tests via alias 'api_register_project'.
    def register_project(path: str, name: Optional[str] = None, description: Optional[str] = None) -> Dict[str, Any]:
        """Register a project."""
        project_registry = get_project_registry()
        language_registry = get_language_registry()
    
        try:
            # Register project
            project = project_registry.register_project(name or path, path, description)
    
            # Scan for languages
            project.scan_files(language_registry)
    
            project_dict = project.to_dict()
            # Add type annotations
            result: Dict[str, Any] = {
                "name": project_dict["name"],
                "root_path": project_dict["root_path"],
                "description": project_dict["description"],
                "languages": project_dict["languages"],
                "last_scan_time": project_dict["last_scan_time"],
            }
            return result
        except Exception as e:
            raise ProjectError(f"Failed to register project: {e}") from e

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