Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

rsbuild-plugin-mcp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsbuild-plugin-mcp

Rsbuild plugin that enables a MCP server for your Rsbuild app to provide information about your setup and modules graphs.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

rsbuild-plugin-mcp

Rsbuild plugin that enables a MCP server for your Rsbuild app to provide information about your setup and modules graphs.

npm version license downloads

Usage

Install:

npm add rsbuild-plugin-mcp -D

Add plugin to your rsbuild.config.ts:

import { defineConfig } from '@rsbuild/core';
import { pluginMCP } from 'rsbuild-plugin-mcp';

export default defineConfig({
  plugins: [pluginMCP()],
});

Options

mcpRouteRoot

  • Type: string | undefined
  • Default: /__mcp

Customize the routes of the MCP server.

  • Example:
import { defineConfig } from '@rsbuild/core';
import { pluginMCP } from 'rsbuild-plugin-mcp';

export default defineConfig({
  plugins: [
    pluginMCP({
      mcpRouteRoot: '/api/__mcp',
    }),
  ],
});

Customize the MCP server

The MCP server can be extended with the following ways:

With plugin options

Use the mcpServerSetup to customize the MCP server.

import { defineConfig } from '@rsbuild/core';
import { pluginMCP } from 'rsbuild-plugin-mcp';

export default defineConfig({
  plugins: [
    pluginMCP({
      mcpServerSetup(mcpServer) {
        // Register tools, resources and prompts
        mcpServer.tool(); /** args */
        mcpServer.resource(); /** args */
        mcpServer.prompt(); /** args */
      },
    }),
  ],
});

You may also return a new McpServer instance to replace the default one:

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { defineConfig } from '@rsbuild/core';
import { pluginMCP } from 'rsbuild-plugin-mcp';

export default defineConfig({
  plugins: [
    pluginMCP({
      mcpServerSetup() {
        // Create a new `McpServer` and return
        const mcpServer = new McpServer();
        // Register tools, resources and prompts
        mcpServer.tool();
        return mcpServer;
      },
    }),
  ],
});

With other plugins

This plugin exposes the McpServer instance using api.expose.

You may use api.useExposed to get the instance and make customization:

import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import type { RsbuildPlugin } from '@rsbuild/core'

export function pluginFoo(): RsbuildPlugin {
  return {
    name: 'plugin-foo',
    pre: ['plugin-mcp'],
    setup(api) {
      if (api.isPluginExists('plugin-mcp')) {
        const mcpServer = api.useExposed<McpServer>('rsbuild-plugin-mcp:mcpServer')!
        // Register tools, resources and prompts
        mcpServer.tool(/** args */)
        mcpServer.resource(/** args */)
        mcpServer.prompt(/** args */)
      }
    },
  },
}

Credits

This plugin is inspired by vite-plugin-mcp. Both the implementation and documentation have been adapted and referenced from the original Vite plugin.

License

MIT.

FAQs

Package last updated on 10 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts