DependencyMCP Server

DependencyMCP Server

Analyzes codebases to generate dependency graphs and architectural insights across multiple programming languages, helping developers understand code structure and validate against architectural rules.

mkearl

Developer Tools
Version Control
Visit Server

README

DependencyMCP Server

A Model Context Protocol (MCP) server that analyzes codebases to generate dependency graphs and architectural insights. This server helps understand code structure, dependencies, and architectural patterns across multiple programming languages.

Features

  • Multi-Language Support: Analyzes dependencies in TypeScript, JavaScript, C#, Python, and more
  • Dependency Graph Generation: Creates detailed dependency graphs in JSON or DOT format
  • Architectural Analysis: Infers architectural layers and validates against rules
  • File Metadata: Extracts imports, exports, and other metadata from source files
  • Scoring System: Evaluates codebase against architectural rules and patterns

Installation

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Build the project:
npm run build

Configuration

Add to your MCP settings file (usually located at ~/.config/cline/mcp_settings.json or equivalent):

json { mcpServers: { \DependencyMCP: { \command: \node, \args: [\path/to/dependency-mcp/dist/index.js], \env: { \MAX_LINES_TO_READ: \1000, \CACHE_DIR: \path/to/dependency-mcp/.dependency-cache, \CACHE_TTL: \3600000 } } }

Environment Variables:

  • MAX_LINES_TO_READ: Maximum number of lines to read from each file (default: 1000)
  • CACHE_DIR: Directory to store dependency cache files (default: .dependency-cache)
  • CACHE_TTL: Cache time-to-live in milliseconds (default: 1 hour = 3600000)

Available Tools

analyze_dependencies

Analyzes dependencies in a codebase and generates a dependency graph.

const result = await client.callTool("DependencyMCP", "analyze_dependencies", {
  path: "/path/to/project",
  excludePatterns: ["node_modules", "dist"], // optional
  maxDepth: 10, // optional
  fileTypes: [".ts", ".js", ".cs"] // optional
});

get_dependency_graph

Gets the dependency graph for a codebase in JSON or DOT format.

const result = await client.callTool("DependencyMCP", "get_dependency_graph", {
  path: "/path/to/project",
  format: "dot" // or "json" (default)
});

get_file_metadata

Gets detailed metadata about a specific file.

const result = await client.callTool("DependencyMCP", "get_file_metadata", {
  path: "/path/to/file.ts"
});

get_architectural_score

Scores the codebase against architectural rules and patterns.

const result = await client.callTool("DependencyMCP", "get_architectural_score", {
  path: "/path/to/project",
  rules: [
    {
      pattern: "src/domain/**/*",
      allowed: ["src/domain/**/*"],
      forbidden: ["src/infrastructure/**/*"]
    }
  ]
});

Example Output

Dependency Graph (JSON)

{
  "src/index.ts": {
    "path": "src/index.ts",
    "imports": ["./utils", "./services/parser"],
    "exports": ["analyze", "generateGraph"],
    "namespaces": [],
    "architecturalLayer": "Infrastructure",
    "dependencies": ["src/utils.ts", "src/services/parser.ts"],
    "dependents": []
  }
}

Architectural Score

{
  "score": 85,
  "violations": [
    "src/domain/user.ts -> src/infrastructure/database.ts violates architectural rules"
  ],
  "details": "Score starts at 100 and deducts 5 points per violation"
}

Development

The server is built with TypeScript and uses:

  • Zod for schema validation
  • diff for file comparison
  • minimatch for glob pattern matching

Project Structure

dependency-mcp/
├── src/
│   └── index.mts    # Main server implementation
├── package.json
├── tsconfig.json
└── README.md

Adding Support for New Languages

To add support for a new programming language:

  1. Add file extensions to the default fileTypes array
  2. Implement language-specific regex patterns in parseFileImports and parseFileExports
  3. Add any language-specific architectural patterns to inferArchitecturalLayer

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Gitingest-MCP

Gitingest-MCP

An MCP server for gitingest. It allows MCP clients like Claude Desktop, Cursor, Cline etc to quickly extract information about Github repositories including repository summaries, project directory structure, file contents, etc

Featured
Local
Python
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript