> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP server (legacy)

> The Morph MCP server for hosts that cannot run commands. New installs should use the morph CLI + skills.

> [!WARNING]
>
> The recommended integration is the [morph CLI](https://docs.morphllm.com/cli.md) plus [skills](https://docs.morphllm.com/skills.md): `curl -fsSL https://www.morphllm.com/install.sh | bash && morph install`. An MCP server puts its tool schemas into every prompt whether or not they are used; a skill costs nothing until the agent needs it. This server stays published for hosts that cannot run shell commands. `morph install --mcp` registers it as `morph mcp`.

The MCP server gives an agent `codebase_search` (WarpGrep over the local workspace), `github_codebase_search`, and `edit_file` (Fast Apply, 10,500 tok/s partial edits).

| Tool | Default | Description |
| - | - | - |
| `codebase_search` | Enabled | WarpGrep exploration subagent for your local workspace. Takes a natural-language query ("How does auth work?") and runs parallel grep + file reads over multiple turns to find relevant files and line ranges. Use first when exploring unfamiliar code. |
| `github_codebase_search` | Enabled | WarpGrep exploration for public GitHub repositories — no clone required. Takes `owner/repo` plus a natural-language query. Use when debugging third-party dependencies or investigating upstream bugs. |
| `edit_file` | Enabled | Morph Fast Apply: 10,500+ tok/s partial edits using `// ... existing code ...` placeholders. Disable it with `DISABLED_TOOLS=edit_file` if it collides with a client-native editor. |

**One command to install:**

```bash theme={null}
npx -y @morphllm/morph-setup --mcp --morph-api-key YOUR_API_KEY
```

Without `--mcp` the installer sets up the CLI and skills instead.

> [!NOTE]
>
> **Logged in?** Your API key auto-fills above. Otherwise, get it from your [dashboard](https://morphllm.com/dashboard/api-keys).

## Installation (All Clients)

**1. 1. Get Your API Key**

Get your API key from the [dashboard](https://morphllm.com/dashboard/api-keys).

**2. 2. Configure Your MCP Client**

> [tab] Claude Code
>
> **One-liner Installation (Recommended)**:
>
> ```bash theme={null}
> claude mcp add filesystem-with-morph --scope user -e MORPH_API_KEY=YOUR_API_KEY -- npx --prefer-offline -y @morphllm/morphmcp
> ```
>
> > [!NOTE]
> >
> > **Configure Claude to prefer Morph**: Add this to your global Claude config:
> >
> > ```bash theme={null}
> > mkdir -p ~/.claude && echo "Fast Apply: IMPORTANT: Use \`edit_file\` over \`str_replace\` or full file writes. It works with partial code snippets—no need for full file content.
> > Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. \"Find the XYZ flow\", \"How does XYZ work\", \"Where is XYZ handled?\", \"Where is <error message> coming from?\"" >> ~/.claude/CLAUDE.md
> > ```
>
> **Manual Config File Method**:
>
> Create or edit `.claude.json` in your workspace:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "filesystem-with-morph": {
>       "env": {
>         "MORPH_API_KEY": "YOUR_API_KEY"
>       },
>       "command": "npx --prefer-offline -y @morphllm/morphmcp",
>       "args": []
>     }
>   }
> }
> ```

> [tab] Codex
>
> **CLI Installation (Recommended)**:
>
> ```bash theme={null}
> # Add Morph MCP server to Codex
> codex mcp add morph-mcp --env MORPH_API_KEY=YOUR_API_KEY -- npx --prefer-offline -y @morphllm/morphmcp
> ```
>
> **Manual Config File**:
>
> Add to `~/.codex/config.toml`:
>
> ```toml theme={null}
> [mcp_servers.filesystem-with-morph]
> env = { "MORPH_API_KEY" = "YOUR_API_KEY" }
> command = "npx --prefer-offline -y @morphllm/morphmcp"
> args = []
> # Optional: adjust timeouts
> startup_timeout_sec = 120
> tool_timeout_sec = 60
> ```
>
> > [!NOTE]
> >
> > **CLI Management**: Use `codex mcp list` to see configured servers and `codex mcp remove filesystem-with-morph` to remove.
>
> > [!NOTE]
> >
> > Add to your `AGENTS.md`:
> >
> > ```markdown theme={null}
> > Fast Apply: IMPORTANT: Use `edit_file` over `str_replace` or full file writes. It works with partial code snippets—no need for full file content.
> > Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. "Find the XYZ flow", "How does XYZ work", "Where is XYZ handled?", "Where is <error message> coming from?"
> > ```

> [tab] Cursor
>
> Add to your Cursor MCP by clicking this button: [        ![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](cursor://anysphere.cursor-deeplink/mcp/install?name=morph-mcp\&config=eyJlbnYiOnsiTU9SUEhfQVBJX0tFWSI6InlvdXItbW9ycGgtYXBpLWtleS1oZXJlIn0sImNvbW1hbmQiOiJucHggLXkgQG1vcnBobGxtL21vcnBobWNwIn0%3D)
>
> OR add to your Cursor MCP config file:
>
> **Location**: `~/.cursor/mcp.json`
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "morph-mcp": {
>       "env": {
>         "MORPH_API_KEY": "YOUR_API_KEY"
>       },
>       "command": "npx --prefer-offline -y @morphllm/morphmcp",
>       "args": []
>     }
>   }
> }
> ```
>
> > [!NOTE]
> >
> > **Global Config**: This configuration works across all your projects automatically. The MCP server detects workspace boundaries via `.git`, `package.json`, and other project indicators.
>
> > [!TIP]
> >
> > **Make Cursor use Morph tools!** Add this to your system prompt in **Settings → Rules for AI**:
> >
> > ```
> > Fast Apply: IMPORTANT: Use `edit_file` over `str_replace` or full file writes. It works with partial code snippets—no need for full file content.
> > Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. "Find the XYZ flow", "How does XYZ work", "Where is XYZ handled?", "Where is <error message> coming from?"
> > ```

> [tab] Claude Desktop
>
> Add to your Claude Desktop config file:
>
> **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`\
> **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "filesystem-with-morph": {
>       "env": {
>         "MORPH_API_KEY": "YOUR_API_KEY"
>       },
>       "command": "npx --prefer-offline -y @morphllm/morphmcp",
>       "args": []
>     }
>   }
> }
> ```
>
> > [!NOTE]
> >
> > **Restart Required**: Completely quit and restart Claude Desktop to load the new configuration.
>
> > [!NOTE]
> >
> > Add to your project instructions:
> >
> > ```markdown theme={null}
> > Fast Apply: IMPORTANT: Use `edit_file` over `str_replace` or full file writes. It works with partial code snippets—no need for full file content.
> > Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. "Find the XYZ flow", "How does XYZ work", "Where is XYZ handled?", "Where is <error message> coming from?"
> > ```

> [tab] VS Code
>
> **CLI Installation (Recommended)**:
>
> ```bash theme={null}
> code --add-mcp '{"name":"morph-mcp","command":"npx","args":["--prefer-offline","-y","@morphllm/morphmcp"],"envVars":{"MORPH_API_KEY":"YOUR_API_KEY"}}'
> ```
>
> Or use the Command Palette: run `MCP: Add Server`, enter the server details, and select **Global** to save to your user profile.
>
> **Manual Config File**:
>
> Run `MCP: Open User Configuration` from the Command Palette, or add to your user-level `mcp.json`:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "filesystem-with-morph": {
>       "env": {
>         "MORPH_API_KEY": "YOUR_API_KEY"
>       },
>       "command": "npx --prefer-offline -y @morphllm/morphmcp",
>       "args": []
>     }
>   }
> }
> ```
>
> > [!NOTE]
> >
> > Add to your `.github/copilot-instructions.md`:
> >
> > ```markdown theme={null}
> > Fast Apply: IMPORTANT: Use `edit_file` over `str_replace` or full file writes. It works with partial code snippets—no need for full file content.
> > Warp Grep: warp-grep is a subagent that takes in a search string and tries to find relevant context. Best practice is to use it at the beginning of codebase explorations to fast track finding relevant files/lines. Do not use it to pin point keywords, but use it for broader natural-language queries. "Find the XYZ flow", "How does XYZ work", "Where is XYZ handled?", "Where is <error message> coming from?"
> > ```

> [tab] Manual
>
> Run the MCP server directly:
>
> ```bash theme={null}
> export MORPH_API_KEY="YOUR_API_KEY"
> npx --prefer-offline -y @morphllm/morphmcp
> ```

**3. 3. Test Installation**

**Claude Code**: Type `/mcp` and `/tools` to see Morph's `edit_file` tool\
**Codex**: Run `codex mcp list` to verify server is configured, then make edit requests\
**Cursor/VS Code**: Make any code edit request - should use Morph automatically\
**Manual**: Check server logs show "MCP Server started successfully"

## Configuration

| Variable | Default | Description |
| - | - | - |
| `MORPH_API_KEY` | Required | Your API key |
| `WORKSPACE_MODE` | `"true"` | Auto workspace detection |
| `DEBUG` | `"false"` | Debug logging |

### Advanced Configuration

| Variable | Default | Description |
| - | - | - |
| `MORPH_API_URL` | `https://api.morphllm.com` | Override the Morph API base URL (for proxies) |
| `MORPH_WARP_GREP_TIMEOUT` | `30000` | Timeout for Warp Grep model calls in milliseconds |

