CodeContext
FreeNot checkedEnables AI coding assistants to automatically detect and inject team-specific codebase patterns (e.g., error handling, imports, naming conventions) via the Mode
About
Enables AI coding assistants to automatically detect and inject team-specific codebase patterns (e.g., error handling, imports, naming conventions) via the Model Context Protocol, ensuring suggestions follow project conventions.
README
🧠 CodeContext
AI Coding Context Layer — Make AI assistants understand your team's codebase patterns
License: MIT TypeScript Next.js MCP Compatible
Features • Quick Start • Architecture • API Reference • Contributing
🎯 The Problem
AI coding assistants like Cursor and Copilot are powerful, but they don't understand your team's unique patterns:
- Your error handling conventions
- Your import style preferences
- Your validation approach
- Your authentication patterns
Every suggestion requires mental translation to match your codebase.
✨ The Solution
CodeContext automatically detects your codebase patterns and injects them as context into AI assistants via the Model Context Protocol (MCP). Now every AI suggestion follows your team's conventions out of the box.
🚀 Features
8 Pattern Types Detected
| Category | Pattern Types | Detection Method |
|---|---|---|
| Code Style | Error Handling, Imports, Naming, Structure | Rules-based (instant) |
| Frameworks | API Format, Validation, Database, Auth | Hybrid (rules + LLM fallback) |
Key Capabilities
- 🔍 AST-Powered Analysis — Deep code parsing with Babel for accurate pattern detection
- 🤖 Hybrid Detection — Rules-based first, LLM (Groq) fallback for complex patterns
- ⚡ Real-time Indexing — Background processing with Redis queue
- 🔗 MCP Protocol — Native integration with Cursor, Copilot, and more
- 🔐 GitHub OAuth — Seamless onboarding and repository access
- 📊 Dashboard — View detected patterns, confidence scores, and usage analytics
🏗️ Architecture
flowchart TB
subgraph Input["📥 Input"]
GH[GitHub Repository]
end
subgraph Core["🧠 CodeContext Engine"]
IDX[Indexing Queue<br/>Redis/Upstash]
AST[AST Parser<br/>Babel]
DET[Pattern Detectors<br/>8 Types]
LLM[LLM Fallback<br/>Groq]
CTX[Context Generator]
end
subgraph Storage["💾 Storage"]
DB[(PostgreSQL<br/>Supabase)]
end
subgraph Output["📤 Output"]
MCP[MCP Server]
DASH[Dashboard]
end
subgraph Clients["🤖 AI Clients"]
CUR[Cursor]
COP[Copilot]
OTHER[Other MCP Clients]
end
GH --> IDX
IDX --> AST
AST --> DET
DET --> LLM
DET --> DB
LLM --> DB
DB --> CTX
CTX --> MCP
DB --> DASH
MCP --> CUR
MCP --> COP
MCP --> OTHER
📦 Tech Stack
| Layer | Technology |
|---|---|
| Frontend | Next.js 14 (App Router), TypeScript, Tailwind CSS |
| Backend | Next.js API Routes, NextAuth.js |
| Database | PostgreSQL (Supabase) |
| Queue | Redis (Upstash) |
| AST Parsing | @babel/parser, @babel/traverse |
| LLM | Groq (llama-3.3-70b-versatile) |
| MCP | @modelcontextprotocol/sdk |
🚀 Quick Start
Prerequisites
- Node.js 18+
- PostgreSQL database (we recommend Supabase)
- Redis instance (we recommend Upstash)
- GitHub OAuth App
- Groq API key (free tier: 14,400 req/day)
1. Clone & Install
git clone https://github.com/bhasinagam/ContextBridge.git
cd ContextBridge
npm install
2. Configure Environment
cp .env.example .env.local
Edit .env.local with your credentials:
| Variable | Description | Where to Get |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Supabase → Settings → Database |
UPSTASH_REDIS_REST_URL |
Redis REST URL | Upstash → Redis → REST API |
UPSTASH_REDIS_REST_TOKEN |
Redis REST token | Same as above |
NEXTAUTH_SECRET |
Random 32-byte secret | Run: openssl rand -base64 32 |
GITHUB_CLIENT_ID |
OAuth App client ID | GitHub → OAuth Apps |
GITHUB_CLIENT_SECRET |
OAuth App secret | Same as above |
GROQ_API_KEY |
Groq API key | Groq Console |
3. Set Up Database
Run the schema in your Supabase SQL editor:
-- Contents of src/lib/db/schema.sql
Or use the Supabase dashboard to import src/lib/db/schema.sql.
4. Run Development Server
npm run dev
Open http://localhost:3000 to access the dashboard.
🔌 MCP Integration
Using with Cursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"codecontext": {
"url": "http://localhost:3000/api/mcp/context",
"headers": {
"X-API-Key": "your-api-key"
},
"defaultParams": {
"repo_id": "your-repo-id"
}
}
}
}
API Usage
curl -X POST http://localhost:3000/api/mcp/context \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"query": "add an API endpoint",
"repo_id": "your-repo-id"
}'
📁 Project Structure
src/
├── app/ # Next.js App Router
│ ├── api/ # API Routes
│ │ ├── auth/ # NextAuth endpoints
│ │ ├── github/ # GitHub API proxy
│ │ ├── mcp/ # MCP context & health
│ │ ├── patterns/ # Pattern queries
│ │ ├── repos/ # Repository CRUD
│ │ └── webhooks/ # GitHub webhooks
│ ├── dashboard/ # Dashboard pages
│ └── onboarding/ # Onboarding flow
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ └── dashboard/ # Dashboard-specific
└── lib/ # Core libraries
├── db/ # Database client & schema
├── github/ # GitHub API client
├── indexing/ # AST parser & queue
├── mcp/ # MCP server & context generator
├── patterns/ # 8 pattern detectors
└── utils/ # Types, helpers, Groq client
🔍 Pattern Types
Rules-Based (No API Calls)
| Pattern | What It Detects |
|---|---|
| Error Handling | try-catch blocks, wrapper functions (handleError, etc.) |
| Import Style | Relative (./path), Absolute (@/, ~/), Barrel exports |
| Naming Convention | camelCase, snake_case, PascalCase |
| File Structure | App Router, Pages Router, Components directory |
Hybrid (Rules + LLM Fallback)
| Pattern | What It Detects |
|---|---|
| API Format | Next.js API Routes, response structure patterns |
| Validation | Zod, Yup, Joi, Valibot, custom validation |
| Database | Prisma, Drizzle, TypeORM, Mongoose, Supabase, Kysely |
| Authentication | NextAuth, Clerk, Auth0, Supabase Auth, Firebase |
🔧 Troubleshooting
Database connection failed
- Ensure your Supabase project is active
- Check if the password contains special characters (URL-encode them)
- Use port
5432for direct connection,6543for pooled
GitHub OAuth redirect error
- Verify callback URL is set to
http://localhost:3000/api/auth/callback/github - Ensure
NEXTAUTH_URLmatches your app URL
Pattern detection returns empty
- Check if repository indexing is complete (status: "completed")
- Verify there are TypeScript/JavaScript files in the repo
- Check Redis queue for pending jobs
MCP not connecting to Cursor
- Restart Cursor after updating
mcp.json - Check API key is valid and not expired
- Verify the repo_id matches a indexed repository
🗺️ Roadmap
- Multi-language support — Python, Go, Rust
- Custom pattern definitions — User-defined pattern rules
- Team collaboration — Shared pattern configs
- VS Code extension — Native VS Code integration
- Pattern analytics — Usage trends and insights
🤝 Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ for the AI-assisted coding community
⭐ Star this repo if you find it useful!
Installing CodeContext
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/bhasinagam/ContextBridgeFAQ
Is CodeContext MCP free?
Yes, CodeContext MCP is free — one-click install via Unyly at no cost.
Does CodeContext need an API key?
No, CodeContext runs without API keys or environment variables.
Is CodeContext hosted or self-hosted?
A hosted option is available: Unyly runs the server in the cloud, no local setup required.
How do I install CodeContext in Claude Desktop, Claude Code or Cursor?
Open CodeContext on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare CodeContext with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
