Skip to main content
Glama
kazuph

MCP Docs RAG Server

by kazuph

add_git_repository

Add a Git repository to the MCP Docs RAG Server for retrieval-augmented generation. Specify a repository URL, optional custom document name, and subdirectory for sparse checkout to organize and access specific content efficiently.

Instructions

Add a git repository to the docs directory with optional sparse checkout. Please do not use 'docs' in the document name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_nameNoOptional: Custom name for the document (defaults to repository name). Use a simple, descriptive name without '-docs' suffix. For example, use 'react' instead of 'react-docs'.
repository_urlYesURL of the git repository to clone
subdirectoryNoOptional: Specific subdirectory to sparse checkout (e.g. 'path/to/specific/dir'). This uses Git's sparse-checkout feature to only download the specified directory.

Implementation Reference

  • MCP CallTool handler case for 'add_git_repository': validates input, invokes cloneRepository helper, handles existing document check and formats success/error responses.
    case "add_git_repository": {
      const repositoryUrl = String(request.params.arguments?.repository_url);
      const subdirectory = request.params.arguments?.subdirectory ? String(request.params.arguments?.subdirectory) : undefined;
      const documentName = request.params.arguments?.document_name ? String(request.params.arguments?.document_name) : undefined;
      
      if (!repositoryUrl) {
        throw new Error("Repository URL is required");
      }
      
      const result = await cloneRepository(repositoryUrl, subdirectory, documentName);
      
      // If document already exists, inform the user without updating
      if (result.exists) {
        return {
          content: [{
            type: "text",
            text: `Document '${result.name}' already exists. Please use list_documents to view existing documents.`
          }]
        };
      }
      
      // Prepare response message for new document
      let responseText = `Added git repository: ${result.name}`;
      
      if (subdirectory) {
        responseText += ` (sparse checkout of '${subdirectory}')`;  
      }
      
      if (documentName) {
        responseText += ` with custom name '${documentName}'`;  
      }
      
      return {
        content: [{
          type: "text",
          text: `${responseText}. The index will be created when you query this document for the first time.`
        }]
      };
    }
  • Schema definition for add_git_repository tool in ListTools response, defining parameters: repository_url (required), document_name (optional), subdirectory (optional).
    {
      name: "add_git_repository",
      description: "Add a git repository to the docs directory with optional sparse checkout. Please do not use 'docs' in the document name.",
      inputSchema: {
        type: "object",
        properties: {
          repository_url: {
            type: "string",
            description: "URL of the git repository to clone"
          },
          document_name: {
            type: "string",
            description: "Optional: Custom name for the document (defaults to repository name). Use a simple, descriptive name without '-docs' suffix. For example, use 'react' instead of 'react-docs'."
          },
          subdirectory: {
            type: "string",
            description: "Optional: Specific subdirectory to sparse checkout (e.g. 'path/to/specific/dir'). This uses Git's sparse-checkout feature to only download the specified directory."
          }
        },
        required: ["repository_url"]
      }
    },
  • Core helper function implementing git clone logic: normal clone or sparse-checkout for subdirectory, checks for existing repos, normalizes name.
    export async function cloneRepository(repoUrl: string, subdirectory?: string, documentName?: string): Promise<{ name: string; exists: boolean }> {
      // Use custom document name if provided, otherwise normalize repo name
      const repoName = documentName || normalizeRepoName(repoUrl);
      const repoPath = path.join(DOCS_PATH, repoName);
      
      // Check if repository already exists
      if (fs.existsSync(repoPath)) {
        // Document already exists, don't update it
        return { name: repoName, exists: true };
      } else {
        if (subdirectory) {
          // Clone with sparse-checkout for specific subdirectory
          await execAsync(`mkdir -p "${repoPath}" && cd "${repoPath}" && \
                          git init && \
                          git remote add origin ${repoUrl} && \
                          git config core.sparseCheckout true && \
                          git config --local core.autocrlf false && \
                          echo "${subdirectory}/*" >> .git/info/sparse-checkout && \
                          git pull --depth=1 origin main || git pull --depth=1 origin master`);
        } else {
          // Normal clone for the entire repository
          await execAsync(`cd "${DOCS_PATH}" && git clone ${repoUrl}`);
        }
      }
      
      return { name: repoName, exists: false };
    }
  • Utility function to derive document name from repository URL by taking basename and stripping .git.
    export function normalizeRepoName(repoUrl: string): string {
      const parts = repoUrl.split('/');
      return parts[parts.length - 1].replace('.git', '');
    }
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. It mentions that the tool adds a repository and supports sparse checkout, but does not describe key behaviors such as what happens if the repository already exists, whether it requires authentication, if there are rate limits, or what the output looks like. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 concise and front-loaded, consisting of two sentences that directly state the tool's purpose and a key instruction. There is no wasted language, and every sentence serves a clear purpose in guiding usage.

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 (adding a git repository with sparse checkout), lack of annotations, and no output schema, the description is incomplete. It fails to address important contextual aspects such as error handling, success criteria, or what the agent should expect after invocation, leaving gaps for effective tool use.

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 three parameters thoroughly. The description adds minimal value beyond the schema by implying the tool's purpose relates to these parameters, but does not provide additional syntax, format details, or usage examples that aren't already covered in the schema descriptions.

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: 'Add a git repository to the docs directory with optional sparse checkout.' It specifies the verb ('add'), resource ('git repository'), and destination ('docs directory'), but does not explicitly differentiate it from sibling tools like 'add_text_file' or 'list_documents' beyond the type of resource being added.

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

Usage Guidelines3/5

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

The description provides some implied usage guidance by mentioning 'optional sparse checkout' and a specific instruction: 'Please do not use 'docs' in the document name.' However, it does not explicitly state when to use this tool versus alternatives like 'add_text_file' for non-git content or 'rag_query' for querying documents, nor does it outline prerequisites or exclusions.

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/kazuph/mcp-docs-rag'

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