Skip to main content
Glama
code-alchemist01

Development Tools MCP Server

find_duplicate_code

Identifies duplicate code blocks across multiple files to help developers maintain clean codebases and reduce redundancy.

Instructions

Find duplicate code blocks across files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to analyze
minLinesNoMinimum lines for duplication detection

Implementation Reference

  • Handler function for the 'find_duplicate_code' tool. Reads input files, prepares options, calls CodeAnalyzer.analyzeCodeQuality, and returns the duplications from metrics.
    case 'find_duplicate_code': {
      const files = params.files as string[];
      const codeFiles = await FileReader.readFiles(files.join(','));
      const options: CodeAnalysisOptions = {
        checkDuplicates: true,
        minLinesForDuplication: params.minLines as number,
      };
      const metrics = await codeAnalyzer.analyzeCodeQuality(codeFiles, options);
      return metrics.duplications;
    }
  • Tool definition including name, description, and input schema for 'find_duplicate_code'.
    {
      name: 'find_duplicate_code',
      description: 'Find duplicate code blocks across files',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            items: { type: 'string' },
            description: 'File paths to analyze',
          },
          minLines: {
            type: 'number',
            description: 'Minimum lines for duplication detection',
            default: 5,
          },
        },
        required: ['files'],
      },
    },
  • src/server.ts:18-25 (registration)
    Registration of codeQualityTools (which includes 'find_duplicate_code') into the allTools array used by the MCP server.
    const allTools = [
      ...codeAnalysisTools,
      ...codeQualityTools,
      ...dependencyAnalysisTools,
      ...lintingTools,
      ...webScrapingTools,
      ...apiDiscoveryTools,
    ];
  • src/server.ts:64-65 (registration)
    Dispatch logic in MCP server that routes calls to 'find_duplicate_code' (in codeQualityTools) to the handleCodeQualityTool function.
    } else if (codeQualityTools.some((t) => t.name === name)) {
      result = await handleCodeQualityTool(name, args || {});
  • Core helper method that implements duplicate code detection by pairwise file similarity comparison above 70% threshold.
    private async findDuplications(
      files: CodeFile[],
      options?: CodeAnalysisOptions
    ): Promise<import('../types/index.js').Duplication[]> {
      // This is a simplified version. In production, we'd use jscpd library
      const duplications: import('../types/index.js').Duplication[] = [];
      const minLines = options?.minLinesForDuplication || 5;
    
      for (let i = 0; i < files.length; i++) {
        for (let j = i + 1; j < files.length; j++) {
          const similarity = this.calculateSimilarity(files[i].content, files[j].content);
          if (similarity > 0.7 && files[i].lines >= minLines) {
            duplications.push({
              lines: files[i].lines,
              tokens: 0,
              firstFile: files[i].path,
              secondFile: files[j].path,
              startLine1: 1,
              endLine1: files[i].lines,
              startLine2: 1,
              endLine2: files[j].lines,
            });
          }
        }
      }
    
      return duplications;
    }
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 states what the tool does but lacks details on how it behaves: e.g., whether it's read-only or has side effects, performance characteristics, output format, or error handling. This is a significant gap for a tool with no annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every part contributing essential information.

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 code analysis, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a list of duplicates, locations, or metrics), behavioral traits, or how it integrates with sibling tools, leaving gaps for effective agent 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?

The schema description coverage is 100%, so the schema already documents both parameters ('files' and 'minLines') with descriptions and defaults. The tool description adds no additional parameter semantics beyond what's in the schema, meeting the baseline score of 3 for high schema coverage.

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 with a specific verb ('find') and resource ('duplicate code blocks across files'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'detect_code_smells' or 'analyze_code_quality', which might also involve code analysis but for different purposes.

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. With many sibling tools for code analysis (e.g., 'detect_code_smells', 'analyze_code_quality'), there's no indication of specific contexts, prerequisites, or exclusions for this tool's application.

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/code-alchemist01/development-tools-mcp-Server'

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