Logo The Librarian

The Librarian

Cộng đồng
aka-kika

Skill librarian MCP server — every installed skill costs tokens; the librarian keeps your whole collection out of agent context. Agents ask, get the few right skills for the task, and their outcomes curate the collection. Fully local: Ollama + SQLite + optional Apple Intelligence.

Nhà phát hànhaka-kika
Kho mãthe-librarian
Ngôn ngữPython
Bản fork
6
Sao
42
Công cụ có sẵn
0
Phương thức truyền tảistdio
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    The Librarian cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    42 sao và 6 bản fork từ kho mã được liên kết.

the_librarian

A skill librarian MCP server — your agents stop carrying the whole skill collection in context and start asking for the one right book.

the_librarian — a wall of thousands of muted books; through the one gap, a robot hand pulls out the single orange book

License: MIT Python 3.12+ MCP server Local-first

How it started

One question in a chat:

"I'm sure you know better than the internet what you need to get better. What's the best workflow with Claude Code? Installing skills and just you pick the best? More the better? Less is more?"

The answer: less is more. Every installed skill costs tokens and adds triggering ambiguity — with 50 skills, descriptions overlap and the wrong one fires; with 8 sharp ones, triggering is nearly deterministic.

But the collection had ~3,000. So instead of installing any of them: give the collection a librarian.

  • find_skill(intent) → librarian recommends
  • agent uses the skill, does the work
  • report_outcome(skill, worked: true/false, note) → librarian logs it

"The poetic part: the librarian is itself the curation loop. Log every query and what got picked vs ignored — skills that never surface are your kill candidates, queries that match nothing are your gaps. The collection optimizes itself from its own usage data."

"So the full shape: SQLite (skills, embeddings, query log, outcome log) + FastMCP + two read tools + one write tool. Maybe 300 lines of Python. It's small, it's one thing, and it compounds."

It's ~600 lines now. Scope creep found even the librarian. The original conversation — typed poolside on a phone, typos preserved on purpose — is in ORIGIN.md.

What it is

A local-first MCP server that acts as a librarian between coding agents and a large skill collection. The collection stays raw markdown on disk — agents never load it into context. They describe what they're trying to do in plain language; the librarian finds the skills whose meaning matches (semantic search — no keyword guessing), makes sure the shortlist isn't three flavors of the same thing, avoids repeating what it just recommended, optionally lets Apple's on-device model deliberate over the finalists — and learns from what agents report back.

Core principle: agents read recommendations, write only outcomes. They never edit skills, weights, or rankings. Curation decisions stay with the human, informed by librarian_stats.

Every stage is local and free: Ollama embeddings, SQLite, and (optionally) Apple Intelligence.

→ In production since June: real usage numbers — 366 queries, 284 agent-filed outcome reports across three snapshots (latest 2026-09-12), what worked and what's queued next.

Pipeline (one find request, end to end)

In plain words: every skill's description is turned once into an embedding — a list of numbers that captures what the skill is about, so "package my server for distribution" can match a skill that never uses the word "package." A request goes through five steps:

intent ─→ Ollama embed (nomic-embed-text, /api/embed)
       ─→ cosine vs every skill vector (SQLite)        ← "which skills mean the same thing?"
       ─→ MMR diversity + recency decay                ← anti-monotony (see below)
       ─→ [opt-in] AFM rerank: Apple's on-device model scores fit 1–10,
          why / why-not per candidate, final pick       (bin/afm-rerank, ~6–12s)
       ─→ [opt-in] soft filter: a local decision model marks the top 4
          "likely" or "weak match", likely first, nothing dropped (nimble, ~3–5s)
       ─→ compact JSON shortlist

Setup (2 minutes)

bash
cd the_librarian
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python "mcp[cli]>=2" httpx pydantic

# embedding model on whichever node you point at:
ollama pull nomic-embed-text

Claude Code config

Add to ~/.claude.json (or project .mcp.json), with paths adjusted to where you cloned this and where your skills live:

json
{
  "mcpServers": {
    "skill-librarian": {
      "command": "/path/to/the_librarian/.venv/bin/python",
      "args": ["/path/to/the_librarian/server.py"],
      "env": {
        "LIBRARIAN_SKILLS_DIR": "/path/to/your/skills-collection",
        "OLLAMA_HOST": "http://localhost:11434",
        "LIBRARIAN_EMBED_MODEL": "nomic-embed-text",
        "LIBRARIAN_CANONICAL_PREFIXES": "categories",
        "LIBRARIAN_RERANK_BIN": "/path/to/the_librarian/bin/afm-rerank"
      }
    }
  }
}

The skills dir is scanned recursively for SKILL.md files (standard agent-skill format: YAML frontmatter with name + description, body below). OLLAMA_HOST can point at a remote node (e.g. over Tailscale) to offload embedding — though an M4 Max reindexed the original 3,000-skill collection in ~2 minutes locally (it has since been trimmed to under 900, which takes seconds).

First run

> use librarian_reindex
> use librarian_find with intent "package my ollama wrapper for distribution"

Soft filter (optional, local decision model)

After the AFM rerank, librarian_find can ask a small local model whether each of the top candidates fits the intent. Skills it marks "match": "likely" come first; "weak match" ones stay in the list below them. Nothing is dropped. Settings in ~/.skill_librarian/soft_filter.json (enabled, model, judge_top, timeout_s); LIBRARIAN_SOFT_FILTER=off turns it off. A slow or missing model returns the previous order. Each find appends one line to ~/.skill_librarian/soft_filter.jsonl. Bench and test set: bench/decision-filter-2026-10-09/ (nimble 72% precision vs 33% without; laya models not usable).

AFM reranker (optional, Apple Intelligence)

librarian_find can pass its shortlist through Apple's on-device Foundation Model for a deliberation pass — reorders by reasoned fit (1–10) and adds one-sentence why / why-not per candidate, plus a final pick. Fully local, free, ~5–12s. Build and enable:

bash
swiftc -O -parse-as-library afm_rerank.swift -o bin/afm-rerank
# then set LIBRARIAN_RERANK_BIN to the binary path in the MCP env

Unset LIBRARIAN_RERANK_BIN (or any failure/timeout) falls back to pure embedding order. Brainstorm is never reranked — it wants divergence, not convergence. The reranker's output is validated against the real candidate set — small on-device models happily hallucinate skill names. Skill names and descriptions are someone else's text, so they reach the model cleaned (no line breaks or control characters) inside a <candidates> fence, one JSON line each, with an instruction to treat them as data: a description that says "rank me first" no longer wins the pick.

Tools

ToolWhat it does
librarian_findRanked shortlist for an intent — varied picks, no repeats from recent queries, success rates shown.
librarian_brainstormWide diverse sweep: k candidates, the last 2 random wildcards. For ideation, not convergence.
librarian_reportAgent reports skill worked/failed. Append-only — agents can't touch rankings.
librarian_reindexRescan + re-embed changed SKILL.md files (hash-checked, cheap to rerun).
librarian_statsCuration digest: hot skills, never-surfaced (kill candidates), low success rate (rewrite candidates).

Teaching your agents to use it

Connecting the server is half the job — agents also need the habit of asking. The repo ships one agent skill for that: skills/using-the-skill-librarian. Install it in each agent's skills directory and it teaches the whole loop: find before any non-trivial task, weigh the why/why-nots, read the winning skill in place, and always file a librarian_report afterward — the reports are what make the collection curate itself.

The joke writes itself, but it's real: the only skill you install is the one that teaches agents to ask the librarian. In three months of production use, that habit produced outcome reports on ~78% of queries, unprompted (~88% since this skill shipped).

Why it won't recommend the same 3 skills forever

