Skip to main content
Glama

get_project_root

Identify the project root and structure type for profiling analysis, returning root path, type, and markers found.

Instructions

Get the detected project root and structure type.

Returns: {root, type, markers_found}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main tool handler for 'get_project_root' - an async function that returns the detected project root path, project type (python/node/mixed/unknown), and markers found. It calls the helper _get_project_root() and checks for common project markers.
    async def get_project_root() -> dict[str, str]:
        """Get the detected project root and structure type.
        
        Returns: {root, type, markers_found}
        """
        root = _get_project_root()
        
        # Detect project type
        project_type = "unknown"
        markers_found = []
        
        if (root / "pyproject.toml").exists():
            project_type = "python"
            markers_found.append("pyproject.toml")
        if (root / "setup.py").exists():
            project_type = "python"
            markers_found.append("setup.py")
        if (root / "package.json").exists():
            project_type = "node" if project_type == "unknown" else "mixed"
            markers_found.append("package.json")
        if (root / ".git").exists():
            markers_found.append(".git")
        if (root / "Makefile").exists():
            markers_found.append("Makefile")
        if (root / "GNUmakefile").exists():
            markers_found.append("GNUmakefile")
        
        return {
            "root": str(root.absolute()),
            "type": project_type,
            "markers_found": ", ".join(markers_found) if markers_found else "none",
        }
  • Internal helper _get_project_root() that returns the cached project root Path, calling _detect_project_root() on first access.
    def _get_project_root() -> Path:
        """Get the current project root (auto-detected or explicitly set)."""
        global _project_root
        if _project_root is None:
            _project_root = _detect_project_root()
        return _project_root
  • Internal helper _detect_project_root() that auto-detects the project root by walking up the directory tree looking for markers like .git, pyproject.toml, setup.py, package.json, Makefile.
    def _detect_project_root(start_path: Path | None = None) -> Path:
        """Auto-detect project root by looking for common markers.
        
        Checks for: .git, pyproject.toml, setup.py, package.json, Makefile
        Falls back to current working directory if no markers found.
        """
        search_path = start_path or Path.cwd()
        if search_path.is_file():
            search_path = search_path.parent
        
        markers = {".git", "pyproject.toml", "setup.py", "package.json", "Makefile", "GNUmakefile"}
        
        # Search up directory tree
        for current in [search_path, *search_path.parents]:
            if any((current / marker).exists() for marker in markers):
                return current
        
        # Fallback to cwd
        return Path.cwd()
  • Registration of get_project_root as an MCP tool via server.tool(get_project_root).
    server.tool(get_project_root)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries burden. It discloses return format {root, type, markers_found} which adds value, but could explicitly state read-only nature and lack of side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences, no wasted words, front-loaded with purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters and no annotations, the description adequately specifies the return value and purpose. Could mention that no input is required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has no parameters (100% coverage trivial). Baseline score of 4 as per guidelines for 0 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states 'Get the detected project root and structure type' with clear verb and resource. It distinguishes from siblings like analyze or list_profiles, though no explicit differentiation is given.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like set_project_context or list_project_files. The description only states what it does.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ptmorris05/scalene-mcp'

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