π NakshAstraMCP β User Guide
Maximize AI Developer Context: Master client configuration, CLI control, multi-client bridges, configuration tuning, and visual graph diagnostics.
π Table of Contents
- Client Configuration
- Dual Transport Bridge
- Automated Agent Orchestration
- MCP Tool Reference
- Unified CLI Command Reference
- Advanced CLI Flags
- Configuration System (
config.toml) - Environment Variables
- Adding Custom Language Support
- Knowledge Mapping & Report Generation
- How the Search Engine Works
π Client Configuration
Once NakshAstraMCP is installed, connect it to your preferred AI coding environment. The server remembers registered workspaces centrally β your IDE config only needs the start command.
1. Claude Desktop (macOS / Windows)
Config file locations:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Option A: Manual JSON Configuration
{
"mcpServers": {
"nakshastramcp": {
"command": "nakshastramcp",
"args": ["start"]
}
}
}
Option B: Claude CLI Automation
# HTTP Transport (requires background server already running):
claude mcp add --transport http nakshastramcp http://127.0.0.1:2102/mcp
# STDIO Transport (Claude manages the process lifecycle):
claude mcp add --transport stdio nakshastramcp nakshastramcp -- start --transport stdio
2. Cursor IDE
- Open Settings β Models β MCP.
- Click + Add New MCP Server.
- Fill in the fields:
- Name:
NakshAstra - Transport:
stdio - Command:
nakshastramcp - Arguments:
start,--transport,stdio
- Name:
3. Antigravity IDE
Add the following block to your mcp_config.json:
{
"mcpServers": {
"nakshastramcp": {
"command": "nakshastramcp",
"args": ["start", "--transport", "stdio"],
"type": "stdio",
"disabled": false
}
}
}
4. Windsurf
Add to your Windsurf MCP configuration:
{
"mcpServers": {
"nakshastramcp": {
"command": "nakshastramcp",
"args": ["start", "--transport", "stdio"]
}
}
}
5. Factory AI
Option A: HTTP Transport (background server required)
{
"mcpServers": {
"nakshastramcp": {
"type": "http",
"url": "http://127.0.0.1:2102/mcp",
"disabled": false
}
}
}
Option B: STDIO Transport
- Server Name:
nakshastramcp - Server Type:
stdio - Command:
nakshastramcp start --transport stdio
6. VS Code (via HTTP Bridge)
When NakshAstraMCP is already running as a host in another IDE, connect VS Code extensions directly to the HTTP bridge β no second process required:
- URL:
http://127.0.0.1:2102/mcp - Type:
streamable-http
π Dual Transport Connection Bridge
NakshAstraMCP features a Dual Transport Bridge. When started via stdio inside your main IDE, the host session automatically spawns a local streamable HTTP connection on port 2102.
βββββββββββββββββββββββββββββββ
β Antigravity / Cursor IDE β β Host (stdio)
β nakshastramcp start β
ββββββββββββββ¬βββββββββββββββββ
β spawns
βΌ
Port 2102 HTTP Bridge
http://127.0.0.1:2102/mcp
β
ββββββββββ΄βββββββββ
βΌ βΌ
VS Code Factory AI
(Follower) (Follower)
Practical Use Case: Use Antigravity as your primary coding host and VS Code with a specialized extension simultaneously β both query the same live codebase graph without performance degradation or index contention.
Configuring follower clients:
| Field | Value |
|---|---|
| Type | streamable-http |
| Bridge URL | http://127.0.0.1:2102/mcp |
[!NOTE] If port
2102is already in use, start with a custom port:nakshastramcp start --port 3000. Then update follower clients to usehttp://127.0.0.1:3000/mcp.
π€ Automated Agent Orchestration
Starting with v3.16.0, NakshAstraMCP simplifies onboarding for AI agents and team members:
- Zero-Config Onboarding: When registering a workspace via
nakshastramcp start --workspace ., the server automatically provisions a customAGENTS.mdfile in your workspace root. - Prompt Alignment: The file instructs AI agents to prioritize surgical MCP tools (
read_filewith line ranges,find_symbol) over expensive shell grep commands. - Non-Destructive Backups: If an older
AGENTS.mdalready exists, it is safely backed up toAGENTS_Backup.md. - MCP-First Skill Profile: Load the π― MCP-First Skill Profile into your AI assistantβs system prompt to enforce AST-aware, token-optimized workflows across all tasks.
π©Ί MCP Tool Reference
NakshAstraMCP registers these precision tools on your AI client. Each tool has a specific purpose β use the right tool for each task to minimize token consumption:
| Tool | Priority | Best For | Parameters |
|---|---|---|---|
deep_context |
π₯ Primary | High-level questions, architectural discovery, module-to-module relationships | query, workspace_path?, rerank?, snippet_chars?, expand_neighbors?, compact_symbols? |
search_codebase |
π₯ Discovery | Broad keyword/grep-style search across all indexed files | query, workspace_path?, snippet_chars? |
find_symbol |
π₯ Surgical | Locate exact class/function/method definition with file + line range | name, workspace_path? |
read_file |
π Reader | Read a specific file or line range before any edit | path, workspace_path?, start_line?, end_line?, if_changed_since? |
find_references |
π Audit | Trace all call sites and usages of a custom function/class | symbol_name, workspace_path? |
generate_report |
πΊοΈ Map | Trigger full architectural synthesis β NAKSHASTRA_REPORT.md + graph.json |
workspace_path? |
server_status |
π©Ί Diagnostic | Check workspace health, memory usage, and uptime | (none) |
Key Tool Parameters Explained
deep_context β Advanced Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
string |
required | Natural language or keyword search query |
workspace_path |
string |
all workspaces | Restrict search to a specific workspace path |
rerank |
bool |
true |
Enable FlashRank semantic reranking |
snippet_chars |
int |
200 |
Snippet character window (200 = fast scan, 1000 = deep read) |
expand_neighbors |
bool |
true |
Include 1-hop AST graph neighbors in results |
compact_symbols |
bool |
false |
Return compact text symbol list instead of structured JSON |
read_file β Advanced Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
string |
required | Relative file path within the workspace |
start_line |
int |
1 | First line to read (1-indexed) |
end_line |
int |
EOF | Last line to read |
if_changed_since |
string |
β | SHA-256 hash of previous read; returns {"status": "unchanged"} if file is unchanged β saves 100% tokens on re-reads |
π οΈ Unified CLI Command Reference
Manage server lifecycle, workspaces, and environment directly from your terminal:
| Command | Description |
|---|---|
nakshastramcp start --workspace <path> |
Register, index, and start monitoring a codebase |
nakshastramcp stop |
Gracefully terminate the background server process |
nakshastramcp restart |
Flush sessions and restart all background transports |
nakshastramcp status |
View registered workspaces and server health |
nakshastramcp doctor |
Run 13 pre-flight environment checks |
nakshastramcp logs [--follow] |
Stream real-time logs to terminal (--follow for tail mode) |
nakshastramcp deregister --workspace <path> |
Stop server, remove workspace, and clean orphaned index data |
nakshastramcp gc |
Garbage collect orphaned index directories for deleted projects |
nakshastramcp ui [--workspace <path>] |
Launch the Nebula Graph UI for interactive visualization |
nakshastramcp report [<path>] |
Generate architectural report (NAKSHASTRA_REPORT.md) for a workspace |
nakshastramcp provision --lang <name> --lib <path> |
Provision a custom Tree-sitter grammar at runtime |
nakshastramcp test-tools |
Run in-process MCP tool diagnostics (debug EOF/transport issues) |
nakshastramcp --version |
Print the installed version |
ποΈ Advanced CLI Flags
nakshastramcp start β Full Flag Reference
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--workspace |
-w |
path | β | Register and index this workspace path (can be repeated for multiple) |
--transport |
β | string | streamable-http |
Transport mode: stdio or streamable-http |
--port |
-p |
int | 2102 |
HTTP bridge port (useful if 2102 is occupied) |
--host |
β | string | 127.0.0.1 |
HTTP bridge bind host |
--config-lang |
β | string | β | Custom language extension mappings: ".go=go,.rs=rust" or JSON {"go": "go"} |
--force |
-f |
bool | false |
Force start by clearing any stale lock file |
nakshastramcp stop β Flags
| Flag | Short | Description |
|---|---|---|
--force |
-f |
Remove stale lock file even if no running process is found |
nakshastramcp logs β Flags
| Flag | Short | Description |
|---|---|---|
--lines |
-n |
Number of recent log lines to display (default: 50) |
--follow |
-f |
Stream logs continuously (like tail -f) |
βοΈ Configuration System (config.toml)
NakshAstraMCP uses a layered configuration system. Settings are resolved in this precedence order (highest to lowest):
CLI Flags > Environment Variables (NAKSH_*) > config.toml > System Defaults
Config File Location (Platform-Specific)
| Platform | Path |
|---|---|
| Windows | %LOCALAPPDATA%\nakshastramcp\config.toml |
| macOS | ~/Library/Application Support/nakshastramcp/config.toml |
| Linux | ~/.local/share/nakshastramcp/config.toml |
Complete config.toml Reference
# ββ Search Settings βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Maximum time (ms) the search pipeline may spend before returning results.
search_timeout_ms = 500
# Maximum time (ms) the FlashRank semantic reranker may use.
rerank_timeout_ms = 150
# Maximum number of result records returned per search query.
snippet_limit = 10
# ββ Memory Management ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# RAM threshold (MB) before Memory Guard triggers garbage collection.
mem_threshold_mb = 1024
# How often (seconds) the Memory Guard polls system RAM usage.
mem_poll_interval_s = 30.0
# Maximum number of simultaneously active workspace contexts (LRU eviction).
mem_lru_size = 5
# ββ Machine Learning / FlashRank βββββββββββββββββββββββββββββββββββββββββββββ
# Cross-encoder model used for semantic reranking.
model_name = "ms-marco-TinyBERT-L-2-v2"
# ββ Performance ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# How long (seconds) search result caches are valid before re-querying.
search_cache_ttl_s = 300
# Filesystem watcher debounce period (ms) β prevents re-indexing during rapid saves.
debounce_ms = 500
# ββ Retrieval Quality ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Alpha weight in the combined relevance formula:
# score = Ξ± Γ lexical_score + (1 - Ξ±) Γ pagerank_score
# 0.7 = favor lexical match; lower values weight architectural importance more.
scoring_alpha = 0.7
# ββ Logging ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Log verbosity level: DEBUG, INFO, WARNING, ERROR
log_level = "INFO"
# Maximum size (bytes) of a single log file before rotation.
log_max_bytes = 5000000 # 5 MB
# Number of rotated log backups to keep.
log_backup_count = 3
# ββ Transport βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Default transport: "streamable-http" or "stdio"
transport = "streamable-http"
# HTTP bridge port.
port = 2102
# HTTP bridge bind host (127.0.0.1 = localhost only).
host = "127.0.0.1"
# ββ Custom Language Mappings ββββββββββββββββββββββββββββββββββββββββββββββββββ
# Associate file extensions with provisioned Tree-sitter grammars.
# Requires grammar to be provisioned first via: nakshastramcp provision --lang go --lib ./tree_sitter_go.dll
[custom_languages]
".go" = "go"
".rs" = "rust"
π Environment Variables
All settings can be overridden at runtime using NAKSH_* prefixed environment variables. These take precedence over config.toml but are overridden by CLI flags.
| Variable | Default | Description |
|---|---|---|
NAKSH_TRANSPORT |
streamable-http |
Transport mode: stdio or streamable-http |
NAKSH_PORT |
2102 |
HTTP bridge port |
NAKSH_HOST |
127.0.0.1 |
HTTP bridge bind host |
NAKSH_MEM_THRESHOLD_MB |
1024 |
Memory Guard cleanup threshold (MB) |
NAKSH_SNIPPET_LIMIT |
10 |
Maximum search result records per query |
NAKSH_LOG_LEVEL |
INFO |
Logging verbosity (DEBUG, INFO, WARNING, ERROR) |
NAKSH_SEARCH_TIMEOUT_MS |
500 |
Search pipeline timeout (ms) |
NAKSH_RERANK_TIMEOUT_MS |
150 |
FlashRank reranker timeout (ms) |
NAKSH_SCORING_ALPHA |
0.7 |
Relevance/PageRank blend weight |
NAKSH_DEBOUNCE_MS |
500 |
Filesystem watcher debounce period (ms) |
NAKSH_SEARCH_CACHE_TTL_S |
300 |
Search result cache TTL (seconds) |
π§© Adding Custom Language Support (Addons)
Core languages β Python, JavaScript, TypeScript, TSX, Java, Kotlin, and Swift β are natively supported with no configuration. To add additional languages:
Step-by-Step Grammar Provisioning
1. Obtain the grammar binary:
Fetch or compile a Tree-sitter binary grammar (.dll on Windows, .so on Linux/macOS, .dylib on macOS) for your target language.
2. Provision the grammar:
nakshastramcp provision --lang go --lib .\tree_sitter_go.dll
Optional flags for provision:
--query <path>: Path to a customsymbols.scmquery file for symbol extraction.--ext <extension>: File extension to map (e.g.,.go). If omitted, you will be shown how to configure this inconfig.toml.
NakshAstraMCP validates the grammar library in an isolated subprocess to prevent crashes from malformed binaries.
3. Associate file extensions (in config.toml):
[custom_languages]
".go" = "go"
Or pass inline via CLI:
nakshastramcp start --config-lang ".go=go,.rs=rust"
πΊοΈ High-Fidelity Knowledge Mapping
Artifact Generation
When triggered, the Architectural Report Engine creates a nakshastra-out/ folder inside your workspace containing:
NAKSHASTRA_REPORT.md: A structured Markdown overview showing:- High-Impact Files: Hub files ranked by PageRank centrality score.
- High-Impact Symbols: Central class/function definitions with clickable line links (e.g.,
file:///path/to/file#L10-L45). - Module Communities: Louvain-detected clusters of tightly coupled files (named by dominant directory).
- Blast Radius Warnings: Flags βGod Nodeβ files whose modification would cascade across the most modules.
graph.json: Raw symbol dependency map in JSON format for rendering in external diagram tools.
Triggering a Report
Via MCP tool (from AI assistant):
generate_report
Via CLI (standalone):
nakshastramcp report .
π¬ How the Search Engine Works
Understanding the search pipeline helps you tune parameters and choose the right tool.
The 5-Stage Search Pipeline
When you call deep_context or search_codebase, the engine runs this pipeline:
Query Input
β
βΌ
1. Query Sanitization
(Remove FTS5/Tantivy special chars; camelCase decomposition as fallback)
β
βΌ
2. Tantivy Full-Text Search β Primary engine (sub-millisecond)
[Fallback if empty]
β
βΌ
3. SQLite FTS5 BM25 Search β Secondary engine
[Fallback if empty]
β
βΌ
4. Substring LIKE Search β Last resort
β
βΌ
5. FlashRank Semantic Reranking β Reorders by conceptual intent (150ms max)
deep_context β Combined Relevance Scoring
After search, deep_context performs additional graph-aware scoring for each symbol:
Combined Score = Dampening Γ (Ξ± Γ Lexical Score + (1 - Ξ±) Γ PageRank Score)
Where:
Ξ±(scoring_alpha, default0.7): Blends lexical match strength with architectural importance.- Dampening (
0.4for graph neighbors,1.0for primary hits): Reduces weight of indirectly expanded files. - Query Match Boost (
2.0Γ): Applied when the symbol name directly contains the search query term. - Top-25 Deduplication: Final results are deduplicated and capped at 25 symbols for token efficiency.
1-Hop AST Graph Expansion
The deep_context tool goes further than text matching: after finding primary file hits, it queries the Symbol Graph to identify 1-hop neighbors β files that import or are imported by the matched files. This pulls in the architectural context a keyword search would miss.
[!TIP] Pass
expand_neighbors=Falsetodeep_contextfor faster responses when you only need direct file matches and donβt need surrounding module context.
π Home Β· π Setup Guide Β· π οΈ Troubleshooting Β· π€ Agent Guide