codebase-agent-mcp-server

e11hzn/codebase-agent-mcp-server

3.2

If you are the rightful owner of codebase-agent-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Codebase MCP Server is a Model Context Protocol server that enhances AI agents' understanding of codebases by enabling indexing, searching, and analysis of Git repositories.

Tools
5
Resources
0
Prompts
0

Codebase MCP Server

A Model Context Protocol (MCP) server that provides AI agents with intelligent codebase understanding capabilities. This server enables LLMs to index, search, and analyze Git repositories, similar to Greptile.

Features

  • Repository Indexing: Clone and index Git repositories from GitHub, GitLab, or local paths
  • Code Search: Search for text patterns across indexed codebases
  • Natural Language Queries: Query codebases using natural language
  • File Navigation: Browse directory structures and file contents
  • Function Analysis: Analyze specific functions and their relationships
  • Git History: Access commit history and diffs
  • PR Review Support: Review diffs with full codebase context

🚀 Quick Start

New to this project? Start here:

  1. - Get up and running in 5 minutes
  2. - Comprehensive usage documentation
  3. - Full implementation details
  4. - LLM integration examples (OpenAI, Claude)

Installation

npm install
npm run build

Usage Modes

1. CLI Tool (Recommended for Getting Started)

Analyze any GitHub repository directly from the command line:

# General analysis
npm run analyze -- facebook/react main

# Ask specific questions
npm run analyze -- facebook/react main "How does reconciliation work?"

See for more examples.

2. MCP Server (For Claude Desktop Integration)

Stdio Transport (Local)
npm start
HTTP Transport (Remote/Web)
TRANSPORT=http PORT=3000 npm start

3. With LLM Integration (For AI-Powered Analysis)

See for OpenAI and Anthropic Claude integration examples.

Available Tools

Repository Management

ToolDescription
git_index_repositoryIndex a Git repository for searching and analysis
git_get_repository_statusCheck indexing status of a repository
git_list_repositoriesList all indexed repositories

Code Search & Query

ToolDescription
git_query_codebaseQuery the codebase in natural language
git_search_codeSearch for text patterns in code
git_get_file_contentRetrieve specific file contents
git_get_file_treeGet directory structure
git_get_git_historyGet commit history
git_analyze_functionAnalyze a specific function
git_review_diffReview a diff/commit

Configuration

Environment Variables

VariableDescriptionDefault
TRANSPORTTransport type (stdio or http)stdio
PORTHTTP server port3000

Claude Desktop Configuration

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "codebase": {
      "command": "node",
      "args": ["/path/to/codebase-mcp-server/dist/index.js"]
    }
  }
}

HTTP Client Configuration

For remote access, configure your MCP client to connect to:

http://localhost:3000/mcp

Example Usage

Index a Repository

{
  "tool": "git_index_repository",
  "arguments": {
    "remote": "github",
    "owner": "facebook",
    "repository": "react",
    "branch": "main"
  }
}

Search for Code

{
  "tool": "git_search_code",
  "arguments": {
    "query": "useState",
    "repositories": [{
      "remote": "github",
      "owner": "facebook",
      "repository": "react",
      "branch": "main"
    }],
    "file_pattern": "\\.tsx?$"
  }
}

Query Codebase

{
  "tool": "git_query_codebase",
  "arguments": {
    "query": "How does the reconciliation algorithm work?",
    "repositories": [{
      "remote": "github",
      "owner": "facebook",
      "repository": "react",
      "branch": "main"
    }]
  }
}

Agent Prompt

See AGENT_PROMPT.md for a comprehensive system prompt that instructs AI agents on how to effectively use this MCP server for codebase intelligence tasks.

Architecture

codebase-mcp-server/
├── src/
│   ├── index.ts           # Main entry point
│   ├── types.ts           # TypeScript type definitions
│   ├── constants.ts       # Configuration constants
│   ├── services/
│   │   └── git.service.ts # Git operations and indexing
│   ├── schemas/
│   │   └── index.ts       # Zod validation schemas
│   └── tools/
│       ├── repository.tools.ts  # Repository management tools
│       └── search.tools.ts      # Search and query tools
└── dist/                  # Built JavaScript files

Limitations

  • Repositories are stored in /tmp/mcp-repos (cleared on restart)
  • No persistent storage (repositories need re-indexing after restart)
  • Basic keyword search (no semantic/AI-powered search)
  • Function extraction is heuristic-based

Future Enhancements

  • Persistent repository storage
  • Semantic code search using embeddings
  • More sophisticated function relationship mapping
  • Support for more version control systems
  • Code complexity analysis
  • Security vulnerability detection

License

MIT