MCP Reloader

MCP Reloader

A hot-reload development tool that enables real-time development of MCP (Model Context Protocol) servers by automatically reloading tools as they're modified without requiring manual restarts.

Category
访问服务器

README

MCP Reloader

A hot-reload development tool for building MCP (Model Context Protocol) servers with Claude Code. This tool enables Claude Code to dynamically reload MCP tools as they are modified, making it perfect for iterative development where Claude Code can write and test MCP tools in real-time.

Overview

MCP Reloader is specifically designed for developers using Claude Code to build MCP tools. It solves the common development pain point where MCP clients need to be restarted whenever server tools are modified. By implementing file watching and the tools/list_changed notification, Claude Code can modify tools and immediately test them without manual restarts.

Key Features for Claude Code Development

  • Real-time Tool Development: Claude Code can write, modify, and test MCP tools without restarts
  • Dynamic Tool Loading: Automatically loads JavaScript tools from tools/ directory
  • Instant Feedback Loop: Changes are reflected immediately in the MCP client
  • File Watching: Uses chokidar to detect file changes in real-time
  • Process Wrapping: Wrap any LSP/MCP process with hot-reload capabilities
  • Auto-restart on Config Changes: Watch configuration files and restart when needed

Quick Start with Claude Code

1. Create a new MCP project

mkdir my-mcp-tools
cd my-mcp-tools
mkdir tools

2. Configure Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "my-tools": {
      "command": "npx",
      "args": ["mcp-reloader"],
      "cwd": "/path/to/my-mcp-tools"
    }
  }
}

3. Ask Claude Code to create tools

Now Claude Code can create and modify tools in the tools/ directory, and they will be automatically available without restarting Claude Desktop!

Example: Claude Code Creating Tools

Here's how Claude Code can create a tool that will be immediately available:

// tools/search-files.js
export default {
  name: "search_files",
  description: "Search for files matching a pattern",
  inputSchema: {
    type: "object",
    properties: {
      pattern: {
        type: "string",
        description: "Glob pattern to search for files"
      },
      directory: {
        type: "string",
        description: "Directory to search in",
        default: "."
      }
    },
    required: ["pattern"]
  },
  handler: async ({ pattern, directory = "." }) => {
    const { glob } = await import('glob');
    const files = await glob(pattern, { cwd: directory });
    return `Found ${files.length} files:\n${files.join('\n')}`;
  }
};

Claude Code can create this file, and it will be immediately available to use!

Installation

# Global installation
npm install -g mcp-reloader

# Or use directly with npx (recommended)
npx mcp-reloader --help

Usage

Basic Server Start

# Start default MCP server with hot-reload
npx mcp-reloader

# Or if installed globally
mcp-reloader

Using Include Patterns

Watch additional files and restart the process when they change:

# Watch configuration files
npx mcp-reloader --include "config/**/*.json" --include "src/lib/**/*.js"

# Or use environment variable
MCP_HOT_RELOAD_INCLUDE='config/**/*.json,src/lib/**/*.js' npx mcp-reloader

Wrapping Custom LSP Servers

Wrap any LSP server with hot-reload capabilities:

# Wrap a Python LSP server
npx mcp-reloader --include "**/*.yaml" -- python my-lsp-server.py --port 3000

# Wrap a Node.js server with complex arguments
npx mcp-reloader --include "**/*.ts" -- node --experimental-specifier-resolution=node ./dist/server.js --config ./config.json

# Legacy cmd: format (still supported)
npx mcp-reloader cmd:python server.py --port 3000

Example: Wrapping Existing MCP Server

Here's how to add hot-reload to any MCP server. This example wraps a simple echo server:

{
  "mcpServers": {
    "echo-with-reload": {
      "command": "npx",
      "args": [
        "mcp-reloader",
        "--include", "examples/echo-server/config.json",
        "--",
        "node",
        "examples/echo-server/server.js"
      ]
    }
  }
}

When config.json changes, the entire echo server restarts automatically.

Command Line Arguments

--include patterns

Specify glob patterns for files to watch. When matched files change, the entire process restarts.

# Single pattern
npx mcp-reloader --include "config.json"

# Multiple patterns
npx mcp-reloader --include "**/*.yaml" --include "lib/**/*.js"

-- separator

Everything after -- is treated as the command and its arguments. This makes it easy to pass complex arguments without escaping.

# Simple command
npx mcp-reloader -- python server.py --port 3000

# Complex Node.js arguments
npx mcp-reloader --include "**/*.ts" -- node --experimental-specifier-resolution=node ./dist/server.js --config ./config.json

# Arguments with spaces and special characters
npx mcp-reloader -- python script.py --message "Hello World!" --path "/path with spaces/"

How It Works

Two-Level Reload Strategy

  1. Tool Files (tools/*.js): Hot-reloaded without process restart

    • File changes are detected by chokidar
    • Tools are dynamically imported with cache busting
    • tools/list_changed notification sent to clients
    • MCP clients can immediately use updated tools
  2. Include Pattern Files: Full process restart

    • Wrapper process monitors specified glob patterns
    • On change, the entire server process is restarted
    • Useful for configuration files or core dependencies

Architecture

┌─────────────┐     ┌─────────────┐     ┌──────────────┐
│ MCP Client  │────▶│   Wrapper   │────▶│  MCP Server  │
└─────────────┘     └─────────────┘     └──────────────┘
                           │                      │
                           ▼                      ▼
                    File Watching           Tool Loading
                    (--include)            (tools/*.js)

Expected Behavior

Initial Startup

  • Server loads all tools from tools/
  • Initial tools are immediately available
  • Client receives the tool list

Adding a Tool

  • Create new file (e.g., tools/hello.js)
  • Server detects the new file
  • Tool is automatically loaded
  • tools/list_changed notification sent
  • Tool immediately available in client

Modifying a Tool

  • Edit existing file (e.g., tools/echo.js)
  • Server detects the change
  • Tool is reloaded with new implementation
  • tools/list_changed notification sent
  • Updated behavior immediately available

Deleting a Tool

  • Remove file (e.g., tools/time.js)
  • Server detects the deletion
  • Tool is removed from available tools
  • tools/list_changed notification sent
  • Tool no longer callable

Include Pattern Changes

  • Modify watched file (e.g., config.json)
  • Wrapper detects the change
  • Entire server process restarts
  • All tools are reloaded with new configuration

Local Development

For developing mcp-reloader itself:

# Clone and install
git clone https://github.com/mizchi/mcp-reloader.git
cd mcp-reloader
npm install

# Build TypeScript
npm run build

# Run tests
npm test

# Run development server
npm run dev

# Test hot-reload functionality
./test-include.sh

Comparison with Similar Tools

Tool Use Case State Preservation MCP Integration
mcp-reloader MCP/LSP servers Two-level strategy Native support
nodemon General purpose No (full restart) Manual setup
tsx watch TypeScript only No (full restart) No
Bun --hot Bun runtime Yes No

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Acknowledgments

This project implements the Model Context Protocol specification for tool hot-reloading, specifically designed to enhance the Claude Code development experience.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选