Skip to main content
SHARC provides 7 MCP tools for indexing and searching codebases. This page documents each tool’s parameters, behavior, and usage examples.

index_codebase

Index a codebase for semantic search. This is typically the first tool you’ll use.

Parameters

Behavior

First Run (Full Indexing):
  1. Scans directory for supported files
  2. Splits code into semantic chunks (AST-based for supported languages)
  3. Generates embeddings
  4. Stores vectors in the search index
  5. Saves a sync snapshot for future incremental sync
  6. Auto-starts file watcher
Multi-repo guard: If the target path contains 2 or more immediate child git repositories (e.g., ~/projects containing multiple repos), SHARC blocks indexing and returns a guarded_block response with:
  • The number of detected repos and sample paths
  • A one-shot guardOverrideToken to proceed if intentional
  • Guidance to index a specific child repo instead
This prevents accidentally indexing broad parent directories, which produces mixed search results and wastes token budget. Subsequent Runs (Incremental):
  1. Loads previous sync snapshot
  2. Computes current file hashes
  3. Identifies changed files via diff
  4. Only re-indexes added/modified files
  5. Removes vectors for deleted files

Example


search_code

Search indexed code using natural language queries.

Parameters

Search Modes

The searchMode parameter controls which types of code are returned: This is useful when an agent needs to find specific categories of code. For example, use implementation_only when looking for how a feature works, or tests_only when looking for test coverage of a function.

Behavior

  1. Generates embedding for query
  2. Performs hybrid search (dense vectors + BM25 sparse)
  3. Reranks results for better relevance
  4. Returns ranked code snippets with metadata

Result Format

Each result includes:
  • Location: File path and line numbers
  • Score: Relevance score (0-1, higher is better)
  • Code: The matching code snippet
  • Context: Surrounding class/function information

Understanding Scores

SHARC uses hybrid retrieval (dense vectors + BM25 sparse matching) combined with a reranker, which produces well-calibrated relevance scores: If a targeted query does not return results in the 0.9+ range, it typically means the implementation doesn’t exist in the codebase, the query was too vague, or the implementation itself is loosely structured. Try rephrasing with more specific terms.

Example

Query Tips


clear_index

Remove a codebase from the index.

Parameters

Behavior

  1. Stops file watcher (if active)
  2. Deletes indexed data for that codebase
  3. Removes sync snapshot metadata
  4. Clears local caches

Example


get_indexing_status

Check the indexing status of a codebase.

Parameters

Response States

Example


start_watch

Start watching a codebase for file changes.

Parameters

Behavior

  • Requires codebase to be already indexed
  • Uses chokidar for file system events
  • 2-second debounce for batched processing
  • Automatically filters unsupported files
  • Validates syntax before indexing (prevents broken code)

Example

File watching starts automatically after index_codebase completes. You only need start_watch if you previously stopped watching.

stop_watch

Stop watching a codebase for file changes.

Parameters

Example


get_watch_status

Get the list of codebases currently being watched.

Parameters

None.

Example


Supported File Extensions

Tier 1: AST-Parsed (Best Quality)

Full semantic understanding with context injection: .ts, .tsx, .js, .jsx, .mjs, .cjs, .py, .pyw, .go, .rs, .java, .cs, .cpp, .cc, .cxx, .c, .h, .hpp, .scala

Tier 2: Documentation

Character-based chunking with overlap: .md, .mdx, .rst, .txt

Tier 3: Configuration

Grouped key-value chunking: .json, .yaml, .yml, .toml, .xml, .env.example, .ini, .cfg

Tier 4: Other Code

Fallback chunking for unsupported languages: .rb, .php, .swift, .kt, .kts, .vue, .svelte, .html, .css, .scss, .less, .sql