MCP ExplorerExplorer

Mcp Github Code Analyzer

@eschizoidon 10 months ago
2 MIT
FreeCommunity
AI Systems
A Kotlin server that analyzes GitHub repos for code insights using AI.

Overview

What is Mcp Github Code Analyzer

mcp-github-code-analyzer is a Kotlin server application designed to analyze GitHub repositories, providing insights into code structure and relationships using AI models.

Use cases

Use cases include analyzing open-source projects for educational insights, assessing code quality in development teams, generating documentation from code structure, and providing feedback on repository architecture.

How to use

To use mcp-github-code-analyzer, clone the repository, build the project with Gradle, configure environment variables, and run the application. You can analyze repositories by sending a POST request to the /analyze endpoint with the repository URL and desired analysis type.

Key features

Key features include cloning and analyzing GitHub repositories, extracting code structure and relationships, processing code with context-aware models, generating detailed insights and summaries, and providing a RESTful API for repository analysis.

Where to use

mcp-github-code-analyzer can be used in software development, code review processes, educational purposes for understanding codebases, and any scenario where code analysis is required.

Content

🤖 MCP Code Analysis Server

A Kotlin server application that analyzes GitHub repositories using AI models through the Model Context Protocol (MCP).

Features

  • Clone and analyze GitHub repositories
  • Extract code structure and relationships
  • Process code using Model Context Protocol
  • Generate detailed insights and summaries
  • Multiple server modes (stdio, SSE)

Getting Started

Prerequisites

  • JDK 23 or higher
  • Kotlin 1.9.x
  • Gradle 8.14 or higher
  • Ollama 3.2 or higher (for model API)
  • MCP Inspector (for model context protocol)

Installation

  1. Clone this repository
  2. Build the project using Gradle:
./gradlew build
  1. Start Ollama server:
ollama run llama3.2
  1. Start the MCP Inspector:
npx @modelcontextprotocol/inspector
  1. You can access the MCP Inspector at http://127.0.0.1:6274/ and configure the Arguments to start the server:

Connect

Use the following arguments:

-jar ~/mcp-github-code-analyzer/build/libs/mcp-github-code-analyzer-0.1.0-SNAPSHOT.jar --stdio
  1. Click Connect to start the MCP Server.

  2. Then you can click the tab Tools to discover the available tools. The Tool analyze-repository should be listed
    and ready to be used. Click on the analyze-repository tool to see its details and parameters:

Tools Tab

  1. Finally, capture the repoUrl and branch parameters and click Run Tool to start the analysis:

Run Tool

Configuration

The application uses environment variables for configuration:

  • SERVER_PORT: The port for the server (default: 3001)
  • GITHUB_TOKEN: GitHub token for API access (optional)
  • WORKING_DIRECTORY: Directory for cloning repositories (default: system temp + “/mcp-code-analysis”)
  • MODEL_API_URL: URL for the model API (default: “http://localhost:11434/api”)
  • MODEL_API_KEY: API key for the model service (optional)
  • MODEL_NAME: Name of the model to use (default: “llama3.2”)

Running the Application

The server supports multiple modes:

# Default: Run as SSE server with Ktor plugin on port 3001
./gradlew run

# Run with standard input/output
./gradlew run --args="--stdio"

# Run as SSE server with Ktor plugin on custom port
./gradlew run --args="--sse-server-ktor 3002"

# Run as SSE server with plain configuration
./gradlew run --args="--sse-server 3002"

# With custom environment variables:
SERVER_PORT=3002 MODEL_NAME=mistral ./gradlew run

Model Context Protocol

This server implements the Model Context Protocol (MCP) and provides the following tool:

  • analyze-repository Analyzes GitHub repositories to provide code insights and structure summary.

Required parameters:

Optional parameters:

  • branch: Branch to analyze (default: main)

Project Structure

  • Main.kt: Application entry point
  • config/: Configuration classes
    • AppConfig.kt: Immutable configuration data class
  • server/: MCP server implementation
    • Server.kt: Functional MCP server with multiple run modes
  • service/: Core services for repository analysis
    • GitService.kt: Handles repository cloning
    • CodeAnalyzer.kt: Analyzes code structure
    • ModelContextService.kt: Generates insights using AI models
    • RepositoryAnalysisService.kt: Coordinates the analysis process

All services are implemented as functional data classes with explicit dependency injection.

License

This project is open source and available under the MIT License.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers