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

rig-mcp-tools

v1.0.1

Published

Model Context Protocol server for intelligent code analysis and refactoring tools

Downloads

234

Readme

RIG MCP Tools

A Model Context Protocol (MCP) server providing intelligent code analysis, graph-based architecture insights, and file operations for AI assistants.

Overview

RIG MCP Tools combines three layers of intelligence:

  • Static analysis — A Repository Intelligence Graph (RIG) built from AST parsing (ts-morph, tree-sitter) stored in SQLite, enabling graph queries with zero LLM cost.
  • Semantic search — Embedding-based symbol retrieval using a local model (nomic-embed-text or compatible). Embeddings are cached in SQLite after the first run. Returns precise code snippets instead of whole files — minimizes token usage.
  • LLM-powered tools — A subset of tools that call a configurable OpenAI-compatible API for natural language reasoning over code.

Installation

From npm

npx rig-mcp-tools

From source

git clone <repository-url>
cd rig-mcp-tools
npm install
npm run build

Docker

docker build -t rig-mcp-tools .
docker run rig-mcp-tools

Configuration

MCP client (Claude Desktop, Cursor, etc.)

{
  "mcpServers": {
    "rig-tools": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "env": {
        "WORKSPACE_PATH": "/your/project",
        "GLM_API_URL": "http://localhost:1234/v1/chat/completions",
        "GLM_MODEL": "qwen2.5-coder-7b-instruct-mlx@8bit",
        "EMBEDDING_API_URL": "http://localhost:1234/v1/embeddings",
        "EMBEDDING_MODEL": "text-embedding-nomic-embed-text-v1.5"
      }
    }
  }
}

Environment variables

| Variable | Default | Description | |---|---|---| | WORKSPACE_PATH | /workspace | Root workspace path | | GLM_API_URL | http://localhost:1234/v1/chat/completions | LLM API endpoint (OpenAI-compatible) | | GLM_MODEL | qwen2.5-coder-7b-instruct-mlx@8bit | Model for LLM-powered tools | | EMBEDDING_API_URL | http://localhost:1234/v1/embeddings | Embeddings API endpoint | | EMBEDDING_MODEL | text-embedding-nomic-embed-text-v1.5 | Model for semantic search |

LLM and embedding tools are optional — all static analysis tools work without any API.

Available Tools

RIG — Graph Analysis

These tools index the repository into a SQLite graph via AST parsing and query it without calling any LLM.

get_smart_context

Retrieve the most relevant files and symbols for a query using graph centrality and keyword scoring.

{ "rootPath": "/project", "text": "authentication flow" }

get_architectural_metrics

Executive summary of repository architecture: core hubs, entry points, and stable foundations ranked by graph centrality.

{ "rootPath": "/project" }

graph_analyzer

Component-level complexity analysis with hotspot detection and refactor recommendations.

{ "rootPath": "/project" }

generate_call_graph

Generate call graphs or dependency diagrams between components, files, or symbols.

{
  "rootPath": "/project",
  "level": "component",
  "format": "mermaid",
  "maxDepth": 5
}

level: "component" | "file" | "symbol"
format: "mermaid" | "dot" | "json"

generate_diagram

Generate C4 architecture diagrams, sequence diagrams, call graphs, or dependency visualizations from the RIG.

{
  "rootPath": "/project",
  "type": "c4-container",
  "format": "mermaid",
  "focus": "auth",
  "maxDepth": 3,
  "style": "default"
}

type: "c4-context" | "c4-container" | "c4-component" | "sequence" | "call-graph" | "dependency-graph"
format: "mermaid" | "plantuml" | "dot"
style: "default" | "compact" | "detailed"

extract_method

Surgically extract a function or class from a source file to a target file using RIG symbol coordinates.

{
  "rootPath": "/project",
  "sourceFile": "src/utils/helpers.ts",
  "symbolName": "formatDate",
  "targetFile": "src/utils/date.ts"
}

File Operations

Pure filesystem tools, no graph or LLM required.

read_files

Read content of up to 10 files in a single call.

{ "files": ["src/index.ts", "src/config.ts"] }

