API

MCP Server

Use jscpd-server as a Model Context Protocol (MCP) server for AI assistants.

Overview

jscpd-server implements the Model Context Protocol (MCP), allowing AI assistants like Claude Desktop to interact with the duplication detection capabilities directly.

Capabilities

The MCP server provides the following tools:

check_duplication

Checks a provided code snippet for duplications against the codebase currently being served by jscpd-server.

Arguments:

  • code (string, required): The source code snippet to analyze.
  • format (string, required): The format of the code (e.g., "javascript", "typescript").
  • recheck (boolean, optional): If true, triggers a re-scan of the current directory before checking the snippet.

get_statistics

Retrieves the overall project duplication statistics.

Arguments: None

check_current_directory

Triggers a re-scan of the current working directory for duplications and returns the updated statistics.

Arguments: None

Usage with Claude Desktop

To use jscpd-server with Claude Desktop, add the following configuration to your claude_desktop_config.json:

{
  "mcpServers": {
    "jscpd": {
      "type": "streamable-http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

Ensure jscpd-server is running (e.g., npx jscpd-server . --port 3000) before starting Claude Desktop.

Replace http://localhost:3000 with the actual URL where your server is running.

Resources

The server exposes the following resources:

  • jscpd://statistics: Returns the current duplication statistics in JSON format.