Skip to main content
Glama

Why Graft?

AI coding tools are only as good as the context they receive. Most tools either have no codebase understanding, or use proprietary indexing locked to a single editor.

Graft gives any MCP-compatible AI tool deep structural understanding of your codebase:

  • 100K lines of code represented in ~2K tokens of ranked context

  • Dependency-aware — knows which files import what, and what depends on what

  • PageRank-scored — surfaces the most structurally important files first

  • Tool-agnostic — works with Claude, Cursor, Windsurf, Continue, or any MCP client

  • Local-first — no cloud, no telemetry, no code ever leaves your machine

$ npx graftmap map

src/indexer/pipeline.ts [score: 0.0842]
  function buildIndex (L19)

src/graph/pagerank.ts [score: 0.0731]
  function computePageRank (L52)
  function buildTeleportVector (L11)

src/parser/index.ts [score: 0.0654]
  function parseFiles (L28)

src/mcp/server.ts [score: 0.0612]
  function createGraftServer (L238)
  function startMcpServer (L327)

[~487 tokens]

Related MCP server: agentmako

Quick Start

# Run instantly with npx (no install needed)
npx graftmap map

# Or install globally
npm install -g graftmap
graft map

MCP Integration

Add Graft to your AI tool's MCP configuration. Once connected, your AI assistant automatically gets ranked codebase context.

Claude Desktop / Claude Code

Add to your MCP settings:

