Knowledge base MCP server · native RAG hybrid retrieval

One knowledge base, every agent plugged in

Spin up one knowledge base every agent shares — no one rebuilds from scratch.

A single binary, one command, MCP over HTTP built in: Claude, Cursor, or your own agent just connects to one endpoint and shares the same knowledge base. Chinese-native hybrid retrieval, end-to-end traceability, and workspace isolation are what make it dependable.

0
external deps (standalone)
1
binary, full stack
6
file formats
2
deploy modes
langhuan — 80×24
$ make standalone
✔ langhuan started (single binary, zero deps)
✔ SQLite db + keys auto-provisioned
✔ MCP over HTTP at :8080/mcp

$ curl :8080/mcp -d '{"tool":"knowledge_search","query":"how to configure hybrid retrieval"}'
{ "hits": [{ "content": "vector + full-text two-path recall…" }] }

Why · Why Langhuan exists

Building agents, you’ll run into these sooner or later

These are the common ones, and how Langhuan answers each.

Every agent rebuilds its own knowledge base

When the second and third agents ship, ingestion, permissions, and retrieval are rebuilt each time, producing inconsistent sets of facts.

Langhuan — Distill knowledge processing into one layer of infrastructure, served over MCP to every agent, reusing the same facts.

How this gets solved

Chinese keyword search misses

Pure vector retrieval can’t reliably find contract codes, product names, or proper nouns — keywords get swallowed by the whole sentence.

Langhuan — zhparser / gse Chinese tokenization plus two-path vector recall, fused with deterministic RRF — exact terms and semantics both hit.

How hybrid search works

Retrieval can’t cite its sources

Which document, which version did this answer come from? You can’t say, so debugging is guesswork and auditing is impossible.

Langhuan — Every chunk carries a source anchor (document / version / page); every retrieval has a stable search_id that admins can replay by original query.

Deployment is too heavy to even try

You want to validate value first, but PostgreSQL + Redis + multiple containers stop you at the door.

Langhuan — One binary plus one .db file, zero-config — no Docker, PG, or Redis. Download and run.

Download

It makes things up when there’s no answer

The knowledge base has nothing, but the model confabulates confidently — the classic RAG hallucination.

Langhuan — Langhuan returns evidence, never fabricates answers: retrieval_status distinguishes available / empty / degraded, so you know whether nothing was recalled or there truly is no answer.

Position · Where Langhuan sits

Langhuan is shared knowledge infrastructure for agents — not yet another RAG framework

When your agents grow from one to many, the knowledge base shouldn’t be rebuilt each time. Langhuan spins up one knowledge base that every agent connects to over MCP; Chinese-native hybrid retrieval, end-to-end traceability, and single-binary zero-config deployment are what make it dependable. It generates no answers and orchestrates no agents — that is the essential difference from app platforms like Dify/RAGFlow: it sits beneath them.

Highlights

A knowledge layer built for production-grade RAG

No LLM answer generation, no chat orchestration — just taking "document → traceable retrieval" as far as it can go, as the knowledge foundation for any LLM app, MCP client, or agent.

Hybrid retrieval, Chinese-native

Chinese-native hybrid retrieval

pgvector embeddings + PostgreSQL FTS (zhparser), or SQLite + gse Chinese tokenization, with two-path recall and deterministic RRF fusion. Chinese keywords are no longer treated as a whole sentence; recall quality works out of the box.

Websites as content sources

Websites as content sources

Three ingestion modes (crawl/sitemap/urls), four engines (http/render/firecrawl/jina with auto escalation), pages indexed alongside uploaded files; three-tier change detection, robots compliance, global in-flight isolation.

First-class MCP over HTTP

First-class MCP over HTTP

Tools like knowledge_search and document_ingest are exposed directly to MCP clients. Claude, Cursor, and others can use them immediately, with no extra bridge.

Single binary, full stack

Single binary, full stack

REST + MCP + async workers + Web Console embedded in one binary (go:embed). Zero-config: one binary plus one .db file, no PostgreSQL, no Redis.

Fully traceable

Fully traceable

Every chunk traces back to its source document, version, and page/line/offset anchor. Ingest, chunking, and indexing are idempotent end to end, with the database as the source of truth.

Workspace-scoped isolation

Workspace-scoped isolation

A workspace is the tenant boundary. Member roles plus API keys scoped to specific knowledge bases provide fine-grained auth, and unauthorized access consistently returns 404.

A library, retrievable at will

A library, retrievable at will

Document → normalized fact layer → searchable projection, atomically published to a single active Generation. The knowledge base is the library; retrieval is fetching a book.

