Skip to main content
Glama

clone

Clone a Git repository from a specified URL to a specific local path using the Git MCP Server's enhanced capabilities. Ideal for initializing projects or managing codebases programmatically.

Instructions

Clone a repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoPath to clone into. MUST be an absolute path (e.g., /Users/username/projects/my-repo)
urlYesURL of the repository to clone

Implementation Reference

  • The main handler function in GitOperations class that validates the path, executes the 'git clone' command via CommandExecutor, handles caching and errors, and returns the formatted result.
    static async clone(options: CloneOptions, context: GitToolContext): Promise<GitToolResult> {
      const path = this.getPath(options);
      return await this.executeOperation(
        context.operation,
        path,
        async () => {
          const pathInfo = PathValidator.validatePath(path, { mustExist: false, allowDirectory: true });
          const result = await CommandExecutor.executeGitCommand(
            `clone ${options.url} ${pathInfo}`,
            context.operation
          );
    
          return {
            content: [{
              type: 'text',
              text: `Repository cloned successfully\n${CommandExecutor.formatOutput(result)}`
            }]
          };
        },
        {
          command: 'clone',
          invalidateCache: true // Invalidate all caches for this repo
        }
      );
    }
  • Type definition for CloneOptions interface, defining the input parameters including required 'url' and optional 'path'.
    export interface CloneOptions extends GitOptions, BasePathOptions {
      /**
       * URL of the repository to clone
       */
      url: string;
    }
  • Type guard function to validate if an object conforms to CloneOptions.
    export function isCloneOptions(obj: any): obj is CloneOptions {
      return obj && 
        typeof obj.url === 'string' &&
        validatePath(obj.path);
    }
  • Tool registration in the ListTools handler, defining the 'clone' tool name, description, and input schema.
    {
      name: 'clone',
      description: 'Clone a repository',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL of the repository to clone',
          },
          path: {
            type: 'string',
            description: `Path to clone into. ${PATH_DESCRIPTION}`,
          },
        },
        required: ['url'],
      },
    },
  • Dispatch logic in the CallTool handler switch statement that validates arguments using isCloneOptions and calls the GitOperations.clone handler.
    case 'clone': {
      const validArgs = this.validateArguments(operation, args, isCloneOptions);
      return await GitOperations.clone(validArgs, context);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Clone a repository' implies a read operation that creates a local copy, but it doesn't specify whether this requires network access, authentication, or has side effects like creating directories. It lacks details on error handling, success criteria, or what happens if the path exists, leaving significant gaps for a mutation-like tool.

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 sentence with zero wasted words. It is front-loaded with the core action and resource, making it immediately scannable. Every word ('clone', 'a', 'repository') earns its place by contributing essential meaning without redundancy.

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 complexity of a cloning operation (involving network access, file system changes, potential authentication), the description is incomplete. With no annotations and no output schema, it fails to address critical aspects like what the tool returns (e.g., success message, error details), behavioral traits, or usage context. This is inadequate for a tool that likely performs significant operations.

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%, with both parameters ('path' and 'url') well-documented in the schema itself. The description adds no additional parameter semantics beyond implying that 'url' is for the source repository and 'path' is the destination. This meets the baseline score of 3 since the schema does the heavy lifting.

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 action ('clone') and resource ('a repository'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'init' (create new repo) or 'pull' (update existing repo). However, it doesn't specify what type of repository (e.g., Git) or mention the cloning mechanism, 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., needing Git installed), contrast with 'init' for creating new repos, or specify when cloning is appropriate versus other operations like 'pull' for existing repos. The agent must infer usage from context 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