{
  "mcpServers": {
    "graft": {
      "command": "npx",
      "args": ["-y", "graftmap"],
      "cwd": "/path/to/your/project"
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "graft": {
      "command": "npx",
      "args": ["-y", "graftmap"],
      "cwd": "/path/to/your/project"
    }
  }
}

Any MCP Client

Graft speaks standard MCP over stdio. Point any MCP-compatible client at npx graftmap and it works.

MCP Tools

Once connected, your AI tool gets these capabilities:

Tool

Description

graft_map

Ranked tree map of the codebase by structural importance

graft_context

Dependencies and definitions for a specific file

graft_search

Find definitions by name or kind (function, class, type, etc.)

graft_impact

Files affected by changing a given file

graft_summary

Project overview with key files and tech stack

Plus two MCP resources: graft://map and graft://file/{path}

CLI Commands

graft map                    # Ranked codebase tree
graft map --focus src/api.ts # Personalized view focused on a file
graft map --budget 4096      # Custom token budget
graft stats                  # File count, definitions, edges, cache age
graft impact src/auth.ts     # What breaks if you change this file?
graft search "handleRequest" # Find definitions by name
graft search "User" --kind class  # Filter by kind
graft serve                  # Start MCP server (default command)

How It Works

Your Codebase          Graft Pipeline              AI Tool
─────────────          ──────────────              ───────
  .ts .js .py    ──►   tree-sitter AST
                        extraction
                             │
                        dependency graph     ──►   graft_map
                        construction               graft_context
                             │                     graft_search
                        personalized         ──►   graft_impact
                        PageRank scoring           graft_summary
                             │
                        token-budgeted       ──►   Ranked context
                        rendering                  in ~2K tokens
  1. Discover — finds all supported files, respects .gitignore

  2. Parse — extracts definitions (functions, classes, types) and references using tree-sitter

  3. Graph — builds a directed dependency graph (files as nodes, imports as edges)

  4. Rank — runs personalized PageRank to score files by structural importance

  5. Render — produces token-budgeted output that fits in any AI context window

  6. Cache — stores results in .graft/cache.json for instant re-indexing

Supported Languages

Language

Definitions

References

Status

TypeScript

Functions, classes, interfaces, types, enums, methods

Imports, usages

Stable

JavaScript

Functions, classes, methods

Imports, usages

Stable

TSX/JSX

Same as TS/JS

Same as TS/JS

Stable

Python

Functions, classes, methods, decorators, dataclasses

Imports, usages

Stable

Go

Planned

Rust

Planned

Performance

Graft is designed for large codebases:

  • Caching — parses once, re-indexes only changed files

  • Token-efficient — 100K LOC → ~2K tokens of meaningful context

  • Fast — full index of a medium codebase in under 3 seconds

  • Memory-efficient — in-memory graph, no external database needed

Configuration

Graft is zero-config by default. It automatically:

  • Discovers .ts, .tsx, .js, .jsx, and .py files

  • Respects .gitignore patterns

  • Excludes node_modules, dist, .git, and common build directories

  • Uses sensible defaults for token budgets and PageRank parameters

No config files needed. Ever.

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup and guidelines.

Especially interested in:

  • New language support (Go, Rust, Java, C#, Ruby)

  • Performance optimizations for very large monorepos

  • MCP tool improvements and new tool ideas

  • Integration guides for more AI coding tools

License

MIT — use it anywhere, for anything.


Available Tools

5 tools
graft_contextC

Dependencies and definitions for a specific file.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesFile path relative to project root

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full responsibility for behavioral disclosure. It only states the tool retrieves data for a file but does not mention whether it is read-only, any required permissions, the nature of the output, or potential side effects. This is insufficient for an agent to safely invoke the tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is front-loaded with the core action. It is concise and to the point, but could be slightly more informative without adding length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has only one required parameter and no output schema, the description is minimally sufficient. However, it lacks details about return format, pagination, or limitations, and does not help an agent decide between this and sibling tools in a meaningful way.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides a full description for the 'path' parameter ('File path relative to project root'), achieving 100% coverage. The description does not add any additional meaning beyond what the schema already states, so it meets the baseline expectation without adding value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool's function: retrieving dependencies and definitions for a specific file. It uses a specific verb+resource pattern, but could be more precise about what 'definitions' entails. It does not explicitly distinguish from siblings like graft_impact or graft_search, but the purpose is distinct enough to infer.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus its siblings (graft_impact, graft_map, graft_search, graft_summary). The description lacks any contextual cues about prerequisites or alternative scenarios, leaving the agent to guess.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

graft_impactC

Files affected by changing a given file.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesFile path relative to project root

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It does not disclose whether affected files include transitive dependencies, limits, or required file existence.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, front-loaded with key info. However, it is overly terse, potentially under-specified for a tool with no output schema or annotations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has one parameter and no output schema; the description should explain what 'affected' means (direct vs transitive) and any limits. It fails to provide sufficient context for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for the single 'path' parameter. The description adds no additional meaning beyond the schema, thus baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool returns files affected by changing a given file, using a specific verb ('changing') and resource ('files affected'). It distinguishes from sibling tools like graft_search, though it lacks detail on scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. It does not specify prerequisites or mention sibling tools for different use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

graft_mapC

Ranked tree map of the codebase by structural importance.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryNoFile or symbol for personalization
budgetNoMax tokens (default 2048)

TDQS

C2.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. The description only mentions 'ranked tree map by structural importance' without explaining side effects, read-only nature, or nuances like how personalization works with the 'query' parameter. The behavior is under-specified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, making it concise, but it lacks structure and fails to provide necessary context. It is not overly verbose, but the brevity compromises completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and annotations, the description should explain what the tool returns (e.g., a list, tree structure, or map). It does not, leaving an agent uncertain about the expected output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage for its two parameters, clearly explaining 'query' as personalization and 'budget' as max tokens. The tool description adds no additional meaning beyond the schema, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states it is a 'ranked tree map of the codebase by structural importance,' which conveys a general purpose but lacks specificity. It does not clearly differentiate from siblings like 'graft_search' or 'graft_impact,' as it does not explain what 'structural importance' means or how this map is generated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'graft_context' or 'graft_summary.' The description does not mention prerequisites, context, or scenarios where this tool is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

graft_summaryB

Project overview with key files and tech stack.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, and the description does not disclose behavioral traits such as read-only nature, authentication requirements, or performance characteristics. The burden of transparency is unaddressed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at 6 words, but it is not a complete sentence; it is a noun phrase. Despite this, it communicates essential information efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description provides a reasonable overview of what the tool returns (key files and tech stack). However, it lacks details on format, scope, or how 'key files' are determined, leaving some ambiguity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are zero parameters, so per guidelines the baseline is 4. The description adds no parameter info, but none is needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool provides a 'project overview with key files and tech stack', which is specific and distinct from sibling tools like graft_search or graft_impact. However, it could be more explicit in differentiating from close alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description lacks any context about prerequisites, limitations, or recommended scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 5 tool updatesv0.0.1
    • First observedgraft_context
    • First observedgraft_impact
    • First observedgraft_map
    • First observedgraft_search
    • First observedgraft_summary

TDQS

B3.4/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: context for a file, impact analysis, codebase map, definition search, and project summary. No overlap or ambiguity.

Naming Consistency5/5

All tools follow the consistent pattern 'graft_<noun>' with simple, descriptive names (context, impact, map, search, summary). Perfect consistency.

Tool Count5/5

5 tools is well-scoped for a focused code analysis server. Each tool earns its place covering essential exploration tasks without unnecessary bloat.

Completeness4/5

The set covers core codebase exploration: summary, search, context, impact, and structural map. Minor gaps like diff or history exist but the surface is practical for typical use.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Code graph context engine that parses codebases with tree-sitter (170+ languages), builds structural dependency graphs, and provides 24 MCP tools for code intelligence. One prepare_context call gives your AI agent the right files for any task. Includes focus, blast radius, hotspots, dead code detection, and hybrid search.
    24
    42 PyPI
    1
    AGPL 3.0
  • A
    license
    C
    quality
    A
    maintenance
    Local-first codebase intelligence engine providing AI coding agents with a typed MCP toolset for understanding and navigating code repositories.
    100
    51
    Apache 2.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    Turn your codebase into AI context — entirely on your machine. Single-binary MCP server with AST parsing, call graph, and local embeddings.
    26
    MIT