MCP HubMCP Hub
situ2001

unplugin-mcp

by: situ2001

A unified MCP (Model Context Protocol) server plugin for any JavaScript build tools.

28created 11/03/2025
Visit
JavaScript
plugin

📌Overview

Purpose: To provide a unified MCP (Model Context Protocol) plugin that creates and manages an MCP Server, enabling enhanced AI capabilities for development environments.

Overview: unplugin-mcp is a versatile plugin designed to work with multiple JavaScript build tools like Rollup, Vite, and Webpack. It facilitates improved AI interactions with the codebase and build processes, offering a standardized server and set of tools for better collaboration and efficiency.

Key Features:

  • Cross-Platform MCP Integration: Establishes a seamless MCP server across diverse build tools, enhancing flexibility.

  • Bi-directional AI Integration: Empowers AI to understand and modify codebases actively, facilitating dynamic development aid.

  • Rich built-in tools: Includes tools for analyzing dependencies, inspecting configurations, and debugging errors, streamlining the development workflow.

  • Extensible Tool Framework: Allows users to create custom tools through a straightforward interface, enabling tailored project-specific functionality.

  • Build Process Integration: Integrates smoothly into the plugin chains of various build tools, enhancing its utility and responsiveness to changes.

  • Persistent Server: Maintains server operation even after builds are complete in watch mode, ensuring continuous availability for AI interactions.

  • Standard Transport Layer: Leverages HTTP and Server-Sent Events (SSE), ensuring compatibility with a range of AI assistants implementing the MCP protocol.


unplugin-mcp

Important: This is a work in progress. Not ready for production use yet. If you are interested in helping, feel free to open an issue or PR.

A unified MCP (Model Context Protocol) plugin that creates and manages an MCP Server and provides MCP tools for better interaction with your codebase and build tools. It supports multiple JavaScript build tools, including Rollup, Vite, and Webpack.

Features

  • Cross-Platform MCP Integration: Seamlessly manages an MCP server across various build tools.
  • Bi-directional AI Integration: Provides context to AI about your codebase and allows AI to modify the build process.
  • Rich built-in tools: Tools for analyzing module dependencies, inspecting build configurations, and debugging errors.
  • Extensible Tool Framework: Create custom MCP tools using the UnpluginMcpTool interface.
  • Build Process Integration: Integrates with build tool plugin chains.
  • Persistent Server: Continues running in watch mode for ongoing AI interactions.
  • Standard Transport Layer: Uses HTTP and Server-Sent Events (SSE) for compatibility with AI assistants.

Installation

# Install the plugin
pnpm add -D unplugin-mcp

Usage

Build Tool Integration

Example configuration for Rollup:

// rollup.config.js
import { defineConfig } from 'rollup';
import { rollupPlugin as mcp } from 'unplugin-mcp';
import { ModuleTool, BuildConfigTool, BuildErrorTool } from 'unplugin-mcp/tools';

export default defineConfig({
  plugins: [
    mcp({
      provideUnpluginMcpTools: () => [
        new ModuleTool(),
        new BuildConfigTool(),
        new BuildErrorTool()
      ]
    }),
  ]
});

Options

Refer to McpPluginOptions in the types file for all available options.

Built-in Tools Compatibility

ToolDescriptionRollupWebpack
ModuleToolAnalyze module dependencies and imports
BuildConfigToolInspect build configuration
BuildErrorToolDebug build errors

Custom Tools

Extend the plugin with custom tools that implement the UnpluginMcpTool interface:

import { InputOptions } from "rollup";
import { UnpluginMcpTool, UnpluginMcpToolSetupOptions } from "unplugin-mcp";
import DeferredCtor, { Deferred } from 'promise-deferred';

export class BuildConfigTool implements UnpluginMcpTool {
  private buildConfig: Deferred<InputOptions>;

  constructor() {
    this.buildConfig = new DeferredCtor<InputOptions>();
  }

  setupMcpServer(mcpServer: any) {
    mcpServer.tool(`get-build-config`, "Get build configuration", {}, async () => {
      const cfg = await this.buildConfig.promise;
      return { content: [{ type: 'text', text: `Build configuration: ${JSON.stringify(cfg)}` }] };
    });
    return mcpServer;
  }

  registerPlugins(): UnpluginOptions {
    return {
      name: 'build-config-tool',
      rollup: {
        options(config) {
          this.buildConfig.resolve(config);
        }
      }
    }
  }
}

Examples

Refer to the examples directory for practical applications, including:

  • simple-hello: A basic example demonstrating MCP integration with Rollup

How it works

  1. Initializes a singleton MCP server instance.
  2. Registers UnpluginMcpTool instances with the MCP server.
  3. Creates an HTTP server for the MCP server.
  4. Starts the HTTP server, listening on the specified port and host.
  5. Registers hooks created by UnpluginMcpTool instances to relevant build tools.

License

MIT License. Copyright (c) 2025 situ2001.