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
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| name | No | ||
| path | Yes |
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
- 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 '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