Skip to main content
Glama
Precision-MCP

Precision-MCP

by rohitkhamrai

Cursor-style AST Codebase Indexing & Surgical Slicing MCP Server for AI Coding Agents

License: MIT CI Python: >=3.10 Protocol: MCP Zero External Dependencies

Stop dumping 500-line files into your LLM context window. Give any AI agent Cursor-grade AST symbol navigation in <15ms.


πŸš€ The Problem

Modern coding agents (Claude Code, Gemini CLI, Cursor, Windsurf, OpenCode) suffer from context rot:

  1. Whole-File Dumping: Reading entire files to inspect a single 20-line method floods the context window with boilerplate, increasing API costs by 10x.

  2. Context Window Degradation: Large codebases cause fast models to lose instruction adherence, skip edge cases, or crash on token limits.

  3. Slow Brute-Force Regex: Scanning with regex fails to distinguish between declarations, call sites, and comments.

  4. Indentation & Syntax Drift: Blind search-and-replace mutates line numbers, corrupting codebases.

Precision-MCP solves this by providing a lightweight, high-performance AST indexing engine over the Model Context Protocol (MCP). It indexes your workspace in milliseconds, lets agents retrieve exact symbol slices, analyzes cascading blast radius, and guarantees zero syntax errors via AST-safe mutations.


Related MCP server: CodeMind

⚑ Performance Benchmarks

Live benchmarks measured across real-world codebases:

Metric

Brute-Force File Read

Standard Ripgrep

Precision-MCP

Cold Index Speed

N/A (no index)

N/A

~70-120 ms (Initial scan)

Warm Re-Index Speed

N/A

N/A

<8.5 ms (Incremental mtime cache)

Query Latency

~45 ms (full read)

~25 ms (text search)

<1.0 ms (Indexed AST)

Token Usage per Query

800 - 1,500+ tokens

Snippet only (no body)

35 - 150 tokens (96.4% saved)

Cascading Blast Radius

Manual search

Incomplete regex

Automated multi-level call graph

Code Mutation Safety

Fragile text replace

None

Cross-Language AST/Syntax Gate with Auto-Rollback

Memory Footprint

Process memory bloat

Variable

<12 MB (Zero dependencies)

Run the visual benchmark demo on your own machine:

python -m precision_mcp.demo

πŸ› οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Coding Agent (Claude Code / Cursor / Gemini CLI)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚ JSON-RPC 2.0 (stdio)
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Precision-MCP                       β”‚
β”‚                                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   MCP Server     β”‚           β”‚    AST Parser     β”‚  β”‚
β”‚  β”‚  (stdio driver)  β”‚ ────────► β”‚  (Python AST +    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚   Regex TS/Go/Rs) β”‚  β”‚
β”‚           β”‚                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚           β–Ό                               β–Ό            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚     CodebaseIndexer (.precision_index.json)      β”‚  β”‚
β”‚  β”‚     - Symbol graph (Classes, Methods, Funcs)     β”‚  β”‚
β”‚  β”‚     - Exact [start_line, end_line] slices        β”‚  β”‚
β”‚  β”‚     - Call-site graph & caller tracing           β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation & Setup

Option 1: Run instantly with uvx (No installation needed)

uvx precision-mcp

Option 2: Install via pip

pip install -e .
precision-mcp

βš™οΈ Configuration in Agents

1. Claude Desktop / Claude Code (claude_desktop_config.json)

{
  "mcpServers": {
    "precision-mcp": {
      "command": "python",
      "args": ["-m", "precision_mcp.server", "--root", "/path/to/your/project"]
    }
  }
}

2. Cursor IDE (settings.json)

{
  "mcp": {
    "servers": {
      "precision-mcp": {
        "command": "precision-mcp",
        "args": ["--root", "."]
      }
    }
  }
}

3. Antigravity IDE / Gemini CLI (mcp_config.json)

{
  "mcpServers": {
    "precision-mcp": {
      "command": "python",
      "args": ["-m", "precision_mcp.server", "--root", "."]
    }
  }
}

🧩 Exposed MCP Tools

Tool

Parameters

Description

index_codebase

workspace_path?, force?

Scans workspace with incremental mtime caching (<8.5ms warm re-index).

find_symbol

query

Locates functions, classes, or methods with exact line boundaries [start, end], signatures, and docstrings.

get_outline

file_path

Generates structural skeleton of any file without reading its entire body.

get_symbol_slice

file_path, symbol_name

Extracts the exact source code block of a single function or class.

find_callers

symbol_name

Identifies all direct callers of a given symbol across the codebase.

get_impact_radius

symbol_name, max_depth?

Blast Radius Analyzer: Traces cascading multi-level callers and affected files before refactoring.

patch_symbol

file_path, symbol_name, new_code

Syntax-Safe Surgical Mutator: Replaces symbol block with cross-language syntax verification (Python, TS/JS, Go, Rust) and automatic rollback.


πŸ§ͺ Testing

Run 20 unit tests across parser, indexer, and MCP protocol handlers:

python -m unittest discover -s tests -v

πŸ“„ License

MIT Β© Rohit Kumar Khamrai

Available Tools

7 tools
find_callersB

Find all functions and methods in the codebase that invoke a given function or method.

Inputs: symbol_name (required).

find_symbolA

Locate classes, functions, or methods by name. Returns file paths, exact line bounds [start_line, end_line], parameter signatures, and docstrings.

Inputs: query (required).

get_impact_radiusA

Analyze cascading downstream blast radius before refactoring. Identifies all callers, affected files, and risk level across the codebase.

Inputs: symbol_name (required), max_depth.

get_outlineA

Get the structural skeleton (all classes, functions, line bounds) of a file without reading its entire contents into context.

Inputs: file_path (required).

get_symbol_sliceB

Extract the exact source code block of a single function or class by symbol name without reading the surrounding file.

Inputs: file_path (required), symbol_name (required).

index_codebaseB

Scan and index all classes, functions, and methods across the workspace for sub-millisecond symbol search.

Inputs: force, workspace_path.

patch_symbolA

Surgically replace a function or class block by symbol name. Automatically validates AST syntax and rolls back if invalid, guaranteeing zero malformed edits.

Inputs: new_code (required), file_path (required), symbol_name (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools target distinct actions: indexing, symbol lookup, file outline, source slicing, caller search, impact analysis, and patching. Find_callers and get_impact_radius overlap since impact_radius includes caller discovery, but the descriptions distinguish direct callers from broader blast-radius analysis.

    Naming Consistency5/5

    All tool names use consistent snake_case with a verb-first pattern: index_, find_, get_, and patch_. The convention is predictable despite a mix of verbs, and each name clearly signals the operation and target.

    Tool Count5/5

    Seven tools is well-scoped for a code-intelligence and refactoring server. Each tool covers a distinct step in the workflow, from indexing to patching, without obvious redundancy.

    Completeness4/5

    The surface covers discovery, navigation, slicing, caller analysis, impact analysis, and safe patching. It lacks explicit create, delete, rename, or move-symbol operations, but agents can work around these via patch_symbol and impact analysis.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLM agents to efficiently understand and navigate a codebase by providing semantic search over symbols and a reference graph, replacing expensive grep/glob calls with structured tools like definition lookup, caller/callee queries, and change-impact analysis.
      19 PyPI
      4
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides persistent codebase memory and semantic context for AI agents via AST-aware chunking and symbol graph indexing.
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes a codebase's symbol graph and symbol-aware editing tools to AI agents, enabling targeted symbol lookup, impact analysis, and atomic multi-file edits with reduced context tokens.
      12 npm
      MIT