Skip to content

Heyosseus/code-intel-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Intelligence MCP Server

A Model Context Protocol (MCP) server that provides code intelligence tools for analyzing and exploring codebases.

Features

This MCP server provides 4 powerful tools:

  1. read_file - Read the contents of any file in your codebase
  2. search - Search for text across multiple files
  3. tree - Display the project file structure
  4. analyze_codebase - Analyze code complexity and identify large files

Installation

First, install dependencies:

npm install

Usage

Option 1: Use with Claude Desktop

  1. Build the server:

    npm run build
  2. Configure Claude Desktop - Add this to your Claude Desktop config file:

    On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json On Windows: %APPDATA%\Claude\claude_desktop_config.json On 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 cwd to the directory you want to analyze!

  3. Restart Claude Desktop

  4. 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"

Option 2: Use with MCP Inspector (Web UI)

The MCP Inspector provides a web-based interface to test and interact with your MCP server.

  1. Build the server:

    npm run build
  2. Navigate to the codebase you want to analyze:

    cd /path/to/your/codebase
  3. Start the MCP Inspector:

    npx @modelcontextprotocol/inspector /usr/bin/node /home/rati/code-intel-mcp/dist/index.js
  4. Open the browser - The inspector will display a URL (usually http://localhost:5173)

  5. 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 tree to see your project structure
  • Use analyze_codebase to get statistics
  • Try search to find specific code patterns
  • Use read_file to view file contents

Tip: Always run the inspector from the directory you want to analyze - this sets the correct working directory for all tools.

Option 3: Use with Other MCP Clients

Connect any MCP-compatible client to this server:

  • Cline (VS Code extension)
  • Zed Editor
  • Continue.dev
  • Any custom MCP client using stdio transport

Option 4: Development/Testing

Run the server directly (useful for development):

npm run dev

Tool Reference

read_file

Reads and returns the contents of a file.

Parameters:

  • filePath (string, required) - Relative or absolute path to the file

Example:

Read file: src/index.ts

search

Searches for text across files in your codebase.

Parameters:

  • query (string, required) - Text to search for
  • extensions (string[], optional) - File extensions to search (e.g., ["js", "ts"])

Example:

Search for "async function" in TypeScript files

tree

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

analyze_codebase

Analyzes the codebase and reports statistics.

Returns:

  • Total number of files
  • Total lines of code
  • Large files (>300 lines)

Example:

Analyze the codebase complexity

Configuration

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 the exts default value
  • src/tools/analyze.ts - Change the glob pattern

Project Structure

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

Tips

  1. Working Directory Matters: The server operates relative to its cwd. Set this correctly when configuring Claude Desktop.

  2. Performance: For large codebases, the search and analyze_codebase tools may take a few seconds.

  3. File Patterns: Tools automatically ignore node_modules, vendor, and .git directories.

  4. Multiple Projects: You can configure multiple instances of this server in Claude Desktop, each with different cwd settings for different projects.

Troubleshooting

"Cannot find module" errors:

  • Run npm run build to 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 cwd in your config points to the correct directory
  • Use absolute paths in the config file

License

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors