Skip to main content
Glama

init

Initialize a new Git repository by specifying the path, initial branch, template, or creating a bare repository, enabling streamlined repository setup for AI-driven workflows.

Instructions

Initialize new Git repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bareNoCreate a bare repository (--bare)
initialBranchNoSet the initial branch name (--initial-branch)
repoPathYesAbsolute path where to initialize the git repository
templateNoTemplate directory to use (--template)

Implementation Reference

  • The private #handle method that executes the 'init' tool: initializes a Git repo at repoPath using simple-git with optional bare, initialBranch, template flags, returns success message and result.
    	readonly #handle: ToolCallback<typeof GIT_INIT_INPUT_SCHEMA> = async (input) => {
    		const sg = simpleGit(input.repoPath);
    
    		const options: string[] = [];
    
    		if (input.bare) {
    			options.push('--bare');
    		}
    
    		if (input.initialBranch) {
    			options.push('--initial-branch', input.initialBranch);
    		}
    
    		if (input.template) {
    			options.push('--template', input.template);
    		}
    
    		const result = await sg.init(options);
    
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Initialized ${input.bare ? 'bare ' : ''}Git repository in ${input.repoPath}`,
    				},
    				{
    					type: 'text',
    					text: JSON.stringify(result),
    				},
    			],
    		};
    	};
    }
  • Zod input schema for the 'init' tool defining required repoPath and optional bare, initialBranch, template parameters.
    export const GIT_INIT_INPUT_SCHEMA = {
    	repoPath: z.string().describe('Absolute path where to initialize the git repository'),
    	bare: z.boolean().optional().describe('Create a bare repository (--bare)'),
    	initialBranch: z.string().optional().describe('Set the initial branch name (--initial-branch)'),
    	template: z.string().optional().describe('Template directory to use (--template)'),
    };
  • Class method that registers the 'init' tool with the MCP server by calling srv.registerTool(name, config, handle).
    register(srv: McpServer) {
    	srv.registerTool(this.name, this.config, this.#handle);
    }
  • Site where GitInitTool is instantiated and its register method is called to add the 'init' tool to the server.
    new GitInitTool().register(server);
  • Getter returning the tool name as 'init'.
    get name() {
    	return 'init';
    }
Install Server

Other Tools

Related 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/ver0-project/mcps'

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