Skip to main content
Glama

getRemoteCodebase

Retrieve a remote GitHub repository's codebase as a single text output in XML, markdown, or plain format, with options to include file summaries, directory structures, line numbers, and filter content using patterns.

Instructions

Retrieve a remote repository's codebase as a single text output using RepoMix

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format (xml, markdown, or plain)xml
ignorePatternsNoIgnore patterns (using glob patterns, comma-separated)
includeDirectoryStructureNoInclude directory structure
includeFileSummaryNoInclude summary of each file
includePatternsNoInclude patterns (using glob patterns, comma-separated)
removeCommentsNoRemove comments from the code
removeEmptyLinesNoRemove empty lines from the code
repoYesGitHub repository URL or shorthand format (e.g., 'username/repo')
showLineNumbersNoShow line numbers

Implementation Reference

  • Handler function that constructs and executes a 'repomix --remote' command to retrieve the remote codebase as text output, handling various formatting options and error cases.
    async ({ repo, format, includeFileSummary, includeDirectoryStructure, removeComments, removeEmptyLines, showLineNumbers, includePatterns, ignorePatterns }) => {
      try {
        let command = `npx repomix --remote ${repo} --output stdout`;
        
        // Add formatting options
        if (format) {
          command += ` --style ${format}`;
        }
        
        if (includeFileSummary === true) {
          command += ` --include-file-summary`;
        } else if (includeFileSummary === false) {
          command += ` --no-include-file-summary`;
        }
        
        if (includeDirectoryStructure === true) {
          command += ` --include-directory-structure`;
        } else if (includeDirectoryStructure === false) {
          command += ` --no-include-directory-structure`;
        }
        
        if (removeComments === true) {
          command += ` --remove-comments`;
        } else if (removeComments === false) {
          command += ` --no-remove-comments`;
        }
        
        if (removeEmptyLines === true) {
          command += ` --remove-empty-lines`;
        } else if (removeEmptyLines === false) {
          command += ` --no-remove-empty-lines`;
        }
        
        if (showLineNumbers === true) {
          command += ` --show-line-numbers`;
        } else if (showLineNumbers === false) {
          command += ` --no-show-line-numbers`;
        }
        
        if (includePatterns) {
          command += ` --include "${includePatterns}"`;
        }
        
        if (ignorePatterns) {
          command += ` --ignore "${ignorePatterns}"`;
        }
    
        console.error(`Running command: ${command}`);
        
        // Run Repomix to dump the codebase
        const output = execSync(command, {
          maxBuffer: 1024 * 1024 * 50, // 50MB buffer for large codebases
        }).toString();
    
        return {
          content: [
            {
              type: "text",
              text: output,
            },
          ],
        };
      } catch (error: unknown) {
        console.error("Error running Repomix on remote repository:", error);
        return {
          content: [
            {
              type: "text",
              text: `Error retrieving remote codebase: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
  • Zod schema defining the input parameters for the getRemoteCodebase tool, including repo URL and various repomix options.
    {
      repo: z.string().describe("GitHub repository URL or shorthand format (e.g., 'username/repo')"),
      format: z.enum(["xml", "markdown", "plain"]).describe("Output format (xml, markdown, or plain)").default("xml").optional(),
      includeFileSummary: z.boolean().describe("Include summary of each file").default(true).optional(),
      includeDirectoryStructure: z.boolean().describe("Include directory structure").default(true).optional(),
      removeComments: z.boolean().describe("Remove comments from the code").default(false).optional(),
      removeEmptyLines: z.boolean().describe("Remove empty lines from the code").default(false).optional(),
      showLineNumbers: z.boolean().describe("Show line numbers").default(true).optional(),
      includePatterns: z.string().describe("Include patterns (using glob patterns, comma-separated)").optional(),
      ignorePatterns: z.string().describe("Ignore patterns (using glob patterns, comma-separated)").optional(),
    },
  • Registration of the getRemoteCodebase tool using McpServer.tool(), including name, description, schema, and handler function.
    server.tool(
      "getRemoteCodebase",
      "Retrieve a remote repository's codebase as a single text output using RepoMix",
      {
        repo: z.string().describe("GitHub repository URL or shorthand format (e.g., 'username/repo')"),
        format: z.enum(["xml", "markdown", "plain"]).describe("Output format (xml, markdown, or plain)").default("xml").optional(),
        includeFileSummary: z.boolean().describe("Include summary of each file").default(true).optional(),
        includeDirectoryStructure: z.boolean().describe("Include directory structure").default(true).optional(),
        removeComments: z.boolean().describe("Remove comments from the code").default(false).optional(),
        removeEmptyLines: z.boolean().describe("Remove empty lines from the code").default(false).optional(),
        showLineNumbers: z.boolean().describe("Show line numbers").default(true).optional(),
        includePatterns: z.string().describe("Include patterns (using glob patterns, comma-separated)").optional(),
        ignorePatterns: z.string().describe("Ignore patterns (using glob patterns, comma-separated)").optional(),
      },
      async ({ repo, format, includeFileSummary, includeDirectoryStructure, removeComments, removeEmptyLines, showLineNumbers, includePatterns, ignorePatterns }) => {
        try {
          let command = `npx repomix --remote ${repo} --output stdout`;
          
          // Add formatting options
          if (format) {
            command += ` --style ${format}`;
          }
          
          if (includeFileSummary === true) {
            command += ` --include-file-summary`;
          } else if (includeFileSummary === false) {
            command += ` --no-include-file-summary`;
          }
          
          if (includeDirectoryStructure === true) {
            command += ` --include-directory-structure`;
          } else if (includeDirectoryStructure === false) {
            command += ` --no-include-directory-structure`;
          }
          
          if (removeComments === true) {
            command += ` --remove-comments`;
          } else if (removeComments === false) {
            command += ` --no-remove-comments`;
          }
          
          if (removeEmptyLines === true) {
            command += ` --remove-empty-lines`;
          } else if (removeEmptyLines === false) {
            command += ` --no-remove-empty-lines`;
          }
          
          if (showLineNumbers === true) {
            command += ` --show-line-numbers`;
          } else if (showLineNumbers === false) {
            command += ` --no-show-line-numbers`;
          }
          
          if (includePatterns) {
            command += ` --include "${includePatterns}"`;
          }
          
          if (ignorePatterns) {
            command += ` --ignore "${ignorePatterns}"`;
          }
    
          console.error(`Running command: ${command}`);
          
          // Run Repomix to dump the codebase
          const output = execSync(command, {
            maxBuffer: 1024 * 1024 * 50, // 50MB buffer for large codebases
          }).toString();
    
          return {
            content: [
              {
                type: "text",
                text: output,
              },
            ],
          };
        } catch (error: unknown) {
          console.error("Error running Repomix on remote repository:", error);
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving remote codebase: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
Behavior2/5

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

With no annotations, the description carries full burden but lacks critical behavioral details. It mentions output is 'a single text output' but doesn't disclose size limits, rate limits, authentication needs, error handling, or what 'RepoMix' entails. For a tool with 9 parameters and no annotations, this is insufficient.

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 that front-loads the core purpose without wasted words. Every part earns its place by specifying retrieval, resource, output format, and method.

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?

For a complex tool with 9 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain the return structure, potential errors, or behavioral constraints, leaving significant gaps for the agent to operate effectively.

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 parameters are well-documented in the schema. The description adds no additional parameter semantics beyond implying the tool handles remote repositories via 'repo', which aligns with the schema. Baseline 3 is appropriate as 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 ('Retrieve') and resource ('remote repository's codebase'), specifying it returns 'a single text output using RepoMix'. It distinguishes from sibling 'getCodebase' by emphasizing 'remote' and 'RepoMix', but doesn't explicitly contrast with 'saveCodebase'.

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?

No explicit guidance on when to use this tool versus siblings 'getCodebase' or 'saveCodebase'. The description implies usage for remote repositories but doesn't specify alternatives or exclusions, leaving the agent to infer context.

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/DeDeveloper23/codebase-mcp'

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