npm package: @quocdat25/morph-fast-apply
Description: MCP server with Morph AI-powered file editing using fast apply model and abbreviated edit snippets (obfuscated)
Author: Morph
Latest version: 0.7.4

# Morph Fast Apply MCP Server

Node.js server implementing Model Context Protocol (MCP) for filesystem operations with AI-powered file editing using Morph's fast apply model.

## Features

- **AI-Powered File Editing** - Advanced `edit_file` tool using Morph's fast apply model for intelligent code merging
- Read/write files with memory-efficient head/tail operations
- Create/list/delete directories with detailed metadata
- Move files/directories
- Search files with exclude patterns
- Get comprehensive file metadata
- Dynamic directory access control via [Roots](https://modelcontextprotocol.io/docs/concepts/roots)
- Workspace-aware path resolution and automatic workspace detection

Set `MORPH_API_KEY` environment variable to enable AI-powered editing features.

## Environment Variables

### `ALL_TOOLS` - Control Tool Availability

This server supports two modes via the `ALL_TOOLS` environment variable:

**`ALL_TOOLS="false"` (Recommended)** - Fast file editing only
- Only exposes the `edit_file` tool for lightning-fast code edits
- Minimal surface area, maximum performance
- Perfect for AI assistants focused on code editing

**`ALL_TOOLS="true"` - Full filesystem access**
- Exposes all filesystem tools: `read_file`, `write_file`, `list_directory`, `search_files`, etc.
- Complete MCP filesystem server functionality
- Use when you need comprehensive file system operations

```bash
# Fast editing mode (recommended)
export ALL_TOOLS="false"
export MORPH_API_KEY="sk-your-morph-api-key-here"

# Full filesystem mode  
export ALL_TOOLS="true"
export MORPH_API_KEY="sk-your-morph-api-key-here"
```

### MCP Roots (Recommended)
MCP clients can dynamically update allowed directories via [Roots](https://modelcontextprotocol.io/docs/concepts/roots).



## Key Tools

### AI-Powered Editing
- **edit_file** - Advanced AI-powered file editing using Morph's fast apply model with intelligent code merging (requires MORPH_API_KEY)

### File Operations  
- **read_file** - Read file contents with optional head/tail parameters for large files
- **read_multiple_files** - Read multiple files simultaneously
- **write_file** - Create/overwrite files with atomic operations
- **tiny_edit_file** - Make small line-based edits with git-style diff output

### Directory Operations
- **create_directory** - Create directories recursively
- **list_directory** - List directory contents
- **list_directory_with_sizes** - List directory contents with file sizes and sorting
- **directory_tree** - Get recursive JSON tree structure
- **move_file** - Move/rename files and directories

### Search & Info
- **search_files** - Search for files recursively with exclude patterns
- **get_file_info** - Get comprehensive file metadata
- **list_allowed_directories** - Show accessible directories

## AI-Powered Editing with Morph

This server uses Morph's fast apply model API for intelligent code merging at 4500+ tokens/second with 99.2% accuracy. The `edit_file` tool processes code edits by taking initial code and edit snippets, then merging them intelligently using special "// ... existing code ..." comments for unchanged sections.

### Getting a Morph API Key

1. Visit [Morph](https://morphllm.com) to sign up for an API key
2. Set the `MORPH_API_KEY` environment variable in your MCP configuration
3. API keys typically start with `sk-` or `morph-`

### Code Obfuscation

This package includes obfuscated code for production deployment while maintaining the same functionality and API compatibility.

## Usage with Claude Desktop

Add to your Claude Desktop configuration file (`claude_desktop_config.json`):

### NPX (Recommended)
```json
{
  "mcpServers": {
    "morph-fast-apply": {
      "command": "npx",
      "args": ["-y", "@morph-llm/morph-fast-apply"],
      "env": {
        "MORPH_API_KEY": "sk-your-morph-api-key-here",
        "ALL_TOOLS": "false"
      }
    }
  }
}
```

### Docker
```json
{
  "mcpServers": {
    "morph-fast-apply": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
        "morph-llm/morph-fast-apply", "/projects"
      ],
      "env": {
        "MORPH_API_KEY": "sk-your-morph-api-key-here",
        "ALL_TOOLS": "false"
      }
    }
  }
}
```

## Usage with Claude Code

### One-liner Installation (Recommended)
```bash
claude mcp add filesystem-with-morph -e MORPH_API_KEY=sk-your-morph-api-key-here -e ALL_TOOLS=false -- npx @morph-llm/morph-fast-apply
```

> **💡 Pro tip:** Configure Claude to always use Morph for edits by adding this to your project:
> ```bash
> mkdir -p .claude
> echo "IMPORTANT: ALWAYS use mcp_filesystem-with-morph_edit_file tool to make any code edits. Do not use the default edit tool." > .claude/CLAUDE.md
> ```

### Config File Method
Add to your `.claude.json` file:
```json
{
  "mcpServers": {
    "filesystem-with-morph": {
      "command": "npx",
      "args": [
        "@morph-llm/morph-fast-apply"
      ],
      "env": {
        "MORPH_API_KEY": "sk-your-morph-api-key-here",
        "ALL_TOOLS": "false"
      }
    }
  }
}
```

## Manual Usage

For direct command-line usage or custom integrations:

```bash
# Set environment variables
export MORPH_API_KEY="sk-your-morph-api-key-here"
export ALL_TOOLS="false"  # or "true" for full filesystem access

# Run the MCP server
npx @morph-llm/morph-fast-apply
```

## Usage with VS Code

For quick installation, click the installation buttons below...

[![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-NPM-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=morph-fast-apply&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40morph-llm%2Fmorph-fast-apply%22%2C%22%24%7BworkspaceFolder%7D%22%5D%7D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-NPM-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=morph-fast-apply&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40morph-llm%2Fmorph-fast-apply%22%2C%22%24%7BworkspaceFolder%7D%22%5D%7D&quality=insiders)

[![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Docker-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=morph-fast-apply&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22--mount%22%2C%22type%3Dbind%2Csrc%3D%24%7BworkspaceFolder%7D%2Cdst%3D%2Fprojects%2Fworkspace%22%2C%22mcp%2Ffilesystem%22%2C%22%2Fprojects%22%5D%7D) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Docker-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=morph-fast-apply&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22--mount%22%2C%22type%3Dbind%2Csrc%3D%24%7BworkspaceFolder%7D%2Cdst%3D%2Fprojects%2Fworkspace%22%2C%22mcp%2Ffilesystem%22%2C%22%2Fprojects%22%5D%7D&quality=insiders)

For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open Settings (JSON)`.

Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others.

> Note that the `mcp` key is not needed in the `.vscode/mcp.json` file.

You can provide sandboxed directories to the server by mounting them to `/projects`. Adding the `ro` flag will make the directory readonly by the server.

### Docker
Note: all directories must be mounted to `/projects` by default. Remember to set your MORPH_API_KEY for AI-powered editing.

```json
{
  "mcp": {
    "servers": {
      "morph-fast-apply": {
        "command": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "--mount", "type=bind,src=${workspaceFolder},dst=/projects/workspace",
          "morph-llm/morph-fast-apply",
          "/projects"
        ],
        "env": {
          "MORPH_API_KEY": "sk-your-morph-api-key-here",
          "ALL_TOOLS": "false"
        }
      }
    }
  }
}
```

### NPX

```json
{
  "mcp": {
    "servers": {
      "morph-fast-apply": {
        "command": "npx",
        "args": [
          "-y",
          "@morph-llm/morph-fast-apply",
          "${workspaceFolder}"
        ],
        "env": {
          "MORPH_API_KEY": "sk-your-morph-api-key-here",
          "ALL_TOOLS": "false"
        }
      }
    }
  }
}
```