Graft

Graft

Local-first codebase context engine that parses code into a ranked dependency graph and serves it to AI tools via MCP for deep structural understanding.

Category
访问服务器

README

<p align="center"> <img src="assets/logo.png" alt="Graft" width="120" /> </p>

<h1 align="center">Graft</h1>

<p align="center"> <strong>Local-first codebase context engine for AI coding tools</strong> </p>

<p align="center"> Parse any codebase into a ranked dependency graph. Serve it to AI tools via MCP.<br/> Zero config. Zero cloud. Nothing leaves your machine. </p>

<p align="center"> <a href="https://www.npmjs.com/package/graftmap"><img src="https://img.shields.io/npm/v/graftmap?color=blue" alt="npm version" /></a> <a href="https://github.com/amaar-mc/graft/actions"><img src="https://github.com/amaar-mc/graft/actions/workflows/ci.yml/badge.svg" alt="CI" /></a> <a href="https://github.com/amaar-mc/graft/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License" /></a> <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node.js" /></a> </p>


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]

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.


<p align="center"> Built by <a href="https://github.com/amaar-mc">Amaar Chughtai</a><br/> Give your AI tools the context they deserve. </p>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选