MCP Rewatch

MCP Rewatch

A Model Context Protocol server that enables AI coding assistants like Claude Code to manage long-running development processes, solving the problem where Claude Code cannot see output from processes like 'npm run dev' that don't exit immediately.

Category
访问服务器

README

MCP Rewatch

A Model Context Protocol (MCP) server that enables AI coding assistants like Claude Code to manage long-running development processes. Without this tool, Claude Code cannot run commands like npm run dev because it will block waiting for the process to complete and eventually timeout without seeing any output.

The Problem

When using Claude Code for development, you hit a fundamental limitation:

# What happens when Claude Code tries to run a dev server:
$ npm run dev

> my-app@1.0.0 dev
> next dev

▲ Next.js 14.0.0
- Local: http://localhost:3000

[Claude Code is now stuck here, waiting for the process to exit]
[After ~2 minutes, it times out without seeing any output]
[Claude Code never sees compilation errors, success messages, or any logs]

Claude Code cannot:

  • ❌ See any output from long-running processes
  • ❌ Know if a dev server started successfully
  • ❌ Check for compilation errors
  • ❌ Restart servers after making changes
  • ❌ Run multiple dev processes simultaneously

This makes it nearly impossible to develop effectively with Claude Code, as you need to manually run all dev servers and restart them after changes.

The Solution

MCP Rewatch acts as a bridge between Claude Code and your development processes:

  • Runs processes in the background - Claude Code doesn't block
  • Captures all output - stdout/stderr saved in memory buffers
  • Provides async access - Claude Code can check logs anytime
  • Enables restarts - Claude Code can restart servers after making changes
  • Manages multiple processes - Run frontend, backend, database servers together

How It Works

MCP Rewatch acts as an intermediary between Claude Code and your development processes:

  1. Runs as a separate service that Claude Code can communicate with via MCP
  2. Manages processes independently - starts your dev servers as child processes
  3. Non-blocking operations - Claude Code can start/restart processes and immediately continue
  4. Async log retrieval - Claude Code can check logs later without blocking
  5. Handles lifecycle properly - graceful shutdown, no orphaned processes

This architecture allows Claude Code to effectively manage long-running processes despite its inherent limitation of not being able to run them directly.

Installation

Install globally via npm:

npm install -g mcp-rewatch

Or use directly with npx (no installation needed):

npx mcp-rewatch

Configuration

