Sponsored by Deepsite.site

TSG Indexer

Created By
entrepeneur4lyf7 months ago
A library for indexing code repositories using Tree-sitter Stack Graphs, designed to be used in MCP servers and other tools.
Content

TSG Indexer

A library for indexing code repositories using Tree-sitter Stack Graphs, designed to be used in MCP servers and other tools.

Overview

TSG Indexer is a Rust library that uses Tree-sitter Stack Graphs to analyze code repositories and build graph representations of code structure. It captures relationships between definitions and references across files, enabling powerful code navigation and analysis capabilities.

Key features:

TSG Indexer is a library that uses tree-sitter-stack-graphs to analyze code repositories and build a graph representation of the code structure. This graph captures the relationships between definitions and references across files, enabling powerful code navigation and analysis.

Support for 20+ programming languages including Rust, Python, JavaScript, TypeScript, Java, and more Recursive directory traversal for comprehensive codebase analysis Multiple output formats (JSON, DOT graph) Optional CLI and LSP support via feature flags Ability to generate TSG files for unsupported languages The library is designed to be integrated with Model Control Protocol (MCP) servers and other tools that need code indexing and navigation capabilities. It leverages the tree-sitter parsing system and stack-graphs technology from GitHub to create a comprehensive code analysis solution.

Features

  • Support for multiple languages:
    • Rust
    • Python
    • JavaScript
    • TypeScript
    • Java
    • Swift
    • Objective-C
    • CSS
    • Scala
    • Zig
    • YAML
    • Go
    • PHP
    • XML
    • JSDoc
    • Bash
    • JSON
    • HTML
    • C#
    • Ruby
    • Markdown
    • Lua
    • Dart
    • And more!
  • Recursive directory traversal
  • Multiple output formats:
    • JSON
    • DOT graph
  • Feature flags for optional functionality:
    • cli - Command-line interface support
    • lsp - Language Server Protocol support

Installation

Add to your Cargo.toml:

[dependencies]
tsg_indexer = { version = "0.1.0", features = ["cli", "lsp"] }

Or clone and build the repository:

# Clone the repository
git clone https://github.com/entrepeneur4lyf/tsg_indexer.git
cd tsg_indexer

# Build the project
cargo build --release

Library Usage

use tsg_indexer::{IndexerConfig, run_indexer};
use std::path::PathBuf;

fn main() -> anyhow::Result<()> {
    // Create configuration
    let config = IndexerConfig {
        path: PathBuf::from("src/"),
        format: "json".to_string(),
        output: Some(PathBuf::from("output.json")),
        verbose: true,
    };
    
    // Run the indexer
    run_indexer(config)
}

CLI Usage

When built with the cli feature:

# Index a single file
tsg_indexer_cli examples/test_rust.rs

# Index a directory recursively
tsg_indexer_cli src/

# Output in DOT format
tsg_indexer_cli --format dot src/

# Output to a file
tsg_indexer_cli --output graph.json src/

# Verbose mode
tsg_indexer_cli --verbose src/

Use with MCP Servers

This library is designed to be used in Model Control Protocol (MCP) servers for code indexing and navigation capabilities. It provides the core functionality needed for parsing and analyzing code repositories with tree-sitter and stack-graphs.

MCP Integration

To integrate with an MCP server:

  1. Add tsg_indexer as a dependency with appropriate features
  2. Use the library's API to index code and build stack graphs
  3. Leverage the graph data for code navigation, reference finding, and more

Example

# Index the examples directory (with CLI feature enabled)
tsg_indexer_cli examples/

# The output will show the graph structure in JSON format by default

Contributing

Contributions are welcome! Here are some ways you can contribute:

  • Report bugs
  • Add support for more languages
  • Improve error handling
  • Add more output formats
  • Optimize performance

License

MIT License & Apache 2.0 License - I am not 100% sure how to properly license this lol.

Acknowledgments

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.