npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codesearch-mcp

v0.0.16-alpha

Published

Local semantic codebase search via MCP — indexes projects into pgvector, exposes search to Claude

Readme

codesearch-mcp

Semantic codebase search for Claude. Indexes your local projects into a PostgreSQL vector database and exposes search via the Model Context Protocol (MCP).

Ask Claude things like "where is the payment retry logic?" or "show me how auth tokens are validated" — across all your projects at once.

Alpha — works well locally, API may change before 1.0.

See CHANGELOG.md for version history.

How it works

  1. rag-index scans your projects, chunks source files, embeds them with bge-m3 via Ollama, and stores vectors in PostgreSQL
  2. rag-mcp exposes an MCP server — Claude calls it automatically when you ask about code
  3. Incremental — only changed files are re-indexed on subsequent runs

Stack: TypeScript · TypeORM · PostgreSQL + pgvector · Ollama (bge-m3) · LangChain text splitters · ts-morph

Requirements

  • Node.js 18+
  • Docker (for local DB + Ollama) — or bring your own PostgreSQL with pgvector + Ollama

Installation

npm install -g codesearch-mcp

Setup

rag-setup

Walks you through:

  • Local Docker — copies docker-compose.yml, starts PostgreSQL + Ollama, pulls bge-m3 automatically
  • Remote DB — enter connection details for Supabase, Railway, or self-hosted; connection is verified before saving
  • Logging — choose log level and directory (defaults: error level, ~/.config/codesearch-mcp/logs/)

Config is saved to ~/.config/codesearch-mcp/.env.

Index your projects

rag-index /home/user/Projects

On first run you will be prompted to select which projects to index. Selections are saved in .ragprojects / .ragskip at the workspace root.

rag-index /path --select          # re-run project selection
rag-index /path --reindex         # force re-embed all files (use after model change)
rag-index /path --select --reindex

Register with Claude Code

claude mcp add codesearch-mcp -s user -- rag-mcp

Then ask Claude anything about your code — it will use the tools below automatically.

MCP Tools

| Tool | Description | |------|-------------| | search_codebase | Semantic search across all indexed projects | | list_projects | List projects with metadata and chunk counts | | find_symbol | Find a function, class, or type by exact name — faster than semantic search | | list_files | Browse the directory tree of a project | | read_file | Read a complete file by absolute path | | read_file_range | Read a specific line range from an indexed file | | get_dependencies | Show what files a given file imports | | get_dependents | Show which files import a given file |

Project metadata

Add .ragmeta.json to a project root to enrich list_projects and generate a visual dependency graph:

{
  "description": "Main API server",
  "stack": "NestJS, GraphQL, PostgreSQL",
  "relations": {
    "consumed_by": ["crm-frontend"],
    "consumes": ["billing-service", "auth-service"]
  }
}

After each indexing run an interactive project-graph.html is written to the workspace root.

Excluding files

Create .ragignore in a project root — same syntax as .gitignore:

src/gql/graphql.ts
**/__snapshots__/**
src/generated/

Logging

Logs are written to ~/.config/codesearch-mcp/logs/ by default (separate subdirectories for indexer and MCP). Only errors are logged unless configured otherwise.

# Read logs
tail -f ~/.config/codesearch-mcp/logs/indexer/current.log
npx pino-pretty < ~/.config/codesearch-mcp/logs/indexer/current.log

# Detailed indexing diagnostics (timing per file: deps / embed / db)
LOG_LEVEL=debug rag-index /path/to/workspace

# Disable file logging
LOG_DIR=false rag-index /path/to/workspace

Environment variables

All set by rag-setup. Override any of them in ~/.config/codesearch-mcp/.env.

| Variable | Default | Description | |----------|---------|-------------| | DB_HOST | — | PostgreSQL host | | DB_PORT | 5433 | PostgreSQL port | | DB_USER | — | PostgreSQL user | | DB_PASS | — | PostgreSQL password | | DB_NAME | rag_<os-username> | Database name — auto-created on first run | | WORKSPACE_ROOT | — | Root of your projects directory | | OLLAMA_HOST | http://localhost:11434 | Ollama API URL | | OLLAMA_MODEL | bge-m3 | Embedding model | | SIMILARITY_THRESHOLD | 0.6 | Max cosine distance — raise if search returns nothing | | AUTO_TRANSLATE | false | Translate non-English queries to English before embedding | | TRANSLATE_MODEL | llama3.2 | Ollama model for translation (requires ollama pull llama3.2) | | LOG_LEVEL | error | Log level written to file: error | warn | info | debug | | LOG_DIR | ~/.config/codesearch-mcp/logs | Base log directory, or false to disable |

License

MIT