**Custom API endpoint** — For enterprise deployments or custom authentication flows:

```json theme={null}
{
  "mcpServers": {
    "morph-mcp": {
      "env": {
        "MORPH_API_KEY": "<user-jwt-token>",
        "MORPH_API_URL": "https://your-proxy.example.com"
      },
      "command": "npx --prefer-offline -y @morphllm/morphmcp",
      "args": []
    }
  }
}
```

Your proxy receives requests to `/v1/chat/completions` with the token in the `Authorization: Bearer` header. Forward these to `https://api.morphllm.com/v1/chat/completions` after handling auth/billing.

**Warp Grep timeout** — Increase for large codebases or slow networks:

```json theme={null}
{
  "mcpServers": {
    "morph-mcp": {
      "env": {
        "MORPH_API_KEY": "sk-xxx",
        "MORPH_WARP_GREP_TIMEOUT": "60000"
      },
      "command": "npx --prefer-offline -y @morphllm/morphmcp",
      "args": []
    }
  }
}
```

## Available Tools

All three tools are on by default. Narrow the set with either variable in the server env:

| Variable | Meaning | Example |
| - | - | - |
| `ENABLED_TOOLS` | Allow-list (or `all`) | `codebase_search,github_codebase_search` |
| `DISABLED_TOOLS` | Deny-list | `edit_file` |

