Skip to main content
Glama
MementoRC

MCP Git Server

by MementoRC

git_init

Initialize a new Git repository by specifying the path to set up version control for your project using the MCP Git Server.

Instructions

Initialize a new Git repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes

Implementation Reference

  • The core handler function that implements the git_init tool logic: initializes a new Git repository at the specified path using dulwich Repo.init().
    def git_init(repo_path: str) -> str:
        """Initialize new Git repository"""
        try:
            path = Path(repo_path)
            path.mkdir(parents=True, exist_ok=True)
    
            # Initialize repository
            Repo.init(path)
    
            return f"✅ Initialized empty Git repository in {repo_path}"
    
        except Exception as e:
            return f"❌ Init failed: {str(e)}"
  • Pydantic input schema for the git_init tool, defining the required repo_path parameter.
    class GitInit(BaseModel):
        repo_path: str
  • ToolDefinition registration in the central ToolRegistry for the git_init tool (name="git_init"), linking schema and initial placeholder handler.
    ToolDefinition(
        name=GitTools.INIT,
        category=ToolCategory.GIT,
        description="Initialize a new Git repository",
        schema=GitInit,
        handler=placeholder_handler,
        requires_repo=False,  # Special case
    ),
  • Registration of the wrapped git_init handler in the git_handlers dictionary using special _create_git_init_handler (no repo required).
    "git_init": self._create_git_init_handler(git_init),
  • Helper function to create a special wrapper handler for git_init, which extracts repo_path from kwargs and calls the core func (since it doesn't require a Repo object).
    def _create_git_init_handler(self, func):
        """Special handler for git_init which doesn't need a repo object"""
    
        def handler(**kwargs):
            repo_path = kwargs["repo_path"]
            return func(repo_path)
    
        return handler

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/MementoRC/mcp-git'

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