A Model Context Protocol (MCP) server that provides code intelligence tools for analyzing and exploring codebases.
This MCP server provides 4 powerful tools:
read_file- Read the contents of any file in your codebasesearch- Search for text across multiple filestree- Display the project file structureanalyze_codebase- Analyze code complexity and identify large files
First, install dependencies:
npm install-
Build the server:
npm run build
-
Configure Claude Desktop - Add this to your Claude Desktop config file:
On macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonOn Windows:%APPDATA%\Claude\claude_desktop_config.jsonOn Linux:~/.config/Claude/claude_desktop_config.json{ "mcpServers": { "code-intel": { "command": "node", "args": ["/home/rati/code-intel-mcp/dist/index.js"], "cwd": "/path/to/your/codebase" } } }Important: Change
cwdto the directory you want to analyze! -
Restart Claude Desktop
-
Use the tools - You can now ask Claude things like:
- "Read the file src/index.ts"
- "Search for 'function' in all TypeScript files"
- "Show me the project structure"
- "Analyze the codebase complexity"
The MCP Inspector provides a web-based interface to test and interact with your MCP server.
-
Build the server:
npm run build
-
Navigate to the codebase you want to analyze:
cd /path/to/your/codebase -
Start the MCP Inspector:
npx @modelcontextprotocol/inspector /usr/bin/node /home/rati/code-intel-mcp/dist/index.js
-
Open the browser - The inspector will display a URL (usually
http://localhost:5173) -
In the browser:
- Click the "Connect" button
- You'll see 4 tools appear in the interface
- Click on any tool (e.g.,
tree,analyze_codebase) - Enter parameters if needed
- Click "Call Tool" to see results
Example workflow:
- Start with
treeto see your project structure - Use
analyze_codebaseto get statistics - Try
searchto find specific code patterns - Use
read_fileto view file contents
Tip: Always run the inspector from the directory you want to analyze - this sets the correct working directory for all tools.
Connect any MCP-compatible client to this server:
- Cline (VS Code extension)
- Zed Editor
- Continue.dev
- Any custom MCP client using stdio transport
Run the server directly (useful for development):
npm run devReads and returns the contents of a file.
Parameters:
filePath(string, required) - Relative or absolute path to the file
Example:
Read file: src/index.ts
Searches for text across files in your codebase.
Parameters:
query(string, required) - Text to search forextensions(string[], optional) - File extensions to search (e.g., ["js", "ts"])
Example:
Search for "async function" in TypeScript files
Lists the project file structure.
Parameters:
depth(number, optional, default: 4) - Maximum directory depth to traverse
Example:
Show me the file tree with depth 3
Analyzes the codebase and reports statistics.
Returns:
- Total number of files
- Total lines of code
- Large files (>300 lines)
Example:
Analyze the codebase complexity
By default, the tools search for common file types: .js, .ts, .php, .vue
You can modify the search patterns in:
src/tools/search.ts- Change theextsdefault valuesrc/tools/analyze.ts- Change the glob pattern
code-intel-mcp/
├── src/
│ ├── index.ts # Main server entry point
│ └── tools/
│ ├── analyze.ts # Codebase analysis tool
│ ├── readFile.ts # File reading tool
│ ├── search.ts # Text search tool
│ └── tree.ts # File tree tool
├── package.json
├── tsconfig.json
└── README.md
-
Working Directory Matters: The server operates relative to its
cwd. Set this correctly when configuring Claude Desktop. -
Performance: For large codebases, the
searchandanalyze_codebasetools may take a few seconds. -
File Patterns: Tools automatically ignore
node_modules,vendor, and.gitdirectories. -
Multiple Projects: You can configure multiple instances of this server in Claude Desktop, each with different
cwdsettings for different projects.
"Cannot find module" errors:
- Run
npm run buildto compile TypeScript to JavaScript - Make sure the path in Claude Desktop config points to
dist/index.js
Tools not showing up in Claude:
- Restart Claude Desktop after changing the config
- Check the Claude Desktop logs for errors
- Verify the config JSON syntax is valid
"ENOENT" file not found errors:
- Check that the
cwdin your config points to the correct directory - Use absolute paths in the config file
ISC