free-ai-mcp
free-ai-mcp
Free AI coding agent that works like Claude Code — read, edit, search, fix, and commit using free AI APIs with automatic fallback. When one provider hits its rate limit, the next one takes over.
Works as both a CLI tool (interactive terminal agent) and an MCP server (use inside Claude Code, Cursor, etc.).
Features
Streaming responses — Tokens appear as the AI generates them, no waiting
Search/Replace editing — Precise SEARCH/REPLACE blocks (like Claude Code)
Auto-fix loop — Runs tests, reads errors, fixes code automatically (up to 3 attempts)
Multi-file edits — "add a name column to users" plans and edits migration + model + views
Project memory —
.free-ai.mdgives the AI persistent context about your projectGrep/search — Search across your codebase without leaving the agent
Smart commit — AI writes commit messages, you just confirm
Image/screenshot support — Send screenshots to Gemini vision, ask "build this UI"
Tab completion — Press Tab to autocomplete file paths
Conversation persistence — Chat history saved, resumes next session
Auto-retry — Bad AI response? Automatically retries with the next provider
Usage tracking — See request counts per provider with
/statusShell & Git — Run any command with
!prefix, git commands work directlyUndo — Revert any edit instantly
Auto-fallback — 5 free AI providers with automatic failover
Supported Providers (All Free)
Provider | Model | Free Tier | Sign Up |
Google Gemini | gemini-2.5-flash | 15 req/min, 1M tokens/day, vision | |
Groq | llama-3.3-70b | 30 req/min, 14,400 req/day | |
Mistral AI | mistral-small | Free tier | |
Cerebras | qwen-3.8-27b | Free tier | |
OpenRouter | nex-n2.5-pro (free) | Free models available |
Setup
1. Clone and install
git clone https://github.com/tmahajan90/free-ai-mcp.git
cd free-ai-mcp
npm install2. Get your free API keys
Sign up at any of the provider links above. You need at least one, but more = more fallback.
Recommended:
Google Gemini — best free tier (1M tokens/day) + image support
Groq — fastest responses (<1 second)
3. Configure API keys
cp .env.example .envEdit .env and paste your keys:
GEMINI_API_KEY=your_gemini_key_here
GROQ_API_KEY=your_groq_key_here4. (Optional) Project memory
Create .free-ai.md in your project root:
This is a Rails 8 app using Tailwind CSS v4.
Multi-tenant with acts_as_tenant.
Use Stimulus controllers for JS.
Tests are in test/ directory, run with: bundle exec rails testThe AI will use this context for every interaction.
Usage — Interactive Mode (like Claude Code)
cd your-project
free-aiEdit files
edit app/models/user.rb add email validation
add pagination to app/controllers/products_controller.rb
remove the header from app/views/layouts/application.html.erbMulti-file edits
add a name column to users
add a search feature to productsAuto-fix (run tests -> fix errors -> repeat)
fix Auto-detects test command
fix bundle exec rails test Custom test command
fix npm test Works with any runnerSearch across files
grep validates app/models Find text in files
search "def create" Same as grep
find TODO Find all TODOsImage / Screenshot (Gemini vision)
image screenshot.png Describe what's in the image
image mockup.png build this UI AI analyzes image and generates codeRead & explore
read app/models/product.rb
explain app/controllers/sales_controller.rb
review app/views/sales/_form.html.erb
ls app/models
scan app/controllersShell & Git
!bundle exec rails test Run any shell command
git status Git commands directly
commit AI writes commit messageAll commands
Command | Description |
| Search across files |
| Auto-fix: run tests, fix errors, repeat |
| Smart commit with AI-generated message |
| Show session changes / git diff |
| Analyze image with Gemini vision |
| Undo last file edit |
| Scan project structure |
| List files |
| Show providers + usage stats |
| Show help |
| Clear conversation + saved history |
| Exit (history saved for next session) |
Keyboard shortcuts
Tab — Autocomplete file paths
Up/Down — Navigate input history
Ctrl+C — Cancel current operation
Usage — One-shot CLI
free-ai edit app/models/user.rb "add email validation"
free-ai explain app/controllers/sales_controller.rb
free-ai review app/views/sales/_form.html.erb
free-ai generate app/models/invoice.rb "Rails model with validations"
free-ai ask "how to add pagination in Rails"
free-ai statusUsage — MCP Server (Claude Code / Cursor)
claude mcp add free-ai node /full/path/to/free-ai-mcp/src/mcp-server.jsTool | Description |
edit_code | Edit files with SEARCH/REPLACE blocks |
read_code | Read a file with line numbers |
generate_code | Generate a new file from instructions |
explain_code | Get an AI explanation of a file |
review_code | Code review for bugs & security |
ask_ai | Ask a coding question |
run_command | Run a shell command |
ai_status | Check configured providers |
How the edit engine works
Uses SEARCH/REPLACE blocks (same approach as Claude Code):
<<<<<<< SEARCH
exact lines from the original file
=======
replacement lines (or empty to delete)
>>>>>>> REPLACERetry chain:
Ask AI for SEARCH/REPLACE blocks
If blocks don't match the file -> retry full-file mode
If AI gives garbage response -> auto-retry with next provider
Falls back to full-file replacement as last resort
Tips
Add all 5 provider keys to maximize free usage across the day
Gemini has the most generous free tier (1M tokens/day) and supports images
Groq is the fastest (responses in <1 second)
Create
.free-ai.mdfor project-specific context the AI always knowsUse
fixafter making changes to auto-run and fix testsUse
commitfor AI-generated commit messagesTab-complete file paths to type faster
Conversation persists across sessions — no need to re-explain context
/statusshows how many requests you've made per provider
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tmahajan90/free-ai-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server