Skip to main content
Glama

push

Push commits and tags to a remote Git repository, optionally force-pushing changes or skipping pre-push hooks, using the Git MCP Server for enhanced Git operations.

Instructions

Push commits to remote

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchYesBranch name
forceNoForce push changes
noVerifyNoSkip pre-push hooks
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)
remoteNoRemote nameorigin
tagsNoPush all tags

Implementation Reference

  • Primary handler function for the 'push' tool. Validates inputs, executes 'git push' command with options, handles caching and errors.
    static async push({ path, remote = 'origin', branch, force, noVerify, tags }: PushPullOptions, context: GitToolContext): Promise<GitToolResult> {
      const resolvedPath = this.getPath({ path });
      return await this.executeOperation(
        context.operation,
        resolvedPath,
        async () => {
          const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath);
          await RepositoryValidator.validateRemoteConfig(repoPath, remote, context.operation);
          await RepositoryValidator.validateBranchExists(repoPath, branch, context.operation);
          
          const result = await CommandExecutor.executeGitCommand(
            `push ${remote} ${branch}${force ? ' --force' : ''}${noVerify ? ' --no-verify' : ''}${tags ? ' --tags' : ''}`,
            context.operation,
            repoPath
          );
    
          return {
            content: [{
              type: 'text',
              text: `Changes pushed successfully\n${CommandExecutor.formatOutput(result)}`
            }]
          };
        },
        {
          command: 'push',
          invalidateCache: true, // Invalidate remote cache
          stateType: RepoStateType.REMOTE
        }
      );
    }
  • Registers the 'push' tool in the MCP server's ListTools handler, defining name, description, and input schema.
    {
      name: 'push',
      description: 'Push commits to remote',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: `Path to repository. ${PATH_DESCRIPTION}`,
          },
          remote: {
            type: 'string',
            description: 'Remote name',
            default: 'origin',
          },
          branch: {
            type: 'string',
            description: 'Branch name',
          },
          force: {
            type: 'boolean',
            description: 'Force push changes',
            default: false
          },
          noVerify: {
            type: 'boolean',
            description: 'Skip pre-push hooks',
            default: false
          },
          tags: {
            type: 'boolean',
            description: 'Push all tags',
            default: false
          }
        },
        required: ['branch'],
      },
    },
  • TypeScript interface defining the input parameters for push/pull operations, used for type checking and validation.
    export interface PushPullOptions extends GitOptions, BasePathOptions {
      remote?: string;
      branch: string;
      force?: boolean;  // Allow force push/pull
      noVerify?: boolean;  // Skip pre-push/pre-pull hooks
      tags?: boolean;  // Include tags
    }
  • Dispatches 'push' tool calls to GitOperations.push after argument validation.
    case 'push': {
      const validArgs = this.validateArguments(operation, args, isPushPullOptions);
      return await GitOperations.push(validArgs, context);
    }
  • Type guard function used to validate push/pull options before execution.
    export function isPushPullOptions(obj: any): obj is PushPullOptions {
      return obj && 
        validatePath(obj.path) && 
        typeof obj.branch === 'string';
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Push commits to remote' implies a write operation that modifies remote repositories, but it doesn't disclose critical behaviors like potential overwriting of remote changes (implied by 'force'), authentication needs, error conditions (e.g., if the branch doesn't exist), or side effects. This leaves significant gaps for safe and effective use.

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

Conciseness5/5

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

The description is a single, efficient phrase ('Push commits to remote') that front-loads the core purpose without unnecessary words. Every word earns its place, making it easy to parse quickly. There's no redundancy or fluff, which is ideal for conciseness.

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 (6 parameters, no annotations, no output schema), the description is incomplete. It doesn't address behavioral aspects like mutation effects, error handling, or output expectations, which are crucial for a tool that modifies remote state. The high schema coverage helps with parameters, but overall context for safe invocation is lacking.

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?

The schema description coverage is 100%, with all parameters well-documented in the schema (e.g., 'branch' as branch name, 'force' to force push changes). The description adds no additional parameter semantics beyond what's in the schema, such as explaining interactions between parameters (e.g., using 'force' with 'branch'). Given the high schema coverage, the baseline score of 3 is appropriate.

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 'Push commits to remote' clearly states the verb ('push') and resource ('commits to remote'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'pull', 'commit', or 'clone', which have different operations. However, it doesn't specify what kind of commits (e.g., local commits) or mention the repository context, which prevents a perfect score.

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 prerequisites (e.g., having commits ready to push), when to use 'force' or 'noVerify' options, or differentiate from similar tools like 'pull' for fetching changes. Without such context, the agent must infer usage from the tool name alone.

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

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