Libragen

Libragen

Creates and searches private, local RAG libraries from documentation to ground AI assistants in authoritative sources, reducing hallucinations by providing current, accurate context from your own docs instead of relying on outdated training data.

Category
访问服务器

README

<p align="center"> <img src="packages/website/public/favicon.svg" alt="Libragen Logo" width="80" height="80"> </p>

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

<p align="center"> <em>(pronounced "LIB-ruh-jen")</em> </p>

<p align="center"> <strong>Stop your AI from hallucinating code, and ground it in your actual documentation</strong> </p>

<p align="center"> <a href="https://www.npmjs.com/package/@libragen/cli"><img src="https://img.shields.io/npm/v/@libragen/cli.svg?label=cli" alt="npm cli"></a> <a href="https://www.npmjs.com/package/@libragen/core"><img src="https://img.shields.io/npm/v/@libragen/core.svg?label=core" alt="npm core"></a> <a href="https://www.npmjs.com/package/@libragen/mcp"><img src="https://img.shields.io/npm/v/@libragen/mcp.svg?label=mcp" alt="npm mcp"></a> <a href="https://github.com/libragen/libragen/actions"><img src="https://github.com/libragen/libragen/actions/workflows/ci.yml/badge.svg" alt="CI"></a> <a href="https://github.com/libragen/libragen/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a> </p>

<p align="center"> <a href="https://libragen.dev">Documentation</a> • <a href="https://libragen.dev/docs/getting-started">Getting Started</a> • <a href="https://github.com/libragen/libragen/discussions">Discussions</a> </p>


Create private, local RAG libraries that ground your AI in real documentation—not 2-year-old training data. No cloud, no API keys, just single files you can share with your whole team.

What's RAG? Retrieval-Augmented Generation lets AI retrieve relevant context before responding, instead of relying solely on training data. libragen packages your docs into searchable libraries your AI can query.

🎯 Why libragen?

  • Ground AI in truth — Give your coding agents authoritative docs to cite, dramatically reducing hallucinations
  • Always current — Rebuild libraries when docs change; your AI gets the latest APIs, not stale training data
  • Private & local — Everything runs on your machine. No API keys, no cloud bills, no data leaving your network
  • Shareable — Single .libragen files work anywhere. Share via git, S3, or install from curated collections

✨ Features

  • � Hybrid Search — Combines vector similarity with BM25 keyword matching
  • 📊 Reranking — Optional cross-encoder reranking for improved relevance
  • 📦 Portable — Single-file SQLite databases with embedded vectors
  • 🧠 Smart Chunking — Language-aware splitting that respects code boundaries
  • 🌐 Multiple Sources — Build from local files or git repositories
  • 🤖 MCP Native — Works directly in Claude Desktop, VS Code, and any MCP client

📦 Packages

Package Description
@libragen/core Core library for embedding, chunking, storage
@libragen/cli Command-line interface for building and querying
@libragen/mcp Model Context Protocol server for AI assistants

🚀 Quick Start

Installation

npm install -g @libragen/cli

Build a Library

# From your internal docs
libragen build ./internal-api-docs --name internal-api

# From a private git repository
libragen build https://github.com/your-org/private-docs -o company-docs.libragen

# From any public repo
libragen build https://github.com/facebook/react -o react.libragen

Query a Library

libragen query "how to authenticate users" -l my-project.libragen

Use with AI Assistants

Install the MCP server globally:

npm install -g @libragen/mcp

Add to your Claude Desktop config (on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
   "mcpServers": {
      "libragen": {
         "command": "npx",
         "args": ["-y", "@libragen/mcp"]
      }
   }
}

Then install libraries to make them available:

libragen install my-project.libragen

� CLI Commands

Command Description
build <source> Build a library from files or git repo
query <query> Search a library for relevant content
info <library> Display library metadata
list List installed libraries and collections
install <source> Install a library or collection
uninstall <name> Remove an installed library or collection
update [name] Update installed libraries to newer versions
collection create Create a collection file
config Display configuration and paths
completions <action> Manage shell completions (bash, zsh, fish)

📚 Collections

Collections are JSON files that group libraries together for easy installation:

{
   "name": "my-stack",
   "description": "Libraries for my project",
   "version": "1.0.0",
   "items": [
      { "library": "https://example.com/react.libragen" },
      { "library": "https://example.com/typescript.libragen" },
      { "library": "https://example.com/testing.libragen", "required": false },
      { "collection": "https://example.com/base-web.json" }
   ]
}

