Code Analysis MCP server

Integrates code analysis with scraping capabilities to enable code review, static analysis, and automated refactoring suggestions for development teams.
Back to servers
Provider
Sai Prashanth Soundararaj
Release date
Feb 08, 2025
Language
Python
Stats
15 stars

The Code Analysis MCP Server enables AI models to understand and analyze codebases through natural language conversations. This lightweight tool lets you explore your code, extract insights, and trace data flows using Claude's AI capabilities.

Installation and Setup

Prerequisites

Installation Steps

  1. Clone the repository:

    git clone https://github.com/saiprashanths/code-analysis-mcp.git
    cd code-analysis-mcp
    
  2. Configure the server in Claude Desktop's configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    Add the following configuration:

    {
      "mcpServers": {
        "code-analysis": {
          "command": "uv",
          "args": [
            "--directory",
            "/PATH/TO/YOUR/REPO",
            "run",
            "code_analysis.py"
          ]
        }
      }
    }
    

    (Replace /PATH/TO/YOUR/REPO with the actual path to your code repository)

  3. Restart Claude Desktop to apply the changes

Verifying Setup

After installation, verify that everything is working correctly:

  1. In Claude Desktop, click the tools icon to confirm that "code-analysis" tools are displayed
  2. Click the integrations button to verify that the "analyze_code_repository" prompt appears

Using the Code Analysis Server

Getting Started

Begin by clicking on the "analyze_code_repository" prompt in Claude Desktop. This will guide you through initializing the repository and start analyzing.

Available Tools

Initialize Repository

initialize_repository("/path/to/repo")
# Output: Successfully initialized code repository at: /path/to/repo

Get Repository Information

get_repo_info()
# Output:
# Code Repository Information:
# Path: /path/to/repo
# Exists: True
# Is Directory: True
# Found .gitignore file

Explore Repository Structure

get_repo_structure(depth=2)
# Output:
# 📁 src/
#   📁 api/
#     📄 routes.py
#     📄 models.py
#   📁 utils/
#     📄 helpers.py
#   📄 main.py

Read File Contents

read_file("src/api/models.py")
# Output:
# File: src/api/models.py
# Language: python
# Size: 2.3 KB
# 
# [File contents...]

Example Conversation

You can ask natural language questions about your codebase:

You: "How does the transaction processing work in this system?"

Claude: [Provides an analysis of transaction processing components]

You: "What are the key database tables involved?"

Claude: [Lists and describes the main database tables used in transactions]

Technical Limitations

  • Default scanning depth: 3 levels
  • Maximum file size: 1MB
  • Maximum lines per file: 1000
  • Ignores paths listed in .gitignore
  • Local file system access only

The tool is a lightweight alternative to more sophisticated code analysis tools. It offers basic analysis capabilities good for high-level code understanding while being cost-effective (uses your existing Claude Pro subscription) and simple to set up.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later