CodeSense MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add codesense-mcp -- uvx codesense-mcp
README.md

Semantic code intelligence for Claude to search, navigate, and analyze code.

🧠 CodeSense MCP

Semantic code intelligence for Claude β€” search, understand, and analyze any codebase using plain English.


πŸ€” The Problem

You open a new codebase and ask Claude:

"Where is the user authentication handled?"

Claude has no idea. It hasn't seen your code.

You could paste files manually β€” but that's slow, hits context limits, and doesn't scale.

CodeSense MCP solves this. Point it at your project once, and Claude can search, navigate and reason about your entire codebase without you doing anything else.


✨ What It Does

Tool What you can ask Claude
index_codebase "Index my project at ~/projects/myapp"
search_code "Find where JWT tokens are validated"
explain_architecture "Give me an overview of how this project is structured"
find_bugs "Scan for common bug patterns and hardcoded secrets"
find_dead_code "Find functions that are defined but never used"
suggest_refactor "What should I refactor in src/utils.py?"
get_file_summary "Tell me about the models/user.py file"
list_indexed_files "List all Python files in the project"

πŸš€ Quick Start

1. Install

# Lightweight (keyword search, no extra deps)
pip install codesense-mcp

# Full semantic search (recommended β€” uses local embeddings, no API key needed)
pip install "codesense-mcp[semantic]"

2. Add to Claude Desktop

Open your Claude Desktop config:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add this:

{
  "mcpServers": {
    "codesense": {
      "command": "uvx",
      "args": ["codesense-mcp"]
    }
  }
}

Restart Claude Desktop. That's it. βœ…


πŸ’¬ Example Conversations

Find authentication logic:

You: "Search my codebase for where passwords are hashed" Claude: Searches and returns the exact functions with file paths and line context.

Understand a new project:

You: "Explain the architecture of ~/projects/django-app" Claude: Returns a structured breakdown of modules, entry points, key classes, and language distribution.

Security audit:

You: "Scan for hardcoded secrets and empty except blocks" Claude: Lists every file and line with potential issues.

Refactor guidance:

You: "What should I refactor in services/payment.py?" Claude: Flags long functions, deep nesting, magic numbers, and missing docstrings with line numbers.


πŸ—οΈ Architecture

codesense-mcp/
β”œβ”€β”€ codesense_mcp/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── server.py          ← All tools live here (FastMCP)
β”œβ”€β”€ tests/
β”‚   └── test_server.py
β”œβ”€β”€ pyproject.toml
└── README.md

Search modes:

Mode When How
🧠 Semantic [semantic] installed HuggingFace all-MiniLM-L6-v2 + ChromaDB (local, no API key)
πŸ” Keyword Fallback Token-overlap scoring across indexed chunks

Supported languages: Python Β· JavaScript Β· TypeScript Β· PHP Β· Ruby Β· Go Β· Java Β· C# Β· C/C++ Β· Rust Β· Swift


πŸ” Bug Detection Patterns

CodeSense scans for:

  • πŸ”΄ Hardcoded secrets / credentials
  • ⚠️ Bare except: clauses
  • ⚠️ Mutable default arguments
  • ⚠️ Empty except blocks
  • 🟑 Leftover print() debug statements
  • πŸ“ TODO / FIXME / HACK comments
  • πŸ’‘ Missing type annotations

πŸ”§ Refactor Analysis

For each file, CodeSense checks:

  • πŸ“ Functions longer than 50 lines
  • πŸͺ† Nesting depth greater than 4 levels
  • πŸ”’ Magic numbers (unnamed constants)
  • πŸ“¦ Files larger than 300 lines
  • ♻️ Duplicated code patterns
  • πŸ“ Missing docstrings

πŸ› οΈ Development

git clone https://github.com/attaelahi/codesense-mcp
cd codesense-mcp
uv venv && source .venv/bin/activate
uv pip install -e ".[semantic]"

# Test the server directly
python -m codesense_mcp.server

# Run with MCP Inspector
npx @modelcontextprotocol/inspector python -m codesense_mcp.server

πŸ—ΊοΈ Roadmap

  • Git diff analysis β€” "What changed in the last 10 commits?"
  • Dependency graph visualization
  • Cross-file call graph tracing
  • Laravel/PHP-specific analysis (routes, controllers, models)
  • CI/CD integration (GitHub Actions)
  • Persistent index (survive restarts)
  • Remote codebase support (GitHub URLs)

🀝 Contributing

PRs welcome! See CONTRIBUTING.md.

If you find this useful, a ⭐ star goes a long way.


πŸ“„ License

MIT Β© Atta Elahi


πŸ™ Built Wi

Tools (8)

index_codebaseIndexes a project directory for search and analysis.
search_codeSearches the codebase for specific logic or patterns.
explain_architectureProvides an overview of the project structure.
find_bugsScans for common bug patterns and hardcoded secrets.
find_dead_codeIdentifies functions that are defined but never used.
suggest_refactorProvides refactoring suggestions for a specific file.
get_file_summaryProvides a summary of a specific file.
list_indexed_filesLists all files currently indexed in the project.

Configuration

claude_desktop_config.json
{"mcpServers": {"codesense": {"command": "uvx", "args": ["codesense-mcp"]}}}

Try it

β†’Index my project at ~/projects/myapp
β†’Find where JWT tokens are validated in the codebase
β†’Give me an overview of how this project is structured
β†’Scan for common bug patterns and hardcoded secrets
β†’What should I refactor in src/utils.py?

Frequently Asked Questions

What are the key features of CodeSense MCP?

Local semantic search using HuggingFace embeddings and ChromaDB. Keyword-based fallback search for token-overlap scoring. Automated bug detection for secrets, empty except blocks, and debug statements. Refactor analysis for code complexity, nesting, and missing docstrings. Supports multiple languages including Python, JS, TS, PHP, Go, and Rust.

What can I use CodeSense MCP for?

Quickly finding specific authentication or business logic in large, unfamiliar codebases. Performing automated security audits to find hardcoded credentials or dangerous code patterns. Generating architectural overviews to onboard new developers to a project. Identifying technical debt and refactoring opportunities in legacy files.

How do I install CodeSense MCP?

Install CodeSense MCP by running: pip install "codesense-mcp[semantic]"

What MCP clients work with CodeSense MCP?

CodeSense MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep CodeSense MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare