xGAIR: An MCP Server That Gives AI Assistants Repo Context
AI coding assistants are good at writing code and bad at knowing your project. Every new session starts from zero: the assistant doesn't know your stack, your conventions, or the mistake you already fixed last week. It also tends to jump straight to writing code. I built xGAIR to deal with both problems: missing context and missing discipline.
Why I built it
I work on several side projects across different stacks, including vanilla JavaScript, TypeScript with React, and Kotlin with Compose. Each time I opened an AI assistant on one of them, I had to re-explain the basics. The assistant would also happily start editing files before it understood the problem.
I wanted one layer that sits between any GitHub repository and any AI assistant, so the assistant arrives already informed and follows the same process every time. The tagline I settled on is PLUG IN. IT ALREADY KNOWS.
What it does
xGAIR is an MCP (Model Context Protocol) server. It is not a chatbot wrapper. It works with Claude Code, VS Code GitHub Copilot, Cursor, Windsurf, Zed, Claude Desktop, JetBrains IDEs and ChatGPT. The README describes it as doing six things:
- Discovers a repository through the GitHub API, with no local clone required.
- Understands the stack, architecture, conventions and constraints.
- Enforces a strict four-phase workflow on every task.
- Remembers gotchas and patterns from previous tasks.
- Validates code against per-stack anti-pattern rules before it ships.
- Ships to GitHub with a conventional commit, a PR and a pattern log.
The workflow is the core idea. Every task, however small, follows the same sequence:
INVESTIGATE → PLAN (hard stop, wait for approval) → IMPLEMENT → VALIDATE → SHIP
The hard stop after planning matters most. The assistant has to present a plan and wait for approval before it touches code.
How it works
The project is written in TypeScript, with some Python and shell scripts alongside. It targets Node.js 18 and above and is published on npm as xgair. The server entry points are src/server.ts and src/index.ts, and a CLI wraps the setup and serving steps.
Two transports
Most IDEs launch MCP servers as a subprocess and talk over stdio, so seven of the eight supported clients use that mode. The config is the same pattern everywhere:
{"command": "npx", "args": ["xgair", "serve"], "env": {"GITHUB_TOKEN": "<your-token>"}}
ChatGPT and other web clients need HTTP instead. xgair serve --http --port 3000 exposes an MCP endpoint at /mcp and a health check at /health. For remote access you can tunnel it with npx ngrok http 3000. If you only want local access, --host 127.0.0.1 binds to localhost.
Supporting both from one server meant the tool logic had to stay independent of the transport. That is a reusable lesson for any MCP server: keep the tools transport-agnostic and treat stdio and HTTP as thin entry layers.
Discovery without a clone
Discovery runs as a five-phase pipeline against the GitHub API. Because it reads through the API, you can connect a repo or a whole organization without checking anything out. xgair connect owner/repo registers one repository, and xgair connect --org myorg registers every repo in an org. xgair discover runs the pipeline, and it resumes from cached phases unless you pass --no-resume. Resumability is useful when a long pipeline gets interrupted partway through.
Setup as a single command
The interactive wizard is the main entry point:
npx xgair init --github <your-username>
It verifies your GitHub token, creates a workspace directory (~/.xgair by default), connects your first repo, optionally runs discovery, and prints setup instructions for every supported IDE. After that, xgair config --ide <id> prints the exact config for your editor, and you can redirect it straight into a file such as .mcp.json or .vscode/mcp.json.
xgair status lists connected repositories with their detected stack and how many discovery phases have completed, so you can see at a glance which repos are ready.
What I learned
- Process is a feature. Encoding the investigate, plan, implement, validate, ship sequence in the tools, slash commands and commit format makes the discipline hard to skip. A rule in a prompt is easy for a model to drift from; a rule built into the tooling is much harder to ignore.
- Make onboarding one command. Tools that need several manual config steps tend not to get used. A wizard that checks the token, creates the workspace and prints per-IDE config removed most of the friction.
- Don't require a clone. Reading through the GitHub API means any repo you can access is reachable immediately, which makes connecting a whole org practical.
- Cache long pipelines. Phase-level caching with an explicit override flag keeps repeated runs cheap without losing the ability to start fresh.
I have not published any measurements of how much this improves assistant output, so I won't claim a number. What I can say is that it changes how a session starts: the assistant has context and a process before the first prompt.
Conclusion
xGAIR is my attempt to stop re-explaining my projects to AI assistants and to make them plan before they code. It is an MCP server with a CLI, support for eight IDEs and assistants, and a fixed four-phase workflow. If you want to try it, the package is on npm as xgair, and the quick start is the single init command above. Questions or feedback are welcome at hello@iramesh.com.