| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A streamlined Model Context Protocol server for efficient AI-powered code editing using FastApply. Inspired by opencode-fast-apply's simplicity and partial editing approach.
FastApply MCP Server provides intelligent code editing through partial file editing, achieving 80-98% token savings compared to full-file approaches. The server uses smart matching to locate and replace code sections automatically, making it ideal for editing large files efficiently.
Run directly without installation:
uvx fastapply-mcpgit clone https://github.com/your-org/fastapply-mcp.git
cd fastapply-mcp
# Using uv
uv sync
source .venv/bin/activate
uv pip install -e .
# Or using pip
pip install -e .Configure the server with just 3 environment variables:
# .env file
FAST_APPLY_URL=http://localhost:1234/v1
FAST_APPLY_MODEL=fastapply-1.5b
FAST_APPLY_API_KEY=optional-api-keyThat's it! No complex configuration needed.
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"fastapply": {
"command": "uvx",
"args": ["fastapply-mcp"],
"env": {
"FAST_APPLY_URL": "http://localhost:1234/v1",
"FAST_APPLY_MODEL": "fastapply-1.5b"
}
}
}
}{
"mcpServers": {
"fastapply": {
"command": "python",
"args": ["/path/to/fastapply-mcp/src/fastapply_mcp/main.py"],
"env": {
"FAST_APPLY_URL": "http://localhost:1234/v1",
"FAST_APPLY_MODEL": "fastapply-1.5b"
}
}
}
}The server implements the standard MCP protocol and works with any compatible client.
The server provides a single, focused tool for efficient code editing.
{
"target_filepath": "src/utils.py",
"original_code": "def parse_config(path):\n with open(path) as f:\n return json.load(f)",
"code_edit": "def parse_config(path):\n try:\n with open(path) as f:\n return json.load(f)\n except FileNotFoundError:\n raise ConfigError(f'Config not found: {path}')"
}Use ... existing code ... markers for unchanged sections:
# ... existing code ...
def updated_function():
return "modified"
# ... existing code ...This tells the AI to skip regenerating unchanged parts, making edits faster.
Partial editing provides massive token savings:
| File Size | Full File | Partial (100 lines) | Savings |
|---|---|---|---|
| 100 lines | 2,500 tokens | 500 tokens | 80% |
| 500 lines | 12,500 tokens | 1,000 tokens | 92% |
| 1000 lines | 25,000 tokens | 1,500 tokens | 94% |
| 5000 lines | 125,000 tokens | 2,000 tokens | 98% |
The tool uses a two-tier matching system:
Finds exact string match in the file.
Handles CRLF/LF differences automatically:
Ensures the section appears only once in the file to prevent ambiguous replacements.
Built-in protection against prompt injection:
# User code with XML tags
original_code = "<code>malicious</code>"
# Automatically escaped before API call
# "<code>malicious</code>"
# Safely processed and unescaped afterAll XML special characters (&, <, >, ", ') are automatically escaped and unescaped.
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull a FastApply model
ollama pull fastapply-1.5b
# Start the server
ollama serveConfigure FAST_APPLY_URL=http://localhost:11434/v1
Any OpenAI-compatible API works:
FAST_APPLY_URL=https://api.openai.com/v1
FAST_APPLY_MODEL=gpt-4
FAST_APPLY_API_KEY=sk-...Clear, actionable error messages:
❌ Error: Cannot locate original_code in file (whitespace mismatch detected). 💡 Troubleshooting: 1. Re-read the file to get current content 2. Ensure original_code matches exactly (including whitespace) 3. Provide more context to make the section unique
Verify your FastApply server is running:
curl http://localhost:1234/v1/modelsUse the tool only for existing files. For new files, use your MCP client's write tool.
The tool handles CRLF/LF differences automatically, but tabs vs spaces must match exactly.
fastapply-mcp/ ├── src/ │ └── fastapply_mcp/ │ ├── __init__.py │ └── main.py # Single-file implementation (~487 lines) ├── .env.example ├── pyproject.toml └── README.md
# Format code
ruff format .
# Lint code
ruff check .
# Type checking
mypy src/
# Syntax check
python -m py_compile src/fastapply_mcp/main.pyThis implementation follows these principles:
Contributions are welcome! Please:
MIT License - see LICENSE file for details.
| Back | FazBrowse Home | New Git URL |