MCP Bun Server

MCP Bun Server

Provides AI assistants with powerful tools to execute, optimize, and manage JavaScript/TypeScript projects using the Bun runtime.

Category
访问服务器

README

MCP Bun Server

Bun Version Node.js Version NPM Version

A comprehensive Model Context Protocol (MCP) server implementation optimized for the Bun JavaScript runtime. This server provides AI assistants with powerful tools to execute, optimize, and manage JavaScript/TypeScript projects using Bun's high-performance runtime.

🔄 Runtime Compatibility: The server requires bun to be installed in the environment the MCP server will run (Windows native, Windows WSL2, etc). See more installation details below.

sample usage

Features

🚀 Bun-Optimized Execution

  • Fast Script Execution: Run JavaScript/TypeScript files with Bun's optimized runtime
  • Built-in TypeScript Support: Execute TypeScript directly without compilation
  • Memory Optimization: Use --smol flag for memory-constrained environments
  • Hot Reloading: Development server with --hot flag support

🔧 Development Tools

  • Package Management: Install dependencies with bun install
  • Script Runner: Execute package.json scripts with bun run
  • Build System: Optimize projects with bun build including minification and bundling
  • Test Runner: Fast testing with bun test and coverage reporting

📊 Performance Analytics

  • Project Analysis: Analyze bundle sizes, dependencies, and runtime performance
  • Benchmarking: Compare script performance with different optimization flags
  • Optimization Suggestions: Get recommendations for Bun-specific optimizations

🖥️ Server Management

  • Background Servers: Start and manage long-running Bun/Node.js servers
  • Process Monitoring: Track server status, logs, and performance
  • Hot Reloading Servers: Development servers with file watching capabilities

🔍 Resource Discovery

  • Script Listing: Browse available npm/package.json scripts
  • Project Structure: Understand project dependencies and configuration

Quick Start

Prerequisites

  • Bun v1.0.0 or later (recommended)
  • Node.js v18.0.0 or later (for compatibility)

For MacOS/Linux users, install Bun using the instructions on the Bun website.

For Windows, the installation depends if you develope with WSL2 or not:

Configuration

On VSCode MCP Client

For quick installation, use one of the one-click install buttons below...

Install with UV in VS Code Install with UV in VS Code Insiders

Or use the configs below.

If using globally, add the following to your MCP client configuration on settings.json:

{
  ...
  "mcp": {
    "servers": {
      "bun": {
        "command": "bunx",
        "args": ["-y", "mcp-bun@latest"],
        "env": {
          "DISABLE_NOTIFICATIONS": "true"
        }
      }
    }
  }
}

On Windows, this doesn't work properly when using WSL2 if your project lives in the WSL2 filesystem and you run VSCode natively on Windows. This happens because the MCP server runs on Windows and the Bun commands are executed in the WSL2 environment, which can lead to path issues.

In this case, configure the MCP server in the project workspace configuration file which makes the MCP server run in the WSL2 environment and execute the Bun commands there.

Create a file named .vscode/mcp.json in your project root with the following content:

{
  "servers": {
    "bun": {
      "command": "bunx",
      "args": ["-y", "mcp-bun@latest"],
      "env": {
        "DISABLE_NOTIFICATIONS": "true"
      }
    }

On Claude Desktop

Configure your Claude Desktop MCP client with the following:

{
  "mcpServers": {
    "bun": {
      "command": "bunx",
      "args": ["-y", "mcp-bun@latest"],
      "env": {
        "DISABLE_NOTIFICATIONS": "true",  // Optional: disable permission prompts
      }
    }
  }
}

For Development/Local Installation

Clone the repository to your local machine, install dependencies, and build the project:

git clone https://github.com/carlosedp/mcp-bun.git
cd mcp-bun
bun install
bun run build

Then configure your MCP client to use the local build:

{
  "servers": {
    "bun-dev": {
      "command": "bun",
      "args": ["/home/user/mcp-bun/dist/mcp-bun.js"],
      "env": {
        "DISABLE_NOTIFICATIONS": "true"
      }
    },
  }
}

For testing there's also the MCP Inspector available, which allows you to run the server with Bun and inspect the commands being executed:

bun run dev

Available Tools

Core Execution Tools

run-bun-script-file

Execute JavaScript/TypeScript files with Bun runtime optimizations.

Parameters:

  • scriptPath: Path to the script file
  • bunArgs: Optional Bun flags (e.g., --smol, --hot)
  • args: Arguments to pass to the script
  • stdin: Optional standard input
  • cwd: Working directory
  • timeout: Execution timeout

run-bun-eval

Execute JavaScript/TypeScript code directly with Bun eval.

Parameters:

  • code: Code to execute
  • evalDirectory: Execution directory
  • bunArgs: Bun optimization flags
  • stdin: Standard input
  • timeout: Execution timeout

Package Management

run-bun-install

Install dependencies using Bun's fast package manager.

Parameters:

  • packageDir: Directory containing package.json
  • dependency: Specific package to install (optional)

run-bun-script

Execute npm scripts using Bun.

Parameters:

  • packageDir: Directory containing package.json
  • scriptName: Script name to run
  • args: Additional arguments

Build & Optimization

run-bun-build

Build and optimize projects with Bun's bundler.

Parameters:

  • entryPoint: Entry file to build
  • outDir: Output directory
  • target: Build target (browser, bun, node)
  • minify: Enable minification
  • sourcemap: Generate source maps
  • splitting: Enable code splitting

run-bun-test

Execute tests with Bun's fast test runner.

Parameters:

  • testPath: Test file or directory
  • coverage: Enable code coverage
  • watch: Enable watch mode
  • bail: Stop after N failures
  • timeout: Test timeout

Performance Analysis

analyze-bun-performance

Comprehensive project performance analysis.

Parameters:

  • projectDir: Project directory
  • entryPoint: Entry point to analyze
  • options: Analysis options (bundle, dependencies, runtime)

benchmark-bun-script

Benchmark script performance with different optimization flags.

Parameters:

  • scriptPath: Script to benchmark
  • iterations: Number of test runs
  • warmup: Warmup runs

Server Management

start-bun-server

Start optimized Bun servers with hot reloading and watch capabilities.

Parameters:

  • scriptPath: Server script path
  • cwd: Working directory
  • bunArgs: Bun flags
  • optimizations: Hot reload, watch, smol mode options

Additional Server Tools

  • start-node-server: Start Node.js servers for compatibility
  • list-servers: List all running servers with status and logs
  • stop-server: Stop running servers gracefully or forcefully
  • get-server-logs: Retrieve server logs with filtering options

Version Management

get-bun-version

Get current Bun version and revision information.

list-bun-versions

List available Bun installations.

select-bun-version

Select specific Bun version for execution.

Performance Optimization Tips

Memory Optimization

Use the --smol flag for memory-constrained environments:

bun --smol your-script.js

Security Considerations

  • The server prompts for permission before executing any command
  • Scripts run with the same permissions as the MCP server process
  • Use environment variable DISABLE_NOTIFICATIONS=true for automation
  • Be cautious when running scripts from untrusted sources

Development

Building

bun run build        # Build with Bun
bun run build:node   # Build with Node.js/TypeScript

Development Mode

bun run dev          # Run with Bun + MCP Inspector
bun run dev:node     # Run with Node.js + MCP Inspector

Linting

bun run lint         # Check for issues
bun run lint:fix     # Fix auto-fixable issues

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选