Code Analysis MCP Server
Provides regex-based code searching and structural analysis for C and C++ source and header files.
Supports searching for patterns and analyzing the code structure and definitions of JavaScript and JSX files.
Connects with OpenAI's API to facilitate AI-powered code updates and support for thinking-based models like o1.
Enables deep code analysis, structure identification, and symbol definition searching for Python source files.
Facilitates file operations and structural code analysis for Ruby source files.
Supports finding symbol definitions and analyzing code structures within Rust programming projects.
Allows for the analysis of TypeScript code structures and searching for symbol definitions within TS and TSX files.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Code Analysis MCP Server
A modular MCP (Model Context Protocol) server for code analysis with file operations, code search, and structure analysis capabilities.
Features
š File Operations
read_file: Read contents of any code file
list_files: List files in directories with pattern matching
file_info: Get detailed file information (size, type, line count)
š Code Search
search_code: Search for patterns in code using regex
find_definition: Find symbol definitions (functions, classes, variables)
š Code Analysis
analyze_structure: Analyze code structure (imports, classes, functions)
Related MCP server: Axon.MCP.Server
Installation
# Clone the repository
git clone https://github.com/yourusername/code-mcp.git
cd code-mcp
# Create virtual environment
python -m venv venv
# Activate environment
source venv/bin/activate # On Unix/macOS
venv\Scripts\activate # On Windows
# Install dependencies
pip install -r requirements.txtUsage
1. With Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"code-analyzer": {
"command": "python",
"args": ["/absolute/path/to/code-mcp/server.py"]
}
}
}Then restart Claude Desktop.
2. With Continue.dev (VS Code)
Add to your Continue configuration:
{
"models": [...],
"mcpServers": {
"code-analyzer": {
"command": "python",
"args": ["/absolute/path/to/code-mcp/server.py"]
}
}
}3. With Other MCP Clients
Any MCP-compatible client can use this server by pointing to the server.py file.
Available Tools
š read_file
Read the contents of a file.
{
"tool": "read_file",
"arguments": {
"path": "src/main.py",
"encoding": "utf-8" // optional, default: utf-8
}
}š list_files
List files in a directory with optional pattern matching.
{
"tool": "list_files",
"arguments": {
"directory": "./src", // optional, default: current dir
"pattern": "*.py", // optional, default: *
"recursive": true // optional, default: false
}
}ā¹ļø file_info
Get detailed information about a file.
{
"tool": "file_info",
"arguments": {
"path": "src/main.py"
}
}š search_code
Search for patterns in code files using regex.
{
"tool": "search_code",
"arguments": {
"pattern": "def.*test", // regex pattern
"directory": "./src", // optional
"file_pattern": "*.py", // optional
"case_sensitive": false // optional, default: true
}
}šÆ find_definition
Find where a symbol is defined.
{
"tool": "find_definition",
"arguments": {
"symbol": "MyClass",
"directory": "./src", // optional
"language": "python" // optional: python, javascript
}
}šļø analyze_structure
Analyze the structure of a code file.
{
"tool": "analyze_structure",
"arguments": {
"path": "src/main.py",
"include_docstrings": true // optional, default: false
}
}š¤ update_with_architecture
Compare old and new architecture versions and intelligently update the new file.
{
"tool": "update_with_architecture",
"arguments": {
"old_file": "src/legacy/module.py", // Reference file (old architecture)
"new_file": "src/modern/module.py", // Target file (will be updated)
"backup": true // optional, default: true
}
}AI Configuration
To use the AI-powered tools, you need to configure your API keys:
Copy
.env.exampleto.env:cp .env.example .envEdit
.envand add your API keys:AI_PROVIDER=openai OPENAI_API_KEY=your-openai-api-key # or AI_PROVIDER=anthropic ANTHROPIC_API_KEY=your-anthropic-api-key
Thinking Models Support
The tool automatically handles "thinking" models (like o1, o1-preview) that include reasoning in their responses:
Thinking sections are automatically removed
Only the actual code is extracted
Supports various thinking formats:
<think>,[thinking], etc.
Install AI dependencies:
pip install openai anthropicTest LLM connectivity:
./test_llm.sh # or python tests/test_llm.py
Examples
In Claude Desktop
After configuring, you can ask Claude:
"Read the file src/main.py"
"Search for all functions that contain 'test' in the src directory"
"Find where the class 'UserModel' is defined"
"Analyze the structure of app.py"
"List all Python files in the project"
Programmatic Usage
# Example of calling tools programmatically
import asyncio
from mcp import Client
async def main():
client = Client()
# Read a file
result = await client.call_tool("read_file", {
"path": "src/main.py"
})
# Search for patterns
result = await client.call_tool("search_code", {
"pattern": "TODO|FIXME",
"directory": "./",
"recursive": True
})
# Analyze structure
result = await client.call_tool("analyze_structure", {
"path": "src/main.py",
"include_docstrings": True
})
asyncio.run(main())Architecture
The server follows a modular architecture:
āāā server.py # Main MCP server
āāā tools/ # Tool definitions
ā āāā file_tools.py # File operations
ā āāā code_tools.py # Code analysis tools
āāā handlers/ # Request handlers
ā āāā file_handler.py
ā āāā search_handler.py
ā āāā analyze_handler.py
āāā core/ # Core services
āāā file_system.py # File system operations
āāā code_parser.py # Code parsing logicSupported Languages
Python (.py)
JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
Java (.java)
C/C++ (.c, .cpp, .h)
Go (.go)
Rust (.rs)
Ruby (.rb)
And more...
Security
File access is restricted to prevent directory traversal
Large files are handled efficiently with streaming
Search results are limited to prevent memory issues
Contributing
Feel free to submit issues and enhancement requests!
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
One MCP server for the services your AI needs: memory, files, Microsoft 365, kanban and more.
Nifty's MCP server ā exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that gives your AI access to the source code and docs of all public github repos
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that implements Claude Code-like functionality, allowing the AI to analyze codebases, modify files, execute commands, and manage projects through direct file system interactions.15305MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that transforms codebases into intelligent, queryable knowledge bases, enabling AI assistants to perform semantic search, explore architecture, and analyze code relationships.166-
- AlicenseNot gradedqualityBmaintenanceA production-ready MCP server that enables AI assistants to intelligently understand, analyze, edit, navigate, and review software projects with multi-workspace support, Git integration, and semantic search.1MIT
- AlicenseBqualityCmaintenanceA comprehensive MCP server for developers providing file operations, shell execution, git integration, and smart caching to enhance AI-assisted development.1115 npmMIT