morph-mcp
v1.0.1
Published
Unified MCP server with AI-powered file editing (Morph Fast Apply) and intelligent code search (Fast Context Search)
Readme
Morph MCP
Unified Model Context Protocol (MCP) server providing AI-powered file editing and intelligent code search capabilities.
Features
AI-Powered Tools
- Fast Apply (edit_file) - Morph's lightning-fast code editing at 4500+ tokens/sec with 99.2% accuracy
- Fast Context Search (fast_context_search) - AI-powered code search 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
- Atomic file operations with temp files for safety
Configuration
Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| MORPH_API_KEY | Your Morph API key (required for AI tools) | - |
| ENABLED_TOOLS | Comma-separated list of enabled tools, or all | all |
| 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:
# Enable all tools (default)
ENABLED_TOOLS=all
# Only AI-powered tools
ENABLED_TOOLS=edit_file,fast_context_search
# Only fast apply
ENABLED_TOOLS=edit_file
# Only context search
ENABLED_TOOLS=fast_context_search
# Custom selection
ENABLED_TOOLS=read_file,write_file,edit_file,fast_context_searchAvailable 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 for intelligent code merging.
Key features:
- 4500+ tokens/sec with 99.2% accuracy
- Smart context preservation with
// ... existing code ... - Batch multiple edits to the same file
- Git-style diff output
Requires: MORPH_API_KEY
fast_context_search
Intelligently search and gather relevant code context from a repository using an AI-powered search agent. Automatically explores the codebase with grep, file reading, and directory analysis.
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
read_file- Read complete file contents with optional head/tailread_multiple_files- Read multiple files simultaneouslywrite_file- Create or overwrite filestiny_edit_file- Make small line-based edits with diff output
Directory Operations
create_directory- Create directories recursivelylist_directory- List directory contentslist_directory_with_sizes- List with file sizes and sortingdirectory_tree- Get recursive JSON tree structuremove_file- Move/rename files and directories
Search & Info
search_files- Recursively search with exclude patternsget_file_info- Get detailed file metadatalist_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-mcpDocker
{
"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-ormorph-
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 (recommended):
{
"env": {
"MORPH_API_KEY": "sk-...",
"ENABLED_TOOLS": "all"
}
}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
2. Generate smart edit instructions with "// ... existing code ..."
3. Apply changes at 4500+ tokens/sec
4. Show you a git-style diffFast Context Search
Ask AI: "Use fast_context_search to find where JWT tokens are validated"
The agent will:
1. Explore the repository using grep, read, and analyse tools
2. Find relevant code across multiple files
3. Return precise line ranges with full context
4. Display formatted XML output with line numbersMigration 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
│ ├── agent/ # Multi-round exploration logic
│ ├── tools/ # Grep, read, analyse, finish
│ └── utils/ # Ripgrep, file finder, logger
├── morph-client.ts # Morph API integration
└── path-*.ts # Security & validationSecurity
- Path validation for all filesystem operations
- Atomic file writes with temp files
- Symlink protection
- Dynamic directory access via MCP roots
- API key validation at startup
Troubleshooting
Tools Not Showing Up
- Check API key is set:
MORPH_API_KEY=sk-... - Verify tools are enabled:
ENABLED_TOOLS=all - Restart your AI assistant completely
- Check logs:
tail -f ~/Library/Logs/Claude/mcp*.log
Fast Context Search Not Finding Code
- Ensure you're passing the correct repository path
- Try more specific queries
- Enable debug logging:
MORPH_DEBUG=true - Check debug logs in
${TMPDIR}/morph-codeseek-debug/
Permission Errors
- Check allowed directories: Use
list_allowed_directoriestool - Verify workspace mode is enabled:
ENABLE_WORKSPACE_MODE=true - Pass directory explicitly via command-line args
Performance
| Feature | Speed | Accuracy | |---------|-------|----------| | Fast Apply (edit_file) | 4500+ tok/sec | 99.2% | | Context Search | 4 rounds, <30s | High relevance | | File Operations | Native speed | 100% |
Support
- Documentation: https://docs.morphllm.com
- Homepage: https://morphllm.com
- Issues: GitHub Issues
License
MIT License - See LICENSE file for details
Credits
Built by Morph - Making AI code editing fast and accurate.
