mcp-llvm

animalang/mcp-llvm

3.2

If you are the rightful owner of mcp-llvm and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The MCP LLVM Documentation Server is a tool that provides real-time searchable access to LLVM documentation using the Model Context Protocol (MCP).

Tools
1
Resources
0
Prompts
0

MCP LLVM Documentation Server

A Model Context Protocol (MCP) server that provides searchable access to LLVM documentation. This allows AI assistants like Claude Code to search through LLVM documentation in real-time to answer questions about LLVM APIs, compiler internals, and more.

Features

  • Full-text search through LLVM documentation using Bleve
  • MCP-compliant JSON-RPC 2.0 protocol
  • Smart content extraction with HTML parsing and snippet generation
  • Fast indexing with concurrent worker pool
  • Configurable LLVM version and search backend

What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely access external tools and data sources. This server implements MCP to expose LLVM documentation search as a tool that can be used by any MCP-compatible client (like Claude Code).

Installation

Prerequisites

  • Go 1.24.4 or later
  • Git

Build from Source

git clone https://github.com/animalang/mcp-llvm.git
cd mcp-llvm
go build -o mcp-llvm

This will create the mcp-llvm executable in the current directory.

Usage

Running the Server

The server will automatically download and index LLVM documentation on first run:

./mcp-llvm

Command-Line Options

./mcp-llvm [flags]

Flags:
  -m, --mode string           Search backend mode: "bleve" or "semantic" (default: "bleve")
  -l, --llvm-version string   LLVM version to index (default: "21.1.2")
  -r, --repo-path string      Path to store LLVM documentation (default: "~/.mcp-llvm/docs")
  -i, --index-path string     Path to store search index (default: "~/.mcp-llvm/bleve-index")
  -h, --help                  Display help information

Example

# Use LLVM 21.1.2 (default)
./mcp-llvm

# Use a different LLVM version
./mcp-llvm --llvm-version 20.0.0

# Use custom paths
./mcp-llvm --repo-path /path/to/llvm-docs --index-path /path/to/index

Integration with Claude Code

To use this MCP server with Claude Code:

1. Build the Server

cd /path/to/mcp-llvm
go build -o mcp-llvm

2. Configure Claude Code

Edit your MCP configuration file:

macOS/Linux: ~/.config/claude-code/mcp.json Windows: %APPDATA%\claude-code\mcp.json

Add the following configuration:

{
  "mcpServers": {
    "llvm-docs": {
      "command": "/absolute/path/to/mcp-llvm",
      "args": [
        "--llvm-version", "21.1.2",
        "--mode", "bleve"
      ]
    }
  }
}

Note: The server will automatically use ~/.mcp-llvm/docs and ~/.mcp-llvm/bleve-index as default paths. You can override these with --repo-path and --index-path if needed.

Important: Replace /absolute/path/to/mcp-llvm with the actual absolute path to your built executable.

3. Restart Claude Code

After saving the configuration, restart Claude Code to load the new MCP server.

4. Using the Tool

Once configured, Claude Code will automatically have access to the llvm_search tool. You can ask questions like:

  • "How does LLVM's PassManager work?"
  • "What's the syntax for LLVM IR functions?"
  • "Explain LLVM's JIT compilation API"

Claude Code will automatically invoke the llvm_search tool when it needs information about LLVM.

How It Works

Architecture

┌─────────────┐         ┌─────────────┐         ┌──────────────┐
│ Claude Code │ ◄─────► │  MCP Server │ ◄─────► │ LLVM Docs    │
│  (Client)   │  stdio  │ (This tool) │         │ (Bleve Index)│
└─────────────┘         └─────────────┘         └──────────────┘

Workflow

  1. Initialization: On first run, the server clones the LLVM documentation from GitHub
  2. Indexing: HTML documentation files are indexed using Bleve for fast full-text search
  3. MCP Protocol: The server communicates with Claude Code via JSON-RPC 2.0 over stdin/stdout
  4. Search: When Claude needs LLVM info, it sends a search query to the server
  5. Results: The server returns relevant documentation snippets with titles and paths

MCP Tools Exposed

llvm_search

Search through LLVM documentation.

Parameters:

  • query (string, required): Search query (e.g., "PassManager", "JIT compilation")
  • limit (integer, optional): Maximum number of results (default: 5, max: 20)

Returns:

  • Array of documentation snippets with titles, file paths, and content excerpts

Project Structure

mcp-llvm/
├── cmd/
│   └── root.go           # CLI command definition
├── internal/
│   ├── mcp/
│   │   └── mcp.go        # MCP protocol implementation
│   ├── search/
│   │   ├── search.go     # Search interface
│   │   ├── bleve.go      # Bleve search backend
│   │   └── semantic.go   # Semantic search (stub)
│   └── repository/
│       └── repository.go # Git repo management
├── main.go               # Entry point
├── go.mod                # Go module definition
└── README.md             # This file

Development

Running Tests

go test ./...

Adding a New Search Backend

  1. Implement the SearchBackend interface in internal/search/search.go
  2. Add your backend to the factory in NewSearchBackend()
  3. Use the --mode flag to select your backend

Troubleshooting

Index Not Building

If the index fails to build, delete the index directory and try again:

rm -rf .llvm-docs/bleve-index
./mcp-llvm

Claude Code Can't Find the Tool

  1. Verify the path in mcp.json is absolute (not relative)
  2. Check that the executable has execute permissions: chmod +x mcp-llvm
  3. Look at Claude Code's logs for error messages
  4. Test the server manually by running it and sending JSON-RPC requests

Slow Performance

  • The first run will be slow as it clones and indexes documentation
  • Subsequent runs are fast because the index is cached
  • Consider using an SSD for better indexing performance

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

Resources