Morph MCP
Unified Model Context Protocol (MCP) server providing AI-powered file editing and intelligent code search capabilities. Built on Morph's SDK for fast, accurate code operations.
Features
AI-Powered Tools
- Fast Apply (edit_file) - Morph's lightning-fast code editing at 10,500+ tokens/sec with 98% accuracy
- Fast Context Search (fast_context_search) - AI-powered code search using WarpGrep that intelligently explores repositories to find relevant code
Filesystem Operations
- 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
Security & Access Control
- Dynamic directory access control via MCP Roots
- Workspace-aware path resolution
- Automatic workspace detection (enabled by default)
- Atomic file operations with temp files for safety
- Symlink protection and path validation
Configuration
Environment Variables
MORPH_API_KEY | Your Morph API key (required for AI tools) | - |
ENABLED_TOOLS | Comma-separated list of enabled tools, or all | edit_file,fast_context_search |
MORPH_DEBUG | Enable debug logging for grep agent (true/false) | false |
ENABLE_WORKSPACE_MODE | Auto-detect workspace root (true/false) | true |
WORKSPACE_ROOT | Override workspace root directory | $PWD |
Tool Configuration
Control which tools are available using ENABLED_TOOLS. By default, only AI-powered tools (edit_file and fast_context_search) are enabled to keep the interface clean. Enable additional filesystem tools as needed:
ENABLED_TOOLS=all
ENABLED_TOOLS=edit_file,fast_context_search
ENABLED_TOOLS=edit_file
ENABLED_TOOLS=fast_context_search
ENABLED_TOOLS=read_file,write_file,edit_file,fast_context_search
Available Tools
AI-Powered Tools
edit_file
PRIMARY TOOL FOR EDITING FILES - Efficiently edit existing files by smartly showing only changed lines. Uses Morph's Fast Apply model (via @morphllm/morphsdk) for intelligent code merging.
Key features:
- 10,500+ tokens/sec with 98% accuracy
- Prevents context pollution by only showing changed lines
- Smart context preservation with
// ... existing code ...
- Batch multiple edits to the same file
- Git-style unified diff output
- Automatic error reporting to Morph for continuous improvement
Requires: MORPH_API_KEY
Note for Cursor users: If you're using this tool within Cursor, you may need to first use another tool (like search_replace) to add exactly one empty newline somewhere in the file before using edit_file. This ensures the file is in an editable state.
fast_context_search
Intelligently search and gather relevant code context from a repository using Morph's WarpGrep AI-powered search agent. Automatically explores the codebase with grep, file reading, and directory analysis to find exactly what you need.
Key features:
- AI-powered multi-round exploration
- Returns precise line ranges, not entire files
- Prevents context pollution by finding only relevant code
- Formatted XML output with line numbers
Example queries:
- "Where is JWT token validation implemented?"
- "How does the authentication middleware work?"
- "Find the database connection setup"
Requires: MORPH_API_KEY
File Operations
Note: These tools are available but disabled by default. Set ENABLED_TOOLS=all to enable.
read_file - Read complete file contents with optional head/tail (memory-efficient for large files)
read_multiple_files - Read multiple files simultaneously
write_file - Create or overwrite files with atomic writes
tiny_edit_file - Make small line-based edits with diff output
Directory Operations
Note: These tools are available but disabled by default. Set ENABLED_TOOLS=all to enable.
create_directory - Create directories recursively
list_directory - List directory contents
list_directory_with_sizes - List with file sizes and sorting
directory_tree - Get recursive JSON tree structure
move_file - Move/rename files and directories
Search & Info
Note: These tools are available but disabled by default. Set ENABLED_TOOLS=all to enable.
search_files - Recursively search with exclude patterns
get_file_info - Get detailed file metadata
list_allowed_directories - Show accessible directories
Installation
Quick Start (NPX - Recommended)
For Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"morph-mcp": {
"command": "npx",
"args": ["-y", "morph-mcp"],
"env": {
"MORPH_API_KEY": "sk-your-morph-api-key-here",
"ENABLED_TOOLS": "all"
}
}
}
}
For Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"morph-mcp": {
"command": "npx",
"args": ["-y", "morph-mcp"],
"env": {
"MORPH_API_KEY": "sk-your-morph-api-key-here",
"ENABLED_TOOLS": "all"
}
}
}
}
One-liner installation:
claude mcp add morph-mcp -e MORPH_API_KEY=sk-your-morph-api-key-here -e ENABLED_TOOLS=all -- npx morph-mcp
Docker
{
"mcpServers": {
"morph-mcp": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"morph-llm/morph-mcp", "/projects"
],
"env": {
"MORPH_API_KEY": "sk-your-morph-api-key-here",
"ENABLED_TOOLS": "all"
}
}
}
}
VS Code
For quick installation, click the installation buttons below:

