@rsdoctor/mcp-server

@rsdoctor/mcp-server 是一个 MCP Server,旨在帮助用户更便捷地使用 Rsdoctor 的构建数据。它可以与 Rsdoctor 的本地构建分析数据配合使用,通过问答的形式,帮助你快速获取构建分析结果。

  • Types
  • ESM
License
MIT
Deps
0
Install Size
1.2 MB
Vulns
0
Published

Get started

$npm install @rsdoctor/mcp-server
$pnpm add @rsdoctor/mcp-server
$yarn add @rsdoctor/mcp-server
$bun add @rsdoctor/mcp-server
$deno add npm:@rsdoctor/mcp-server
$vlt install @rsdoctor/mcp-server
$vp add @rsdoctor/mcp-server
# Run locally
$npx rsdoctor-mcp
$pnpm exec rsdoctor-mcp
$npx rsdoctor-mcp
$bunx rsdoctor-mcp
$deno run npm:@rsdoctor/mcp-server
$vlx rsdoctor-mcp
$vp exec rsdoctor-mcp

Weekly DownloadsAcross all versions

Versions

View all versions
0.1.3
latest

Readme

@rsdoctor/mcp-server

English | 简体中文

Introduction

@rsdoctor/mcp-server is an MCP Server 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.

Features

Currently supports four main types of analysis capabilities:

  • Build Artifact Analysis: Analyzes the size and composition of build artifacts
  • Dependency Analysis: Analyzes project dependencies and duplicate dependency issues
  • Bundle Optimization Suggestions: Provides suggestions for bundle size optimization and code splitting
  • Build Performance Suggestions: Analyzes build time and provides build performance optimization suggestions

Examples

1. Bundle Optimization Analysis

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

Example video:

https://github.com/user-attachments/assets/c73e55a9-445d-481d-8dbd-cf99bfca680f

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:

https://github.com/user-attachments/assets/312cf5ce-19bd-49e7-87bb-aab1fc8a6a43

3. Build Performance Analysis

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

Example video:

https://github.com/user-attachments/assets/cc0f5441-4950-420c-bbad-635e21e87492

Configuration

Parameters
compiler
  • Configure the name of the linked bundler (optional)

For multi-compiler projects, since each compiler will have its own Rsdoctor build analysis data, you need to configure the compiler parameter to specify which bundler's Rsdoctor data the mcp-server should analyze. Rsdoctor-mcp do not currently support analyzing multiple Rsdoctor data sets simultaneously.

npx @rsdoctor/mcp-server@latest --compiler [compilerName]
port
  • Configure the port (optional)
npx -y @rsdoctor/mcp-server@latest --port 9988

Note: By default, the Rsdoctor local server starts on a random port. Therefore, if you want to use the port parameter, you need to configure the port in the plugin:

new RsdoctorRspackPlugin({
  port: 9988,
});

Usage

Version Requirements

The following Rsdoctor plugins are required (version requirements):

  • @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'll need to configure it in your project, 👉🏻 Quick Start.

2. Enable Rsdoctor and Run Local Build

With Rsdoctor enabled, execute the build process. Do not use the MCP Client to start the project, as Rsdoctor's local server will block the MCP Client's conversation process.

npm run build
  • Note: If you have set disableClientServer: true, change it to disableClientServer: false. By default, disableClientServer is set to false.
3. Configure MCP Client
Claude

Add the following configuration to claude_desktop_config.json:

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

Once connected, you can interact directly with Rsdoctor's build analysis data in the MCP panel of Cursor, asking questions about artifacts, dependencies, optimizations, and more.

Cursor

Install MCP Server

To integrate @rsdoctor/mcp-server in the Cursor editor, usually you only need to add the server configuration in the .cursor/mcp.json file.

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

Once connected, you can interact directly with Rsdoctor's build analysis data in the MCP panel of Cursor, asking questions about artifacts, dependencies, optimizations, and more.

VS Code / GitHub Copilot

Install in VS Code

  1. Create .vscode/mcp.json in your project root directory. GitHub Copilot will automatically load the MCP Server configuration.
{
  "mcpServers": {
    "rsdoctor": {
      "command": "npx",
      "args": ["-y", "@rsdoctor/mcp-server@latest"]
    }
  }
}
  1. In the Copilot Chat view, select Agent mode, then start interacting.
Cline

Add the MCP Server configuration in the Cline configuration file.

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

Once connected, you can interact directly with Rsdoctor's build analysis data in the MCP panel of Cursor, asking questions about artifacts, dependencies, optimizations, and more.

Tools List

  1. get_chunks
  • Retrieve information about all code chunks
  1. get_chunk_by_id
  • Retrieve information about a specific chunk by ID
  • Input: chunkId (Number)
  1. get_modules
  • Retrieve information about all modules
  1. get_module_by_id
  • Retrieve information about a module by ID
  • Input: moduleId (Number)
  1. get_module_by_path
  • Retrieve information about a module by path
  • Input: modulePath (string)
  1. get_module_issuer_path
  • Retrieve the issuer path of a module
  • Input: moduleId (string)
  1. get_package_info
  • Retrieve information about the current package
  1. get_package_dependencies
  • Retrieve the list of package dependencies
  1. get_rule_info
  • Retrieve build rule scan results
  1. get_duplicate_packages
  • Retrieve the list of duplicate packages
  1. get_similar_packages
  • Retrieve the list of similar packages
  1. get_large_chunks
  • Retrieve the list of oversized code chunks
  1. get_media_asset_prompt
  • Retrieve media asset optimization suggestions
  1. get_loader_time_all_files
  • Retrieve loader time for each file
  1. get_loader_times
  • Retrieve loader times for compiled directories