Skip to main content

Copy-Paste Implementation

Get a production-ready edit_file tool that you can paste directly into Cursor, Windsurf, Cline, Continue, and other AI IDEs

Quick Copy-Paste Implementation

This example shows how to use standard tool calls to implement the edit_file tool. Many research papers have shown that having LLMs like Claude/Gemini do code edits via normal JSON tool calls results in worse overall coding performance due to constrained decoding. For the best coding performance, you can use XML tags for your tool calls. See how Cline and Cursor use XML tags for all their tool calls.

Copy-Paste Prompt

Copy this prompt and paste it into your AI IDE (Cursor, Windsurf, Cline, Continue, etc.):

Implementation Examples

TypeScript with OpenAI SDK

Vercel AI SDK with Zod Validation

Setup Requirements

  1. Install dependencies: npm install openai or npm install ai zod
  2. Set API key: export MORPH_API_KEY="your-api-key-here"
  3. Get API key: Morph Dashboard

Next Steps

Ready to implement your edit_file tool? Here’s what to do next:

Agent Tools Guide

Learn about supporting tools and common patterns for building effective AI agents

Quickstart Guide

Step-by-step guide to configure your agent with the edit_file tool and integrate with Morph’s Fast Apply API

Apply API Reference

Explore the Apply API endpoints, models, and message formats for production use