Or manually add to .vscode/mcp.json:
{
"mcp": {
"servers": {
"morph-mcp": {
"command": "npx",
"args": ["-y", "morph-mcp", "${workspaceFolder}"],
"env": {
"MORPH_API_KEY": "sk-your-morph-api-key-here",
"ENABLED_TOOLS": "all"
}
}
}
}
}
Getting Started
1. Get Your Morph API Key
- Sign up at Morph
- Get your API key from the dashboard
- API keys typically start with
sk- or morph-
2. Choose Your Configuration
For fast editing only:
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "edit_file"
}
}
For code search only:
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "fast_context_search"
}
}
For everything (including all filesystem tools):
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "all"
}
}
Default (AI tools only - recommended for most use cases):
{
"env": {
"MORPH_API_KEY": "sk-..."
}
}
3. Test Your Setup
In your AI assistant, try:
- Edit test: "Use the edit_file tool to add a comment to the main function"
- Search test: "Use fast_context_search to find where database connections are initialized"
Usage Examples
Fast Apply Editing
Ask AI: "Use the edit_file tool to add error handling to this function"
The AI will:
1. Read the current code (or use existing context)
2. Generate smart edit instructions with "// ... existing code ..."
3. Apply changes at 10,500+ tokens/sec using Morph's Fast Apply
4. Show you a git-style unified diff
5. Report errors (if any) to Morph for continuous improvement
Fast Context Search
Ask AI: "Use fast_context_search to find where JWT tokens are validated"
The WarpGrep agent will:
1. Explore the repository using grep, read, and analyse tools
2. Perform multi-round intelligent exploration
3. Find relevant code across multiple files
4. Return precise line ranges with full context (not entire files)
5. Display formatted XML output with line numbers
6. Show summary of tool calls made during search
Migration Guide
From @morph-llm/morph-fast-apply
Old config:
{
"env": {
"MORPH_API_KEY": "sk-...",
"ALL_TOOLS": "false"
}
}
New config:
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "edit_file"
}
}
From morph-codeseek
Old config:
{
"env": {
"GREP_AGENT_API_KEY": "sk-..."
}
}
New config:
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "fast_context_search"
}
}
Architecture
Modular Design
morph-mcp/
├── index.ts # Main server & tool registry
├── grep/ # Fast context search agent (WarpGrep)
│ ├── agent/ # Multi-round exploration logic
│ ├── tools/ # Grep, read, analyse, finish
│ └── utils/ # Ripgrep, file finder, logger
├── path-utils.ts # Path normalization & Windows/WSL support
├── path-validation.ts # Security validation
├── roots-utils.ts # MCP Roots protocol handling
└── @morphllm/morphsdk # Morph SDK integration (Fast Apply & WarpGrep)
Dependencies
- @morphllm/morphsdk (v0.2.22) - Core Fast Apply and WarpGrep functionality
- @modelcontextprotocol/sdk (v1.12.3) - MCP protocol implementation
- @vscode/ripgrep - Fast text search engine
Security
- Path validation for all filesystem operations
- Atomic file writes with temp files and rename operations
- Symlink protection (resolves symlinks before validation)
- Dynamic directory access via MCP Roots protocol
- Workspace-aware path resolution
- API key validation at startup
- Error reporting to Morph API (anonymized, for service improvement)
Troubleshooting
Tools Not Showing Up
- Check API key is set:
MORPH_API_KEY=sk-...
- By default, only
edit_file and fast_context_search are enabled. To enable all filesystem tools, set ENABLED_TOOLS=all
- Verify the tool name is in your
ENABLED_TOOLS list
- Restart your AI assistant completely
- Check logs:
tail -f ~/Library/Logs/Claude/mcp*.log (Claude Desktop) or check stderr output
Fast Context Search Not Finding Code
- Ensure you're passing the correct repository path (absolute or relative to workspace)
- Try more specific queries - WarpGrep works best with clear, descriptive queries
- Enable debug logging:
MORPH_DEBUG=true
- Check that
MORPH_API_KEY is correctly set
- Verify the repository path is within allowed directories (use
list_allowed_directories tool)
Permission Errors
- Check allowed directories: Use
list_allowed_directories tool
- Verify workspace mode is enabled:
ENABLE_WORKSPACE_MODE=true
- Pass directory explicitly via command-line args
Performance
| Fast Apply (edit_file) | 10,500+ tok/sec | 98% |
| Context Search (WarpGrep) | Multi-round, <30s | High relevance |
| File Operations | Native speed | 100% |
Note: Performance metrics are based on Morph's production models. Actual performance may vary based on file size, complexity, and network conditions.
Support
License
MIT License - See LICENSE file for details
Credits
Built by Morph - Making AI code editing fast and accurate.