Skip to main content
Glama

git-remote

Manage Git remote repositories by adding, removing, renaming, displaying, updating URLs, and pruning stale references to organize your project's remote connections.

Instructions

Git remote management tool for managing remote repositories. Supports add, remove, rename, show, set-url, and prune operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe remote operation to perform
allNoShow all remotes (for show action)
dryRunNoShow what would be pruned without actually pruning (for prune action)
fetchNoFetch after adding remote (for add action)
nameNoRemote name (required for most operations)
newNameNoNew remote name (required for rename operation)
projectPathYesAbsolute path to the project directory
pushNoSet push URL instead of fetch URL (for set-url action)
urlNoRemote URL (required for add and set-url operations)
verboseNoShow verbose output with URLs (for show action)

Implementation Reference

  • Main handler function of GitRemoteTool class that validates parameters, checks Git repository, and routes to specific operation handlers (add, remove, rename, show, set-url, prune, list).
    async execute(params: GitRemoteParams): Promise<ToolResult> {
      const startTime = Date.now();
    
      try {
        // Validate basic parameters
        const validation = ParameterValidator.validateToolParams('git-remote', params);
        if (!validation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Parameter validation failed: ${validation.errors.join(', ')}`,
            params.action,
            { validationErrors: validation.errors },
            validation.suggestions
          );
        }
    
        // Validate operation-specific parameters
        const operationValidation = this.validateOperationParams(params);
        if (!operationValidation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Operation validation failed: ${operationValidation.errors.join(', ')}`,
            params.action,
            { validationErrors: operationValidation.errors },
            operationValidation.suggestions
          );
        }
    
        // Check if it's a Git repository
        const isRepo = await this.gitExecutor.isGitRepository(params.projectPath);
        if (!isRepo) {
          return OperationErrorHandler.createToolError(
            'NOT_A_GIT_REPOSITORY',
            'The specified path is not a Git repository',
            params.action,
            { projectPath: params.projectPath },
            ['Initialize a Git repository first with: git init']
          );
        }
    
        // Route to appropriate handler
        switch (params.action) {
          case 'add':
            return await this.handleAdd(params, startTime);
          case 'remove':
            return await this.handleRemove(params, startTime);
          case 'rename':
            return await this.handleRename(params, startTime);
          case 'show':
            return await this.handleShow(params, startTime);
          case 'set-url':
            return await this.handleSetUrl(params, startTime);
          case 'prune':
            return await this.handlePrune(params, startTime);
          case 'list':
            return await this.handleList(params, startTime);
          default:
            return OperationErrorHandler.createToolError(
              'UNSUPPORTED_OPERATION',
              `Operation '${params.action}' is not supported`,
              params.action,
              {},
              ['Use one of: add, remove, rename, show, set-url, prune, list']
            );
        }
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return OperationErrorHandler.createToolError(
          'EXECUTION_ERROR',
          `Failed to execute ${params.action}: ${errorMessage}`,
          params.action,
          { error: errorMessage },
          ['Check the error details and try again']
        );
      }
    }
  • Static method providing the complete tool schema for MCP protocol registration, including name, description, and detailed input schema with all parameters and enums.
    static getToolSchema() {
      return {
        name: 'git-remote',
        description: 'Git remote management tool for managing remote repositories. Supports add, remove, rename, show, set-url, and prune operations.',
        inputSchema: {
          type: 'object',
          properties: {
            action: {
              type: 'string',
              enum: ['add', 'remove', 'rename', 'show', 'set-url', 'prune', 'list'],
              description: 'The remote operation to perform'
            },
            projectPath: {
              type: 'string',
              description: 'Absolute path to the project directory'
            },
            name: {
              type: 'string',
              description: 'Remote name (required for most operations)'
            },
            url: {
              type: 'string',
              description: 'Remote URL (required for add and set-url operations)'
            },
            newName: {
              type: 'string',
              description: 'New remote name (required for rename operation)'
            },
            fetch: {
              type: 'boolean',
              description: 'Fetch after adding remote (for add action)'
            },
            push: {
              type: 'boolean',
              description: 'Set push URL instead of fetch URL (for set-url action)'
            },
            all: {
              type: 'boolean',
              description: 'Show all remotes (for show action)'
            },
            verbose: {
              type: 'boolean',
              description: 'Show verbose output with URLs (for show action)'
            },
            dryRun: {
              type: 'boolean',
              description: 'Show what would be pruned without actually pruning (for prune action)'
            }
          },
          required: ['action', 'projectPath']
        }
      };
    }
  • src/server.ts:123-132 (registration)
    Tool registration in MCP server's ListToolsRequestSchema handler, where GitRemoteTool.getToolSchema() is included in the returned list of available tools.
    return {
      tools: [
        GitWorkflowTool.getToolSchema(),
        GitFilesTool.getToolSchema(),
        GitBranchesTool.getToolSchema(),
        GitIssuesTool.getToolSchema(),
        GitPullsTool.getToolSchema(),
        GitTagsTool.getToolSchema(),
        GitReleaseTool.getToolSchema(),
        GitRemoteTool.getToolSchema(),
  • src/server.ts:484-485 (registration)
    Execution dispatch in the server's CallToolRequestSchema handler switch statement, routing 'git-remote' calls to the tool instance's execute method.
    case 'git-remote':
      return await this.gitRemoteTool.execute(args);
  • Operation-specific parameter validation helper method used by the main handler to ensure required parameters for each git-remote action.
    private validateOperationParams(params: GitRemoteParams): { isValid: boolean; errors: string[]; suggestions: string[] } {
      const errors: string[] = [];
      const suggestions: string[] = [];
    
      switch (params.action) {
        case 'add':
          if (!params.name) {
            errors.push('Remote name is required for add operation');
            suggestions.push('Provide a remote name (e.g., "origin", "upstream")');
          }
          if (!params.url) {
            errors.push('Remote URL is required for add operation');
            suggestions.push('Provide a remote URL (e.g., "https://github.com/user/repo.git")');
          }
          break;
    
        case 'remove':
          if (!params.name) {
            errors.push('Remote name is required for remove operation');
            suggestions.push('Provide the name of the remote to remove');
          }
          break;
    
        case 'rename':
          if (!params.name) {
            errors.push('Current remote name is required for rename operation');
            suggestions.push('Provide the current remote name');
          }
          if (!params.newName) {
            errors.push('New remote name is required for rename operation');
            suggestions.push('Provide the new remote name');
          }
          break;
    
        case 'set-url':
          if (!params.name) {
            errors.push('Remote name is required for set-url operation');
            suggestions.push('Provide the remote name to update');
          }
          if (!params.url) {
            errors.push('Remote URL is required for set-url operation');
            suggestions.push('Provide the new remote URL');
          }
          break;
    
        case 'prune':
          if (!params.name) {
            errors.push('Remote name is required for prune operation');
            suggestions.push('Provide the remote name to prune (e.g., "origin")');
          }
          break;
    
        case 'show':
          // Show operation can work without parameters (shows all remotes)
          break;
      }
    
      return {
        isValid: errors.length === 0,
        errors,
        suggestions
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it lists the operations supported, it doesn't describe what each operation actually does, their side effects, error conditions, or output formats. For example, it doesn't clarify that 'prune' removes stale remote-tracking branches or that 'show' displays information about remotes. The description provides minimal behavioral context beyond the operation names.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with just two sentences that efficiently convey the tool's domain and supported operations. It's front-loaded with the core purpose and follows with the operation list. There's no wasted verbiage or redundant information. However, it could be slightly more structured by grouping related operations or indicating which are mutating versus read-only.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (10 parameters supporting 7 distinct operations), no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns for different operations, doesn't describe error handling, and provides minimal behavioral context. For a multi-operation tool with significant parameter complexity, the description should do more to guide proper usage and set expectations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 10 parameters thoroughly with clear descriptions of each parameter's purpose and when they're required. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain parameter relationships, provide examples, or clarify edge cases. The baseline score of 3 reflects adequate parameter documentation through the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Git remote management tool for managing remote repositories' and enumerates the specific operations supported (add, remove, rename, show, set-url, prune). It distinguishes itself from siblings by focusing specifically on remote repository operations rather than other Git functions like branches, tags, or analytics. However, it doesn't explicitly differentiate from all siblings beyond the general domain focus.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose specific operations (e.g., when to use 'set-url' vs 'rename'), nor does it reference sibling tools that might handle related functionality. There's no context about prerequisites, dependencies, or typical workflows where this tool would be appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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