Code Analysis MCP server

Integrates code analysis using a Neo4j graph database to enable structural insights, quality metrics, and natural language querying of codebases.
Back to servers
Setup instructions
Provider
David VC
Release date
Dec 22, 2024
Language
Java
Stats
12 stars

This MCP server plugin empowers AI assistants like Claude and Cline with comprehensive code analysis capabilities. By connecting to a Neo4j graph database, it allows AI systems to analyze code structure, calculate quality metrics, extract documentation, and answer natural language questions about codebases.

Installation Requirements

To run the Code Analysis MCP Plugin, you'll need:

  • Neo4j graph database
  • Python 3.8 or higher
  • MCP server

Setup Instructions

1. Install Neo4j

First, you need to install and set up the Neo4j database:

# Download and install Neo4j from the official website
# https://neo4j.com/download/

# Or using Docker
docker run \
    --publish=7474:7474 --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    neo4j:latest

2. Install the MCP Plugin

# Clone the repository
git clone https://github.com/your-username/code-analysis-mcp-plugin.git
cd code-analysis-mcp-plugin

# Install dependencies
pip install -r requirements.txt

# Configure the plugin
cp config.example.json config.json

3. Configure the Plugin

Edit the config.json file to include your Neo4j credentials and other settings:

{
  "neo4j": {
    "uri": "bolt://localhost:7687",
    "user": "neo4j",
    "password": "your-password"
  },
  "mcp": {
    "port": 8080,
    "host": "0.0.0.0"
  }
}

Usage Guide

Starting the MCP Server

To start the MCP server with the Code Analysis plugin:

python mcp_server.py --config config.json

Analyzing a Codebase

To analyze a codebase and load it into the database:

python analyze_codebase.py --path /path/to/your/codebase --language python,javascript

Connecting an AI Assistant

Configure your AI assistant (Claude or Cline) to connect to the MCP server:

MCP Server URL: http://your-server-ip:8080
Plugin Name: code-analysis

Example Queries

Once connected, your AI assistant can answer sophisticated questions about your codebase:

  • Code Structure Analysis: "Summarize the key features and functionality of this codebase"
  • Architecture Overview: "Write a high-level design document for this codebase"
  • Component Analysis: "Write a summary of the key components, with a paragraph for each"
  • Quality Assessment: "What are the most problematic files according to SOLID principles?"

Advanced Configuration

Language Support

Specify which languages to analyze:

python analyze_codebase.py --path /path/to/codebase --language python,javascript,java,typescript

Metrics Calculation

Enable specific code quality metrics:

python analyze_codebase.py --path /path/to/codebase --metrics complexity,duplication,coverage

Troubleshooting

Common Issues

  • Database Connection Errors: Ensure Neo4j is running and credentials are correct
  • Parser Errors: Check that the specified languages are supported
  • Memory Issues: For large codebases, increase Neo4j and JVM memory allocation

Logs

Check the logs for detailed error information:

tail -f logs/mcp_server.log

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "code-analysis" '{"command":"npx","args":["-y","code-mcp"]}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "code-analysis": {
            "command": "npx",
            "args": [
                "-y",
                "code-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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

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

2. Add this to your configuration file:

{
    "mcpServers": {
        "code-analysis": {
            "command": "npx",
            "args": [
                "-y",
                "code-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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