kaleido34/Code-Analysis-Mcp
If you are the rightful owner of Code-Analysis-Mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Model Context Protocol (MCP) server provides AI assistants with advanced code analysis capabilities, demonstrating core computer science concepts and modern software engineering practices.
Code Analysis MCP Server
Project Overview
A Model Context Protocol (MCP) server that provides AI assistants with powerful code analysis capabilities. Perfect for demonstrating advanced software engineering concepts while keeping the architecture clean and understandable.
What This Project Demonstrates
Core CS Concepts:
- Abstract Syntax Trees (AST) - Parse and analyze code structure
- Static Code Analysis - Find bugs, complexity, patterns
- API Design - Clean, type-safe interfaces
- Protocol Implementation - JSON-RPC communication
- File System Operations - Recursive directory traversal
- Data Structures - Trees, graphs, maps for code representation
- Algorithm Design - Pattern matching, complexity calculation
Software Engineering Practices:
- TypeScript Development - Type safety and modern JavaScript
- Error Handling - Robust error management and logging
- Schema Validation - Runtime type checking with Zod
- Modular Architecture - Separation of concerns
- Documentation - Self-documenting code and APIs
- Testing Strategy - Unit and integration testing
Architecture
Code Analysis MCP Server
āāā Resources (Read-only data)
ā āāā codebase://project/structure # File tree and project info
ā āāā docs://generated/readme # Auto-generated README
ā āāā (dynamic) # Other future resources
āāā Tools (AI-callable functions)
ā āāā analyze_path() # Analyze *any* file OR directory
ā āāā generate_documentation() # Generate docs from code
āāā Prompts (templates)
āāā code_review # Code-review helper
Learning Outcomes
- MCP Protocol - Deep understanding of client-server communication
- Code Analysis - How tools like ESLint, SonarQube work internally
- AST Manipulation - Foundation for building dev tools
- Type Systems - Advanced TypeScript patterns
- API Design - Creating clean, extensible interfaces
- Error Handling - Production-ready error management
- Software Architecture - Scalable, maintainable code organization
"How would you scale this system?"
- Git Integration Server - Analyze commit history, PR diffs
- CI/CD Integration Server - Build metrics, test coverage analysis
- Documentation Server - Auto-generate docs from code
- Security Analysis Server - Vulnerability scanning, dependency analysis
- Performance Monitoring Server - Runtime analysis, profiling data
- Team Analytics Server - Code ownership, productivity metrics
- Directly Relevant - Every company needs code analysis
- Advanced Concepts - Shows deep CS understanding
- Production Ready - Proper error handling, logging, validation
- Extensible Design - Clear path for adding features
- Modern Tech Stack - TypeScript, modern tooling
- Clear Documentation - Shows communication skills
Technologies Used
- TypeScript - Type-safe development
- Node.js - Runtime environment
- MCP SDK - Protocol implementation
- AST Parsers - Code structure analysis
- Zod - Runtime schema validation
- Winston - Professional logging
- Jest - Testing framework
@code-analysis {"path": "C:\Users\pasha\Desktop\N2N"}
š§ Usage
- Install & build
npm install npm run build
- Start the server (compiled)
npm start # or: node dist/server.js
- Connect Claude Desktop
Update (or create)
claude_desktop_config.json
:{ "mcpServers": { "code-analysis": { "command": "node", "args": ["--no-warnings", "dist/server.js"], "cwd": "C:\\Users\\<you>\\Desktop\\Mcp" } } }
- Call the tool
⢠If@code-analysis {"path": "C:\\Users\\<you>\\Desktop\\N2N"}
path
points to a file ā returns JSON with LOC & cyclomatic complexity. ⢠If it points to a directory ā returns a full project-structure report (files, languages, LOC, etc.).
Tool Input / Output
Tool | Input JSON | Returns |
---|---|---|
analyze_path | { "path": "<absolute-or-relative-path>" } | Plain-text JSON summary (file or directory) |
generate_documentation | { "projectName": "MyApp", "format": "markdown" } | Markdown or JSON docs |
Debugging Tips
⢠Server logs ā standard error (won't corrupt MCP JSON).
⢠If Cursor shows Unexpected token
errors, make sure you're running dist/server.js (not ts-node).
⢠Re-build after any TypeScript edits: npm run build
.
⢠Use LOG_LEVEL=debug node dist/server.js
to get verbose output.