Skip to main content
Glama

remote_add

Enable AI assistants to add a Git remote by specifying the repository path, remote name, and URL for enhanced repository management via the Git MCP Server.

Instructions

Add a remote

Input Schema

NameRequiredDescriptionDefault
nameYesRemote name
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)
urlYesRemote URL

Input Schema (JSON Schema)

{ "properties": { "name": { "description": "Remote name", "type": "string" }, "path": { "description": "Path to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)", "type": "string" }, "url": { "description": "Remote URL", "type": "string" } }, "required": [ "name", "url" ], "type": "object" }

Implementation Reference

  • The primary handler function in GitOperations class that executes the 'git remote add' command. It validates the repository path, remote name, and URL, runs the git command via CommandExecutor, handles caching invalidation, and formats the success response.
    static async remoteAdd({ path, name, url }: RemoteOptions, context: GitToolContext): Promise<GitToolResult> { const resolvedPath = this.getPath({ path }); return await this.executeOperation( context.operation, resolvedPath, async () => { const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath); PathValidator.validateRemoteName(name); if (!url) { throw ErrorHandler.handleValidationError( new Error('URL is required when adding a remote'), { operation: context.operation, path: repoPath } ); } PathValidator.validateRemoteUrl(url); const result = await CommandExecutor.executeGitCommand( `remote add ${name} ${url}`, context.operation, repoPath ); return { content: [{ type: 'text', text: `Remote '${name}' added successfully\n${CommandExecutor.formatOutput(result)}` }] }; }, { command: 'remote_add', invalidateCache: true, // Invalidate remote cache stateType: RepoStateType.REMOTE } ); }
  • Registration and dispatch logic in ToolHandler's CallToolRequest handler switch statement. Validates arguments using isRemoteOptions type guard and delegates to GitOperations.remoteAdd.
    case 'remote_add': { const validArgs = this.validateArguments(operation, args, isRemoteOptions); return await GitOperations.remoteAdd(validArgs, context); }
  • JSON schema definition for the 'remote_add' tool provided to MCP clients via ListToolsRequest. Specifies input parameters: path (optional), name and url (required).
    name: 'remote_add', description: 'Add a remote', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, name: { type: 'string', description: 'Remote name', }, url: { type: 'string', description: 'Remote URL', }, }, required: ['name', 'url'], },

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

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