Skip to main content
Glama
hydavinci

Chromium Commits Query Tool

by hydavinci

get_chromium_latest_commit

Retrieve the most recent commit details for a specific file in the Chromium repository, including hash, author, message, and changes.

Instructions

MCP handler to get the latest commit information for a specified file in Chromium repository

Args:
    file_path (str): Relative path of the file in Chromium repository (e.g., "components/sync/service/data_type_manager.cc")

Returns:
    str: Formatted commit information including hash, author, message, modified files list, and diff details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Implementation Reference

  • The MCP tool handler function, registered via @mcp.tool decorator, which executes the tool logic by instantiating ChromiumCommitFetcher and calling its get_file_commit_info method with detailed and diff options.
    @mcp.tool("get_chromium_latest_commit")
    async def get_chromium_latest_commit(file_path: str):
        """
        MCP handler to get the latest commit information for a specified file in Chromium repository
    
        Args:
            file_path (str): Relative path of the file in Chromium repository (e.g., "components/sync/service/data_type_manager.cc")
    
        Returns:
            str: Formatted commit information including hash, author, message, modified files list, and diff details
        """
        fetcher = ChromiumCommitFetcher()
        return fetcher.get_file_commit_info(file_path, detailed=True, show_diff=True)
  • Core helper method in ChromiumCommitFetcher class that orchestrates fetching the latest commit info for a file, retrieves commit details and diff if requested, and formats the output. This is the primary implementation delegated to by the tool handler.
    def get_file_commit_info(
        self, file_path: str, detailed: bool = True, show_diff: bool = False
    ) -> Optional[str]:
        """
        Get complete commit information for a file
    
        Args:
            file_path: File path
            detailed: Whether to get detailed information (including all modified files)
            show_diff: Whether to show diff code comparison
    
        Returns:
            Formatted commit information string
        """
        # Get the latest commit for the file
        commit_info = self.get_file_latest_commit(file_path)
        if not commit_info:
            return None
    
        commit_details = None
        commit_diff = None
    
        commit_hash = commit_info.get("commit")
        if commit_hash:
            if detailed:
                commit_details = self.get_commit_details(commit_hash)
            if show_diff:
                commit_diff = self.get_commit_diff(commit_hash)
    
        return self.format_commit_info(
            commit_info, commit_details, show_diff, commit_diff
        )
  • Helper method that queries the Chromium Gitiles API to find the latest commit hash and basic info for the specific file path.
    def get_file_latest_commit(self, file_path: str) -> Optional[Dict]:
        """
        Get the latest commit information for the specified file
    
        Args:
            file_path: Relative path of the file, e.g. "components/sync/service/data_type_manager.cc"
    
        Returns:
            Dictionary containing commit information, or None if not found
        """
        # Normalize path format (use forward slashes)
        normalized_path = file_path.replace("\\", "/")
        # Build API URL to get commit history for this file
        url = f"{self.base_url}/+log/HEAD/{normalized_path}?format=JSON&n=1"
    
        try:
            print(f"Querying file: {normalized_path}")
            print(f"Request URL: {url}")
    
            response = requests.get(url, timeout=30)
            response.raise_for_status()
    
            # Gitiles API returns JSON with a security prefix ")]}'" that needs to be removed
            content = response.text
            if content.startswith(")]}'"):
                content = content[4:]
    
            data = json.loads(content)
    
            if "log" not in data or not data["log"]:
                print(f"Error: No commit history found for file {normalized_path}")
                return None
    
            # Get the latest commit
            latest_commit = data["log"][0]
            return latest_commit
    
        except requests.exceptions.RequestException as e:
            print(f"Network request error: {e}")
            return None
        except json.JSONDecodeError as e:
            print(f"JSON parsing error: {e}")
            return None
        except Exception as e:
            print(f"Unknown error: {e}")
            return None
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/hydavinci/chromium-commits'

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