Skip to content

Chanakya MCPStructural Intelligence

Pure compiler-grade AST static analysis and relational SQLite indexing for AI coding agents. Zero embeddings, zero LLM hallucinations, and zero network calls.

Chanakya MCP Logo
Zero network calls • 100% Deterministic Structural Intelligence
⚡

Deterministic Structural Code Intelligence

Chanakya MCP does not guess, hallucinate, or generate probabilistic embeddings. It compiles concrete syntax trees (AST) into high-speed SQLite relational graphs with Zero network calls.

Why AI Agents Need Structural Intelligence (Not More Grep or Embeddings) ​

Coding agents traditionally explore codebases by running grep and reading entire source files. Vector embeddings and fuzzy semantic search often return irrelevant approximate matches with zero syntactic guarantees.

Chanakya MCP provides deterministic AST structural intelligence: exact symbol declarations, verified call graphs, and relational imports/exports.

Chanakya MCP vs Traditional Grep Token Comparison
Comparison: Structured AST query (400 tokens) vs Naive Grep + File Reads (4,500+ tokens)
CapabilityWithout Chanakya (Grep / Embeddings)With Chanakya MCP (Structural AST)Advantage
Intelligence ModelProbabilistic guesswork / Vector embeddings100% Deterministic Syntax Trees (AST)Zero Hallucination
Network & TelemetryCloud embeddings / Remote API callsZero network calls (100% Local)Zero Data Leak
Find Symbol Definition3,500 tokens (grep matches + file reads)120 tokens96% Token Savings
Find All Semantic References4,500 tokens (scans 15-30 files)400 tokens91% Token Savings
Cross-Package Impact Analysis8,000+ tokens (multiple reads)550 tokens93% Token Savings
Query Latency2,000 - 5,000 ms (disk I/O)150 - 400 ms12x Faster
Call Graph PrecisionApproximate strings / False positivesExact AST Call Edges (certain & resolved)100% Accuracy

Instant Multi-Agent Setup ​

Connect Chanakya MCP to your favorite AI coding assistant in seconds over standard stdio:

Claude Code Setup

Local MCP stdio integration. Adds full AST symbols and cross-file relationships to Claude.

1Option A: Quick CLI Add (Recommended)
claude mcp add chanakya -- npx -y @aravindh-arumugam/chanakya-mcp /path/to/project
2Option B: Project .mcp.json
{
  "mcpServers": {
    "chanakya": {
      "command": "node",
      "args": [
        "./node_modules/@aravindh-arumugam/chanakya-mcp/dist/cli/main.js",
        "."
      ],
      "type": "stdio"
    }
  }
}
💡 Add "chanakya" to enabledMcpjsonServers in your ~/.claude/settings.json

System Architecture ​

Chanakya MCP operates as a deterministic compiler-grade pipeline: scanning files with .gitignore cascade support, parsing with native Tree-Sitter grammars, extracting language-agnostic code models, and querying a high-speed SQLite relational index.

Chanakya MCP Architecture Overview
Complete System Architecture: Scanner → Tree-Sitter → Model Extraction → SQLite Index → MCP Engine

Interactive 14 MCP Tools Explorer ​

Explore all 14 schema-validated tools available to your AI agents:

search_symbolsRead-only

Tri-tier ranked symbol search (exact -> prefix -> substring) with kind, path, and language filters.

Parameters (JSON Schema validated):
query*stringSymbol name or search query
match"exact" | "prefix" | "substring"Match strategy ranking
kindsstring[]Filter by function, class, interface, etc.
exported_onlybooleanOnly return public exports
Example Agent Tool Call:
call_tool("search_symbols", {
  query: "UserService",
  match: "exact",
  exported_only: true
})
search_codeRead-only

Full-text code search annotated with the innermost enclosing AST symbol for every match. Worker-thread ReDoS safe.

Parameters (JSON Schema validated):
query*stringText or regular expression
is_regexbooleanTreat query as regex
time_budget_msnumberExecution timeout cap (default: 500ms)
Example Agent Tool Call:
call_tool("search_code", {
  query: "jwt\.verify",
  is_regex: true,
  context_lines: 2
})
get_symbolRead-only

Returns the full indexed metadata for a symbol: kind, signature, container, and export status.