write_code_unit

Write or overwrite a file with specific content. Creates parent directories as needed.

{ "path": "src/utils/new-file.ts", "content": "export const foo = 1;" }

ls_tree

List directory structure as an ASCII tree.

{ "path": "/project/src", "maxDepth": 3 }

search_code

Search text or regex patterns recursively across the codebase.

{ "path": "/project/src", "pattern": "useEffect", "useRegex": false }

inspect_symbols

Extract class and function signatures from a file using AST analysis (ts-morph).

{ "file": "src/tools/index.ts" }

run_shell_task

Execute allowed shell commands.

{ "command": "npm run build", "timeout": 60000 }

Allowed prefixes: npm test, npm run, npm list, npx vitest, npx tsc, npx eslint, node --version, tsc, git status, git diff, git log, git show, git blame, ls, pwd, cat, wc.


Quality Analysis

Static analysis tools, no LLM required.

detect_patterns

Detect anti-patterns, code smells, and security issues using Babel AST analysis.

{ "sourceCode": "...", "filePath": "src/auth/login.ts" }

suggest_refactor

Detect refactoring opportunities: long functions, deep nesting, magic numbers, duplicate code, and missing type annotations.

{
  "file_path": "src/services/user.ts",
  "max_suggestions": 10,
  "min_priority": 3,
  "include_diff": true
}

Either file_path or code_snippet must be provided.

analyze_dependencies

Build a lightweight dependency graph of TypeScript files via import analysis. Returns nodes, circular dependencies, and DOT format for Graphviz.

{ "rootPath": "/project/src" }

Embedding-Powered

Requires EMBEDDING_API_URL and EMBEDDING_MODEL. Embeddings are generated once per symbol and cached in .rig/index.db — subsequent queries only embed the query string.

search_semantic

Semantic symbol search using vector similarity. Returns the most relevant functions and classes with their code snippets. Use this before read_files to avoid loading entire files into context. Embeddings are generated once per symbol and cached in .rig/index.db.

{
  "repoPath": "/project",
  "query": "how is authentication handled",
  "maxResults": 5,
  "threshold": 0.3
}

LLM-Powered

Requires GLM_API_URL and GLM_MODEL.

analyze_logic

Ask a natural language question about a piece of code. Uses the configured LLM to reason about behavior, intent, or logic.

{
  "filePath": "/project/src/auth/login.ts",
  "question": "What edge cases does this miss?"
}

Prefer filePath over code to avoid passing file contents through context.

smart_summarize

Generate an intelligent summary of a code file including imports, exports, purpose, and key dependencies.

{ "filePath": "/project/src/services/user.ts", "maxLength": 200 }

generate_unit_tests

Generate vitest unit tests for a specific function or class. Uses the RIG index to extract only the method body (not the whole file) — token-efficient. Covers happy path, edge cases, and error cases.

{
  "repoPath": "/project",
  "symbolName": "createUser",
  "filePath": "src/services/user.ts"
}

filePath is required only if the symbol exists in multiple files.

investigate_ts_fix

Run tsc --noEmit and use the LLM to explain and suggest minimal fixes for each TypeScript error. Token-efficient: only passes the snippet around the error line (±8 lines), not the whole file.

{
  "repoPath": "/project",
  "filePath": "src/services/user.ts",
  "maxErrors": 5
}

filePath and maxErrors are optional. Omit filePath to investigate all errors across the repo.


Architecture

src/
├── cli/           # rig-indexer CLI (pre-index a repo into .rig/index.db)
├── graph/         # RIG graph engine (indexer, parsers, SQLite storage, types)
├── security/      # Path validation and safe extension checks
└── tools/         # MCP tool implementations (19 tools)

Pre-indexing a repository

For large codebases, pre-index before using RIG tools:

npx tsx src/cli/index.ts /path/to/project --db /path/to/project/.rig/index.db

Options: --max-files <n>, --include-tests, --json

Development

npm run build   # Compile TypeScript
npm run dev     # Run in development mode
npm test        # Run test suite
npm run clean   # Clean build artifacts

License

MIT