Skip to content

bgauryy/octocode-mcp

Repository files navigation

Octocode MCP

The Perfect AI Code Assistant - Advanced Search & Discovery Across GitHub & NPM

Version License MCP Buy me a coffee

What is Octocode? πŸ™

The perfect code assistant that can help understand anything. Octocode provides AI-powered advanced search with heuristic discovery and smart fallbacks to understand connections between repositories and NPM packages across any privilege level you have.

Instead of manually browsing repositories, ask questions like:

  • "How did React implement concurrent rendering?"
  • "Show me authentication patterns in Next.js applications"
  • "Find examples of how to use this specific API"
  • "What's the architecture of this library?"
  • "How do I use this MCP tool effectively?"

Unique Value Proposition

The most advanced AI-powered code assistant for understanding connections across the entire GitHub & NPM ecosystem. While other GitHub MCPs focus on project management or basic operations, Octocode provides unparalleled depth for code discovery and technical research.

Key Differentiators:

  • 🧠 AI-Powered Search - Heuristic algorithms with smart fallbacks that understand code context and find relevant code even with vague queries
  • πŸ” Zero-Config Security - Uses GitHub CLI authentication - no personal access tokens needed
  • πŸ”— Connection Intelligence - Maps NPM packages to repositories, traces dependencies, finds related implementations
  • 🌐 Universal Access - Works seamlessly with public, private, and organization repositories
  • ⚑ LLM Optimized - Advanced content minification and partial fetching reduces token usage by 80-90%

Quick Start πŸš€

1. Install Prerequisites

# Install Node.js 18.12+
brew install node  # macOS
# or download from https://nodejs.org/

# Install GitHub CLI
brew install gh    # macOS
# or see: https://github.com/cli/cli#installation

2. Authenticate

# Login to GitHub (opens browser)
gh auth login

# Login to NPM (for package research)
npm login

πŸ” Authentication Benefits:

  • βœ… No personal access tokens - Uses GitHub CLI OAuth flow
  • βœ… Enterprise ready - Works with SSO, 2FA, and organization access
  • βœ… Automatic organization detection - Instantly accesses your private repositories
  • βœ… Zero configuration - Uses existing gh CLI permissions

3. Add to MCP Configuration

{
  "octocode-mcp": {
    "command": "npx",
    "args": ["octocode-mcp"]
  }
}

That's it! Octocode automatically works with your organization's private repositories.

How It Works πŸ”„

Smart Discovery Flow:

  1. πŸ” Query Analysis β†’ AI determines the best search strategy
  2. ⚑ Multi-Tool Orchestration β†’ Intelligently combines 10 specialized tools
  3. πŸ”„ Smart Fallbacks β†’ Automatically retries with different approaches
  4. πŸ”— Cross-Reference Discovery β†’ Links packages to repositories with commit SHA integration
  5. 🎯 Context Synthesis β†’ Provides comprehensive understanding

Example Flows

Example 1: LangGraph Node.js Implementation Tutorial

Query: "Show implementations of langgraph in node js. Make a tutorial for how to implement a simple agent using OpenAI API."

LangGraph Node.js Tutorial

Example 2: Zustand React State Management

Query: "Show me how to add zustand to react application. Show examples and best practices"

Zustand React State Management

Example 3: React vs Vue.js Rendering Comparison

Query: "How did React implement their concurrent rendering flows? How is it different from Vue.js rendering mechanism? Which is better?"

React vs Vue.js Rendering Comparison

Core Features πŸ› οΈ

🧠 AI-Powered Intelligence

  • Advanced Search - Heuristic pattern recognition with automatic fallback strategies
  • Connection Mapping - Automatically links NPM packages to GitHub repositories
  • Cross-Reference Analysis - Discovers how different projects implement similar patterns
  • Progressive Refinement - AI-guided search that improves with each iteration
  • Context-Aware Discovery - Understands relationships between code, commits, issues, and discussions

πŸ”— Commit SHA Integration

  • Time Travel Code Viewing - View files from specific commits and pull requests
  • PR Code Analysis - Automatically fetch commit SHAs for precise code comparison
  • Historical Implementation - Compare code evolution across versions

⚑ Performance Optimization

  • Smart Content Selection - Extracts only relevant code sections
  • Advanced Minification - Language-aware compression preserving meaning
  • Partial File Access - Fetches targeted line ranges
  • Token Efficiency - 80-90% reduction in LLM token usage

Available Tools

10 specialized tools working together intelligently:

Discovery: Repository Search, Package Search
Analysis: Code Search, Package Analysis, Repository Structure
Activity: Commit Search, Pull Request Search, Issue Search
Content: File Content Fetching, API Status Check

All tools feature automatic cross-referencing and intelligent fallbacks.

Security & Privacy πŸ›‘οΈ

Local-First Architecture

  • 🏠 100% Local - Runs entirely on your machine
  • 🚫 Zero Data Collection - No telemetry or data transmission
  • πŸ”‘ No Token Management - Uses GitHub CLI authentication

Command Execution Security

  • βšͺ Allowlisted Commands Only - Pre-approved safe commands
  • πŸ›‘οΈ Argument Sanitization - Prevents shell injection attacks
  • βœ… Pre-execution Validation - Every command is validated
  • πŸ”§ Controlled Environment - Cross-platform secure shell execution
  • ⏱️ Timeout Protection - Prevents resource exhaustion

Best Practices πŸ’‘

Effective Questions:

  • Start with natural language - "How does authentication work?"
  • Ask for connections - "What libraries use this pattern?"
  • Cross-ecosystem queries - "NPM packages that implement X"
  • Evolution questions - "How has this approach changed?"

Pro Tips:

  • Let AI guide discovery - vague queries work great
  • Trust smart fallbacks - automatic retry with alternatives
  • Build on previous searches - maintain context for deeper exploration
  • Works everywhere - public, private, and organization repositories

Troubleshooting πŸ”§

# Check GitHub CLI status
gh auth status

# Re-authenticate if needed
gh auth logout && gh auth login

# Check NPM access
npm whoami

# Clear NPX cache if needed
rm -rf ~/.npm/_npx

Common Solutions:

  • No results? Try broader search terms
  • Private repos not found? Check gh auth status for organization membership
  • Windows users? PowerShell is automatically supported

Background πŸ’­

This project started as a personal tool while working at Wix, born from the challenge of navigating large codebases and keeping up with rapidly evolving technology landscapes. What began as a side project evolved into the perfect code assistant that can help understand anything.

The goal: make code exploration as intelligent as having a senior developer guide you through any codebase.

License πŸ“„

MIT License - See LICENSE for details.