MCP Server

Introduction

@rsdoctor/mcp-server is an MCP Server tool designed to help users more conveniently utilize Rsdoctor's build data. It works with Rsdoctor's local build analysis data and helps you quickly obtain build analysis results through a Q&A interface.

Core features

@rsdoctor/mcp-server provides four core analysis capabilities:

  • Bundle Analysis: Analyzes bundle size, composition and other information
  • Dependency Analysis: Analyzes project dependencies and duplicate dependency issues
  • Bundle Optimization Suggestions: Provides suggestions for bundle size optimization and code splitting
  • Compilation Optimization Suggestions: Analyzes compilation time and provides compilation performance optimization suggestions

Usage examples

1. Bundle optimization analysis

By asking "Please help me to optimize the bundle or artifacts", the tool will analyze the build output and provide optimization suggestions.

Example video:

2. Dependency analysis

By asking "Please investigate the referrer dependency of node_modules/dayjs/index.js", the tool will analyze the dependency relationships of the specified module.

Example video:

3. Compilation performance analysis

By asking "Please help me find files or loaders with high compilation time and provide optimization suggestions", the tool will analyze compilation time and provide optimization suggestions.

Example video:

Quick start

💡 Version requirements

WARNING

The following Rsdoctor plugin versions are required:

  • @rsdoctor/rspack-plugin >= 1.1.2
  • @rsdoctor/webpack-plugin >= 1.1.2

Note: Please ensure you are using the latest version for the best experience.

1. Plugin configuration

If you haven't added the Rsdoctor plugin yet, you need to configure it in your project. 👉🏻 Quick Start.

2. Enable Rsdoctor and run local build

Enable Rsdoctor and run the build. Do not use MCP Client to start the project, as Rsdoctor's local service will block the MCP Client's dialogue process.

# Enable Rsdoctor

RSDOCTOR=true npm run build
  • Note: If disableClientServer: true is configured, it needs to be modified to disableClientServer: false, and disableClientServer defaults to false.

3. Start MCP Server

Cursor

  1. Create a .cursor/mcp.json file in the project root directory:
{
  "mcpServers": {
    "rsdoctor": {
      "command": "npx",
      "args": ["-y", "@rsdoctor/mcp-server@latest"]
    }
  }
}
  1. Restart the Cursor editor
  2. Start interaction in the MCP panel

Claude

Add configuration in claude_desktop_config.json:

{
  "mcpServers": {
    "rsdoctor": {
      "command": "npx",
      "args": ["-y", "@rsdoctor/mcp-server@latest"]
    }
  }
}

Cline

Add configuration in the configuration file:

{
  "mcpServers": {
    "rsdoctor": {
      "command": "npx",
      "args": ["-y", "@rsdoctor/mcp-server@latest"]
    }
  }
}

Configuration instructions

Command line parameters

ParameterDescriptionDefaultExample
compilerSpecify the name of the compiler to analyzeAutomatically detected--compiler web
portSpecify the MCP Server portLatest port number (written to ~/.cache/rsdoctor/mcp.json)--port 1000

Multi-compiler project configuration

In a multi-compiler project, each compiler will have a separate Rsdoctor build analysis data. Use the --compiler parameter to specify the compiler to analyze:

npx @rsdoctor/mcp-server@latest --compiler web

Port configuration

  1. Configure the MCP Server port:
npx @rsdoctor/mcp-server@latest --port 1000
  1. Configure the Rsdoctor local service port:
new RsdoctorRspackPlugin({
  port: 9988,
});

Tools list

Product analysis tool

ToolDescriptionParameters
get_chunksGet all code block information-
get_chunk_by_idGet specific code block informationchunkId (Number)
get_large_chunksGet code blocks with large volume-
get_media_asset_promptGet media resource optimization suggestions-

Dependency analysis tool

ToolDescriptionParameters
get_modulesGet all module information-
get_module_by_idGet module informationmoduleId (Number)
get_module_by_pathGet module by pathmodulePath (String)
get_module_issuer_pathGet module source pathmoduleId (String)
get_package_infoGet package information-
get_package_dependenciesGet dependency list-
get_duplicate_packagesGet duplicate package list-
get_similar_packagesGet similar package list-

Performance analysis tool

ToolDescriptionParameters
get_loader_time_all_filesGet file loader time-
get_loader_timesGet compilation directory loader time-
get_rule_infoGet build rule scan results-

Q&A

1. Connection issues

Issue: Unable to connect to Rsdoctor MCP Server or no data returned successfully

Solution:

  • Ensure the Rsdoctor local Server has been successfully started.
    • Manually start the local Server, do not use MCP Client to start the project, as the local service of Rsdoctor will block the dialogue process of MCP Client.
  • If the Rsdoctor MCP server uses the --port parameter, please ensure the Rsdoctor startup port configuration is correct.
  • Check if the Rsdoctor plugin version meets the requirements. Version requirements