When both are set a tool is on only if allowed and not denied. `ENABLED_TOOLS` was dropped in 0.8.114 and restored in 0.8.216; the pre-0.8.124 names `warpgrep_codebase_search` and `warpgrep_github_search` still resolve. Search only:

```json theme={null}
{
  "mcpServers": {
    "morph-mcp": {
      "env": {
        "MORPH_API_KEY": "YOUR_API_KEY",
        "ENABLED_TOOLS": "codebase_search,github_codebase_search"
      },
      "command": "npx --prefer-offline -y @morphllm/morphmcp",
      "args": []
    }
  }
}
```

## Troubleshooting

**Server won't start**: Check API key, Node.js 16+, run `npm cache clean --force`\
**Tools missing**: Restart client, validate JSON config\
**Workspace issues**: Add `.git` or `package.json`, or set `WORKSPACE_MODE="false"`\
**Slow performance**: Use `edit_file` over `write_file`, check network to api.morphllm.com

## Performance Optimization

### Best Practices

1. **Use `edit_file` for modifications**: Much faster than reading + writing entire files
2. **Minimize edit scope**: Include only the sections that need changes
3. **Batch related edits**: Make multiple changes in a single `edit_file` call

### Performance Comparison

| Method | Speed | Use Case |
| - | - | - |
| `edit_file` (Morph) | \~11 seconds | Code modifications, updates |
| Search & replace | \~20 seconds | Simple text substitutions |
| Traditional read/write | \~60 seconds | Full file rewrites |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.