Skip to content

MCP Server

Let AI agents analyze your codebase. AST Metrics includes a built-in Model Context Protocol (MCP) server that exposes all metrics through a standard interface.

How it works

The ast-metrics mcp command starts an MCP server over stdio. Your AI client launches it automatically: you never run it manually.

Available tools

analyze_project

Project-level overview: LOC, complexity, maintainability index.

get_file_metrics

Detailed metrics for a specific file.

find_complex_code

Locate high-complexity hotspots in the codebase.

find_risky_code

Find code with high risk scores (complexity × churn).

get_coupling

Analyze coupling between components.

get_dependencies

List dependency relationships across files.

get_communities

The communities the code forms on the dependency graph, with the shared kernel, the cycles, the findings and the actions to take first.

get_test_quality

Evaluate test coverage and quality.

list_components

Inventory of all classes, functions, and components.

Setup

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "ast-metrics": {
      "command": "ast-metrics",
      "args": ["mcp", "."]
    }
  }
}

Add to your .cursor/mcp.json:

{
  "mcpServers": {
    "ast-metrics": {
      "command": "ast-metrics",
      "args": ["mcp", "."]
    }
  }
}

Any MCP-compatible client can use AST Metrics. The server command is:

ast-metrics mcp

Transport: stdio. Refer to your client's documentation for the configuration format.