CodeMerge
A Model Context Protocol server that uses Osmosis-Apply-1.7B to intelligently apply code edits while preserving the structure of the original code.
README
CodeMerge
A Model Context Protocol (MCP) server that uses the Osmosis-Apply-1.7B model to merge code edits.
- Code Merging: Uses the Osmosis/Osmosis-Apply-1.7B model to apply edits
- MCP Integration: Works as a Model Context Protocol server to integrate into existing AI IDE solutions
- File Operations: Can directly edit files in place or return edited code
Installation
Prerequisites
- Python 3.10 or higher
- Ollama installed and running
- The Osmosis model pulled:
ollama pull Osmosis/Osmosis-Apply-1.7B
Setup
- Clone the repository:
git clone <repository-url>
cd codemerge
- Install dependencies using uv:
uv sync
- Run:
uv run python codemerge.py
Usage
As an MCP Server
CodeMerge can be used as an MCP server. Configure it in your MCP client:
{
"mcpServers": {
"codemerge": {
"command": "uv",
"args": [
"--directory",
"/path/to/codemerge",
"run",
"codemerge.py"
]
}
}
}
Direct Usage
You can also use CodeMerge directly in Python:
from call_snippet import apply_code_edit
# Original code
original_code = """def hello():
print('Hello, World!')
print('Some code')
print('Some more code')
return 'success'"""
# Edit to apply
edit_snippet = """def hello():
print('Hello, Universe!')
print('Some code')
# ... existing code ...
return 'success'"""
# Apply the edit
result = apply_code_edit(original_code, edit_snippet)
print(result)
MCP Tool Usage
The MCP server provides an edit_snippet tool with the following parameters:
original_code: The exact original code to be editededit_snippet: The edit to apply, using// ... existing code ...markersfile_path: Absolute path to a file to update in place
Example tool call:
{
"name": "edit_snippet",
"arguments": {
"original_code": "def hello():\n print('Hello, World!')",
"edit_snippet": "def hello():\n print('Hello, Universe!')\n # ... existing code ...",
"file_path": "/path/to/your/file.py"
}
}
Edit Format
CodeMerge uses a specific format for edits that preserves context while being concise:
// ... existing code ...
FIRST_EDIT
// ... existing code ...
SECOND_EDIT
// ... existing code ...
THIRD_EDIT
// ... existing code ...
The // ... existing code ... markers indicate where the original code should be preserved. This allows you to specify only the parts you want to change while maintaining the exact structure and formatting of the original code.
Dependencies
httpx>=0.28.1: HTTP client for API callsmcp[cli]>=1.10.1: Model Context Protocol implementationollama: Python client for Ollama (installed separately)
Architecture
CodeMerge consists of several components:
codemerge.py: Main MCP server implementationcall_snippet.py: Direct usage interface with streaming supporttest_codemerge.py: Comprehensive test suitepyproject.toml: Project configuration and dependencies
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.