Parameters (JSON Schema validated):
id*stringCanonical symbol ID (e.g., src/user.ts#class:UserService)
Example Agent Tool Call:
call_tool("get_symbol", {
  id: "src/user.ts#class:UserService"
})
get_symbol_contextRead-only

The ultimate agent context query. Returns symbol details, members, callers, callees, references, and module neighborhood.

Parameters (JSON Schema validated):
id*stringTarget symbol identifier
Example Agent Tool Call:
call_tool("get_symbol_context", {
  id: "src/user.ts#method:UserService.create_user"
})
find_definitionRead-only

Locates exactly where a symbol is declared: file path, 1-based start/end line, and clean signature.

Parameters (JSON Schema validated):
id*stringSymbol identifier
Example Agent Tool Call:
call_tool("find_definition", {
  id: "src/auth.ts#function:verify_token"
})
find_referencesRead-only

Finds every semantic occurrence of a symbol across the entire repository with enclosing symbol annotations.

Parameters (JSON Schema validated):
id*stringSymbol identifier
Example Agent Tool Call:
call_tool("find_references", {
  id: "packages/shared/types.ts#interface:UserConfig"
})
get_callersRead-only

Lists all functions/methods that call this symbol, along with syntactic vs resolved call confidence.

Parameters (JSON Schema validated):
id*stringCallable symbol identifier
Example Agent Tool Call:
call_tool("get_callers", {
  id: "src/db.ts#function:connect_database"
})
get_calleesRead-only

Lists all functions, methods, and external constructors invoked from inside this symbol body.

Parameters (JSON Schema validated):
id*stringSymbol identifier
Example Agent Tool Call:
call_tool("get_callees", {
  id: "src/routes.ts#function:handle_checkout"
})
get_file_structureRead-only

Returns a tree of symbols declared in a file: classes, interfaces, functions, and nested member declarations.

Parameters (JSON Schema validated):
path*stringProject-relative file path
Example Agent Tool Call:
call_tool("get_file_structure", {
  path: "src/services/billing.ts"
})
get_dependenciesRead-only

Returns all internal files and external npm packages that a file imports.

Parameters (JSON Schema validated):
path*stringProject-relative file path
Example Agent Tool Call:
call_tool("get_dependencies", {
  path: "src/server.ts"
})
get_dependentsRead-only

Returns all files and re-exporting barrel files that import or depend on this file.

Parameters (JSON Schema validated):
path*stringProject-relative file path
Example Agent Tool Call:
call_tool("get_dependents", {
  path: "packages/shared/constants.ts"
})
apply_patchSafe Edit

Applies exact text replacements in sequence. Refuses stale files, missing text, or ambiguous multiple matches.

Parameters (JSON Schema validated):
path*stringProject-relative file path
edits*{ old_text: string, new_text: string }[]Exact ordered replacements
Example Agent Tool Call:
call_tool("apply_patch", {
  path: "src/config.ts",
  edits: [{
    old_text: "port: 3000,",
    new_text: "port: process.env.PORT || 3000,"
  }]
})
replace_symbolSafe Edit

Replaces a symbol declaration directly using its index-recorded byte range. Eliminates fuzzy matching drift.

Parameters (JSON Schema validated):
id*stringTarget symbol identifier
new_source*stringComplete replacement code for the declaration
Example Agent Tool Call:
call_tool("replace_symbol", {
  id: "src/utils.ts#function:format_date",
  new_source: "export function format_date(d: Date): string { return d.toISOString(); }"
})
rename_symbolSafe Edit

Renames a symbol across the entire codebase: declaration, all references, imports, and re-export barrels.

Parameters (JSON Schema validated):
id*stringTarget symbol identifier
new_name*stringNew identifier name
Example Agent Tool Call:
call_tool("rename_symbol", {
  id: "src/models/user.ts#interface:UserEntity",
  new_name: "UserProfile"
})

Measured Performance Benchmarks ​

Real-world benchmark measurements on full-stack monorepos comparing naive agent file reading against Chanakya MCP tool calls:

60.68%
less context per question
68.86×
median faster to answer
5,487 → 2,158
tokens across all 8 questions
Without the MCP (grep, then read the files it hit) With the MCP (one tool call)
Where is create_user defined?82.52% less
680
119

Locating a symbol before editing it.

Everything that uses format_money73.66% less
569
150

The blast radius of changing a shared helper.

Who calls user_service.create_user?96.69% less
680
23

Finding callers before changing a signature.

What does the user service depend on?42.45% less
298
172

Understanding a module before touching it.

What breaks if I change the shared types?94.1% less
1,568
93

Cross-package impact in a monorepo.

Structure of the user service73.49% more
298
517

Seeing a class outline without reading it.

Which React components use the orders hook?1.86% more
389
397

Tracing a hook through the frontend.

Full working context for user_service31.51% less
1,006
689

Everything an agent needs before a refactor: one call versus reading the layer.

Bars show approximate tokens entering the agent's context (bytes ÷ 4). Measured on 16 files / 51 symbols, median of 11 runs on Node v24.11.1.


Key Guarantees ​

  • Structural Intelligence, Not AI: Relationships are derived purely from concrete syntax trees. No AI inference, no embeddings, zero hallucinations.
  • No Guessed Relationships: Edges carry certainty flags (certain for syntax, resolved across imports). Missing edges are preferred over hallucinated ones.
  • Path Containment: All read and write operations are strictly sandboxed within the project root using realpath resolution.
  • Incremental Cache: 2-stage change detection (mtime + hash) reindexes only modified files in under 20ms.

Released under the MIT License. Zero data telemetry — 100% local execution.