git_init
Set up a new Git repository by specifying the path. This tool simplifies repository initialization, enabling quick project setup for version control.
Instructions
Initialize a new Git repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes |
Implementation Reference
- src/mcp_server_git/server.py:129-134 (handler)The main handler function for git_init tool that initializes a new Git repository at the given path using gitpython Repo.init().def git_init(repo_path: str) -> str: try: repo = git.Repo.init(path=repo_path, mkdir=True) return f"Initialized empty Git repository in {repo.git_dir}" except Exception as e: return f"Error initializing repository: {str(e)}"
- src/mcp_server_git/server.py:60-62 (schema)Pydantic BaseModel defining the input schema for the git_init tool, which requires a repo_path string.class GitInit(BaseModel): repo_path: str
- src/mcp_server_git/server.py:226-230 (registration)Registration of the git_init tool within the list_tools() decorator, defining its name, description, and input schema.Tool( name=GitTools.INIT, description="Initialize a new Git repository", inputSchema=GitInit.schema(), )
- src/mcp_server_git/server.py:75-75 (helper)Enum value in GitTools defining the string name 'git_init' for the tool.INIT = "git_init"
- src/mcp_server_git/server.py:267-272 (registration)Dispatch logic in the call_tool() handler specifically for git_init, calling the handler function and returning the result as TextContent.if name == GitTools.INIT: result = git_init(str(repo_path)) return [TextContent( type="text", text=result )]