Create a rewatch.config.json file in your project root (where you'll be running Claude Code):

The startupDelay should be tuned based on your specific processes:

  • Fast tools (scripts, small servers): 1000-2000ms
  • Next.js/React dev servers: 3000-5000ms
  • Heavy build processes: 5000-10000ms
  • Services with dependencies: 8000-15000ms
{
  "processes": {
    "convex": {
      "command": "pnpm",
      "args": ["dlx", "convex", "dev"],
      "cwd": "./",
      "startupDelay": 5000
    },
    "nextjs": {
      "command": "pnpm",
      "args": ["dev"],
      "cwd": "./",
      "env": {
        "PORT": "3000"
      },
      "startupDelay": 4000 
    },
    "backend": {
      "command": "npm",
      "args": ["run", "dev"],
      "cwd": "./backend",
      "env": {
        "NODE_ENV": "development",
        "PORT": "8080"
      },
      "startupDelay": 2000
    }
  }
}

Configuration Options

  • command: The executable to run (e.g., npm, pnpm, node)
  • args: Array of command arguments
  • cwd: Working directory for the process (relative to where MCP server runs, i.e., your project root)
  • env: Additional environment variables (optional)
  • startupDelay: Time in milliseconds to wait after starting before checking status (default: 3000)
  • readyPattern: (Not implemented yet - see roadmap)

Usage with Claude Code

Quick Start (Single Project)

  1. Add MCP Rewatch to Claude Code:
# Using npx (no installation needed)
claude mcp add rewatch npx -- mcp-rewatch

# Or if installed globally
claude mcp add rewatch mcp-rewatch

# Or for local development
claude mcp add rewatch node -- /path/to/mcp-rewatch/dist/index.js
  1. Create rewatch.config.json in your project root

  2. Start Claude Code from your project directory - MCP Rewatch will look for the config in the current working directory

User-Scoped Setup (Global Access)

To make MCP Rewatch available in all Claude Code sessions:

claude mcp add -s user rewatch npx -- mcp-rewatch

Important: The server looks for rewatch.config.json in the current working directory where Claude Code is running. Each project needs its own config file.

Managing Multiple Projects

How it works: MCP Rewatch looks for rewatch.config.json in the current working directory where Claude Code is running.

Best practices:

  1. Keep configs project-specific: Each project should have its own rewatch.config.json
  2. Use relative paths: In your config, use relative cwd paths like "./backend" or "./frontend"
  3. Launch Claude Code from project root: Always start Claude Code from your project directory

Example multi-service config:

{
  "processes": {
    "frontend": {
      "command": "npm",
      "args": ["run", "dev"],
      "cwd": "./frontend"
    },
    "backend": {
      "command": "npm",
      "args": ["run", "dev"],
      "cwd": "./backend"
    },
    "database": {
      "command": "docker",
      "args": ["compose", "up", "postgres"],
      "cwd": "./"
    }
  }
}

Available Tools

Once configured, Claude Code can use these tools:

restart_process

Stop and restart a development process by name. Waits for the configured startupDelay (or 3 seconds by default), then returns initial logs.

await restart_process({ name: "nextjs" })
// Output:
// Process 'nextjs' started successfully
//
// Initial logs:
// [2024-01-07T10:00:01.123Z] [stdout] > my-app@1.0.0 dev
// [2024-01-07T10:00:01.456Z] [stdout] > next dev
// [2024-01-07T10:00:02.789Z] [stdout] ▲ Next.js 14.0.0
// [2024-01-07T10:00:03.012Z] [stdout] - Local: http://localhost:3000

get_process_logs

Retrieve logs from a process, optionally limiting the number of lines.

await get_process_logs({ name: "nextjs", lines: 50 })
// Returns last 50 lines of logs from the Next.js process

await get_process_logs({ name: "convex" })
// Returns all available logs from the Convex process

list_processes

List all configured processes and their current status.

await list_processes()
// Output:
// nextjs: running (PID: 12345)
// convex: stopped

stop_all

Stop all running processes gracefully.

await stop_all()
// Output: "All processes stopped"

Typical Workflow

Here's how Claude Code uses MCP Rewatch during development:

  1. Initial setup (done once by you):

    • Create rewatch.config.json in your project
    • Start Claude Code - servers can be started on demand
  2. During development Claude Code will:

    • Make code changes to your files
    • Call restart_process({ name: "nextjs" }) to restart the server
    • Automatically receive initial logs after a 3-second startup delay
    • Check the logs for success indicators or errors
    • Continue with more changes based on the results
    • Call get_process_logs({ name: "nextjs" }) later if needed
  3. Key benefits:

    • Claude Code never gets blocked by long-running processes
    • You don't need to manually restart servers after every change
    • Claude Code can verify changes worked by checking logs
    • Multiple servers can be managed in parallel

How It Works

When restart_process is called:

  1. Stops any existing process with that name
  2. Starts the new process
  3. Waits for the configured startupDelay (default: 3 seconds)
  4. Returns the startup status and initial logs

This gives Claude Code immediate feedback about whether:

  • The process started successfully
  • There were immediate errors (port conflicts, missing deps)
  • The server is beginning to compile/build

For ongoing monitoring, Claude Code can use get_process_logs to check progress later.

Why This Matters

Without MCP Rewatch, the development flow with Claude Code is frustrating:

  • ❌ Claude Code tries npm run dev → blocks and times out
  • ❌ You make changes → servers break → manual restart needed
  • ❌ No way to check if changes compiled successfully

With MCP Rewatch:

  • ✅ Claude Code uses restart_process → returns immediately
  • ✅ Servers restart automatically after changes
  • ✅ Claude Code can check logs to verify success

Troubleshooting

  • Processes not starting: Check that rewatch.config.json exists in your project root
  • Permission errors: Ensure the commands in your config have proper execution permissions
  • Can't find tools: Verify MCP Rewatch appears in Claude Code's MCP menu
  • Logs not appearing: Processes might be buffering output; some servers need specific flags to disable buffering

Development

To contribute to MCP Rewatch:

git clone https://github.com/brennancheung/mcp-rewatch.git
cd mcp-rewatch
pnpm install
pnpm build

For development, you can point Claude Code directly to the built output:

# Build the project
pnpm build

# Add to Claude Code
claude mcp add rewatch-dev node -- /path/to/mcp-rewatch/dist/index.js

Then create a rewatch.config.json in whatever directory you're testing from.

推荐服务器

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

官方
精选