Skip to main content
Build an agent that edits files at 10,500 tok/s and searches codebases in 3.8 steps.

Fast Apply

Your agent outputs a lazy edit snippet (changed lines + // ... existing code ... markers). Morph merges it into the original file and returns the result. 98% accuracy, sub-second latency.
1

Install

npm install @morphllm/morphsdk
Get your API key from the dashboard.
2

Run it

Save as apply.ts and run:
import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const result = await morph.fastApply.execute({
  target_filepath: 'src/auth.ts',
  instructions: 'Add null check before session creation',
  code_edit: `
// ... existing code ...
if (!user) throw new Error("User not found");
// ... existing code ...
  `
});

console.log(result.diff);
The instructions parameter must be generated by the model, not hardcoded. It provides context for ambiguous edits. Example: “Adding error handling to the user auth and removing the old auth functions.”
3

Add to your agent

The SDK provides tool factories for every major framework. One line gives your agent an edit_file tool:
import Anthropic from '@anthropic-ai/sdk';
import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
const anthropic = new Anthropic();

const response = await anthropic.messages.create({
  model: "claude-sonnet-4-5-20250929",
  max_tokens: 12000,
  tools: [morph.anthropic.createEditFileTool()],
  messages: [{ role: "user", content: "Add error handling to src/auth.ts" }]
});
For tool definition schemas, system prompt instructions, and output-parsing mode, see the Fast Apply product page.

WarpGrep

Code search subagent. Searches your codebase in its own context window, finds relevant code in 3.8 steps, returns file/line-range spans. Your agent’s context stays clean.
1

Install

npm install @morphllm/morphsdk
brew install ripgrep  # also: apt-get install ripgrep, choco install ripgrep
2

Run it

import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const result = await morph.warpGrep.execute({
  searchTerm: 'Find authentication middleware',
  repoRoot: '.'
});

if (result.success) {
  for (const ctx of result.contexts) {
    console.log(`${ctx.file}: ${ctx.content}`);
  }
}
3

Add to your agent

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
const warpGrepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });

const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 12000,
  tools: [warpGrepTool],
  messages: [{ role: 'user', content: 'Find authentication middleware' }]
});
For streaming, GitHub search, sandbox execution, and the raw API protocol, see the WarpGrep product page.

Next Steps

Fast Apply

Tool schemas, system prompts, and the lazy edit format

WarpGrep

Streaming, GitHub search, remote execution

MCP Integration

One command to add Morph to Claude Code, Cursor, or Codex

SDK Reference

Complete API documentation