Create a collection:

# Initialize a template
libragen collection init my-stack.json

# Or create with libraries directly
libragen collection create my-stack.json \
   -l ./react.libragen \
   -l ./typescript.libragen \
   -o ./testing.libragen

Install a collection:

libragen install ./my-stack.json        # Required libraries only
libragen install ./my-stack.json --all  # Include optional libraries

Collections support:

  • Nesting — Collections can include other collections
  • Deduplication — Libraries are only installed once
  • Optional items — Mark libraries as "required": false
  • Reference counting — Uninstalling removes only unreferenced libraries

⚙️ Configuration

Storage Location

By default, libragen stores libraries and configuration in a platform-specific directory:

Platform Default Location
macOS ~/Library/Application Support/libragen
Windows %APPDATA%\libragen
Linux $XDG_DATA_HOME/libragen (defaults to ~/.local/share/libragen)

Override this by setting the LIBRAGEN_HOME environment variable:

export LIBRAGEN_HOME=/custom/path/to/libragen

The directory structure is:

$LIBRAGEN_HOME/
  libraries/       # Installed .libragen files
  manifest.json    # Tracks installed libraries and collections
  collections.json # Collection configuration
  cache/           # Cached collection indexes

📄 Library Format

A .libragen file is a SQLite database containing:

  • Metadata — Library name, version, description, embedding model info
  • Chunks — Code/documentation segments with source file info
  • Embeddings — Vector representations using Xenova/bge-small-en-v1.5 (384 dims)
  • FTS Index — Full-text search index for keyword matching

📖 Programmatic Usage

Use @libragen/core directly in your TypeScript/JavaScript projects:

import { Library, Searcher, Embedder, Reranker } from '@libragen/core';

// Open an existing library and search it
const library = await Library.open('./my-docs.libragen');

const embedder = new Embedder();
await embedder.initialize();

const reranker = new Reranker();
await reranker.initialize();

const searcher = new Searcher(embedder, library.getStore(), { reranker });

const results = await searcher.search({
   query: 'how do I authenticate?',
   k: 5,
   rerank: true,  // Use cross-encoder reranking
});

for (const result of results) {
   console.log(`[${result.score.toFixed(3)}] ${result.sourceFile}`);
   console.log(result.content);
}

await library.close();
import { Builder } from '@libragen/core';

// Build a library from source files
const builder = new Builder();
const result = await builder.build('./docs', {
   name: 'my-docs',
   description: 'Internal API documentation',
   include: ['**/*.md', '**/*.mdx'],
});

console.log(`Built ${result.outputPath} with ${result.stats.chunkCount} chunks`);

🛠️ Development

# Install dependencies
npm install

# Run tests
npm test

# Run linting
npm run standards

# Build all packages
npm run build

🏗️ Architecture

@libragen/cli (build, query, install, manage)
        │
        ▼
@libragen/core
  ├── Embedder (bge-small-en-v1.5)
  ├── Chunker (language-aware splitting)
  ├── VectorStore (SQLite + sqlite-vec + FTS5)
  ├── Searcher (hybrid search with RRF)
  ├── Reranker (mxbai-rerank-xsmall-v1)
  ├── Library (create/open/validate)
  ├── LibraryManager (install/uninstall/update)
  ├── Manifest (tracks installations)
  ├── CollectionResolver (nested collections)
  └── Sources (FileSource, GitSource)
        │
        ▼
@libragen/mcp (MCP server for AI assistants)
  Tools: libragen_search, libragen_list, libragen_build,
         libragen_install, libragen_uninstall, libragen_update,
         libragen_collection

🙏 Acknowledgments

libragen uses the following open-source models:

If you use libragen in academic work, please cite the underlying models:

@misc{bge_embedding,
   title={C-Pack: Packaged Resources To Advance General Chinese Embedding},
   author={Shitao Xiao and Zheng Liu and Peitian Zhang and Niklas Muennighoff},
   year={2023},
   eprint={2309.07597},
   archivePrefix={arXiv},
   primaryClass={cs.CL}
}

@online{rerank2024mxbai,
   title={Boost Your Search With The Crispy Mixedbread Rerank Models},
   author={Aamir Shakir and Darius Koenig and Julius Lipp and Sean Lee},
   year={2024},
   url={https://www.mixedbread.ai/blog/mxbai-rerank-v1},
}

📜 License

MIT — see LICENSE for details.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选