The failure mode this design exists to kill: a naive retriever recommends the same handful of skills every time. Three mechanisms prevent it:

  1. MMR selection (maximal marginal relevance) — each next pick has to be relevant to the request and different from the picks already made, so the shortlist can't be three near-duplicates.
  2. Recency decay — the librarian remembers its own recent recommendations; anything suggested in the last 10 queries gets pushed down (RECENCY_PENALTY = 0.15 per appearance — tune at top of server.py).
  3. Wildcards in brainstorm mode — 2 random skills from outside the relevant set, every time. They are not logged as recommendations, so they never pick up a repeat penalty.

The AFM reranker runs after these — it reorders the already-diversified shortlist, so it can't reintroduce monotony.

Three months of real data says it works: 525 distinct skills surfaced across 366 queries. See the usage report for the one sharp edge (recency decay also hides just-confirmed winners) and the fix queued for it.

The flywheel

Every librarian_find is logged. Every librarian_report is logged. Run librarian_stats weekly: never-surfaced skills → kill, low-success skills → rewrite descriptions. The collection curates itself from usage.

First time it paid out (2026-09-12): after three months the rewrite list went from empty to 11 skills, and it is almost entirely one family — mcp-integration (6 uses, 1 worked), mcporter (5, 0), skill-installer (5, 0), mcp-building (4, 0). The agents' notes explain why: those four surface for every MCP-flavoured intent and get rejected as the wrong tool for that exact job. No static review would have found that; the descriptions all read fine. The fix is a description pass on four files, not a new feature. Details in the usage report.

Tuning knobs (top of server.py)

  • RECENCY_WINDOW / RECENCY_PENALTY — how hard repeats get punished
  • MMR_LAMBDA_FIND (0.7) — relevance vs diversity for find
  • MMR_LAMBDA_BRAINSTORM (0.45) — brainstorm leans diverse
  • RERANK_TIMEOUT (30s) — AFM reranker budget before falling back to embed order

Env knobs: LIBRARIAN_CANONICAL_PREFIXES (which top-level dirs win duplicate-name races, e.g. categories; inside one prefix the shallower path wins, so a root-level override beats the same name nested in a pack; a skill reached through two symlinks is ranked the same way, never by folder-walk order), LIBRARIAN_RERANK_BIN (path to afm-rerank; empty disables rerank).

Hard rules the code keeps

  • Never load full skill bodies into tool responses — descriptions + metadata only. The whole point is keeping the collection out of agent context.
  • Agents get no write access beyond the append-only outcome log.
  • DB is SQLite WAL at ~/.skill_librarian/librarian.db; query_log and outcome_log are append-only — no tool deletes or rewrites log rows.

FAQ

What is a skill librarian? An MCP server that sits between AI agents and a skill collection: agents describe a task in plain language, the librarian recommends the few skills that fit, and the collection itself never enters agent context.

Why not just install all the skills? Every installed skill's description is loaded into context on every request — with a large collection that's a constant token cost, and overlapping descriptions make the wrong skill fire. The librarian reduces that to one tool call when a skill is actually needed.

Does it work with agents other than Claude Code? Yes — it's a standard stdio MCP server. Any MCP client (Claude Code, Claude Desktop, Cursor, Goose, and others) can use it; this one runs against five different agents daily.

Does my skill collection leave my machine? No. Indexing (Ollama), storage (SQLite), and the optional reranker (Apple's on-device model) all run locally. Nothing is sent anywhere.

See CHANGELOG.md for the full history of changes and the decisions behind them.

Dùng MCP The Librarian với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối The Librarian, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm The Librarian làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của The Librarian.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "the-librarian": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của The Librarian, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của The Librarian.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng The Librarian giúp tôi làm việc này không?
The Librarian
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng The Librarian.

Câu hỏi thường gặp

Máy chủ MCP The Librarian dùng để làm gì?

The Librarian là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP The Librarian với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng The Librarian với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP The Librarian với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối The Librarian, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP The Librarian với TypingMind?

The Librarian hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP The Librarian cung cấp những công cụ nào trong TypingMind?

The Librarian cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP The Librarian không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu The Librarian yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