Architecture

Data flow: from document to traceable retrieval

1IngestFile / Web / FAQ → stable Document + immutable Revision
2Processasync task chain: parse → asset archive → chunk → index (idempotent)
3ProjectRetrievalEntry: halfvec vector + FTS tsvector + return content in one row
4Retrievevector + FTS two-path recall → deterministic RRF fusion → rerank → anchored evidence
5Publishatomically published to one active Generation, replayable within retention
6ServeREST /api/v1/* · MCP /mcp · Web Console

Baseline:Go 1.26 · Gin · GORM · PostgreSQL 17 + pgvector · FTS · asynq + Redis · SQLite standalone (sqlite-vec + FTS5 + gse)

Quick Start

One command, a complete knowledge service

No Docker, PostgreSQL, or Redis: run the langhuan binary directly and it auto-provisions a SQLite database, keys, and config on first start. Open http://127.0.0.1:8080 to initialize, then ingest and search. For production concurrency, use the PostgreSQL + Redis deployment.

# Zero external dependencies; no Docker / PostgreSQL / Redis
$ git clone https://github.com/amoydavid/langhuan.git
$ cd langhuan && make standalone
直接下载二进制(无需构建)macOS / Linux / Windows · 解压即用
1

Initialize

Create an admin account

2

Ingest

Create a knowledge base, upload pdf/md/txt/csv/xlsx/docx, or attach web sources that crawl pages automatically

3

Search

Consistent retrieval across REST / Web / MCP

Positioning

Not a Dify / RAGFlow replacement — the layer beneath them

Langhuan pushes "knowledge processing and retrieval" as far as it can go, then exposes it to upper-layer apps over MCP.

LanghuanDify / RAGFlow and similar platforms
PositionKnowledge layer (no LLM orchestration)App platform (with Chat / Agent)
Keyword retrievalNative zhparser / gse tokenization + RRFVector-dependent, weaker FTS
DeliverySingle binary + one .db file (zero-dep option)Multi-container suite
MCPNative MCP over HTTPExtra bridge required
Traceabilitychunk → page/line anchor, full chainPartial
IntegrationAs the knowledge foundation for your appIn-platform closed loop

Integrations

Fits the toolchain you already have

MCP clients

Claude DesktopCursorany MCP over HTTP client

File formats

PDFDOCXMarkdownTXTCSVXLSX

Retrieval stack

pgvectorzhparsergsesqlite-vecPostgreSQL FTS

FAQ

Frequently asked questions

How is Langhuan different from Dify / RAGFlow?+

Langhuan is not an app platform — it is a knowledge layer. It does not generate LLM answers or orchestrate chat/agents; it takes "document → traceable retrieval" to production grade and exposes it to upper layers over MCP.

Does Langhuan support Chinese retrieval?+

Yes, and natively. The full-text path uses zhparser (production) or gse (standalone) Chinese tokenization, and after two-path recall with embeddings, results are fused with deterministic RRF.

How do I connect Langhuan to an MCP client?+

Langhuan serves MCP over HTTP natively at /mcp, using a workspace API key as a Bearer token. MCP clients like Claude and Cursor just need one endpoint to call it.

What do I need to deploy it?+

Zero-config: run the langhuan binary directly and it auto-provisions a SQLite database and keys — no Docker, PostgreSQL, or Redis. For production concurrency, use PostgreSQL + Redis.

How do I download Langhuan?+

Download a prebuilt binary for macOS (Apple Silicon / Intel), Linux, or Windows — unzip and run, no Docker, PostgreSQL, or Redis required. See the download page on this site.

Journal · Blog

Judgments written down from practice

Aug 25, 202614 min read

How a Chinese Question Sentence Zeroed Out Our Full-Text Search

An everyday question like "埃及有哪些民族?" returns literally nothing from SQLite FTS5 Chinese full-text search — and hybrid retrieval quietly degrades to vector-only, with no errors, no alerts, and normal-looking metrics. The mechanism, the query-side fix, and how to check whether your FTS channel is already spinning in neutral.

Aug 25, 202616 min read

We Benchmarked Our Own RAG Retrieval — and the First Smoke Run Caught Two Production Bugs

The metric that matters most for a knowledge base product is retrieval quality, and all we had were functional tests. How Langhuan built a retrieval eval with 200 human-annotated real queries, a dual-track channel matrix, and bit-identical reproducibility — plus the production bugs it caught on day one and the hybrid-search hypothesis it finally confirmed with data.

Give your agents one shared knowledge base

One command to start, every agent plugged in. Chinese-native hybrid retrieval, end-to-end traceability, single-binary zero-config.