librian 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,155 @@
1
- # Temporary Holding Version
1
+ # librian-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Find and read the right section of a markdown docs folder without loading whole files.
4
+ librian gives AI agents a file list, per-file outlines with line ranges, section reads and section-level search, over MCP.
5
+ It keeps no saved index: every call reflects the files on disk at that moment, so it stays correct while several agents edit the same docs.
6
+
7
+ Status: early release. Tool inputs and output formats may still change before 1.0.
8
+
9
+ Requires Node.js 22.13 or newer.
10
+
11
+ ## Why
12
+
13
+ A large docs folder costs tokens twice: reading a whole file to find one section, and grepping lines that come back truncated.
14
+ librian answers with small, structured pieces instead: titles first, then only the section you ask for.
15
+
16
+ ## Get started
17
+
18
+ ```
19
+ npx -y librian@latest # or: npm i -g librian, then run `librian`
20
+ ```
21
+
22
+ This opens the librian menu. Then:
23
+
24
+ 1. **Runtime → Install**: installs librian into `~/.librian/runtime`.
25
+ 2. **Add docs folder**: give it a name and the path of a docs folder (see below). Repeat for more folders.
26
+ 3. **AI services**: switch on Claude Code and/or Codex, then **Apply**. librian shows the commands it will run and asks before running them.
27
+ 4. Open a new session in Claude Code or Codex. Sessions that are already open keep what they started with.
28
+
29
+ To update, open `librian` → **Runtime → Check for updates**. To undo a registration, switch the service off in **AI services** and **Apply**.
30
+
31
+ ## The menu
32
+
33
+ Run `librian` in a terminal. Without a terminal (a pipe or a script) it prints the usage instead.
34
+
35
+ ### Docs folders
36
+
37
+ The main screen lists your docs folders; each one is an entry with a name and a path, like a connection in a database tool.
38
+ Choose an entry to **Edit**, **Check** (file count, total size, largest files) or **Remove** it. Removing an entry never touches the folder itself.
39
+
40
+ An entry has:
41
+
42
+ | Field | Meaning |
43
+ | --- | --- |
44
+ | Name | 1 to 24 characters: a lowercase letter, then lowercase letters, digits or `_`. Defaults to the folder name (`akms.docs` becomes `akms_docs`). It prefixes the tool names. |
45
+ | Docs folder | Absolute path of the folder that holds the markdown files. |
46
+ | Exclude | Folder names (`evidence`) or root-relative paths (`ks/archive`) to skip. Folders starting with `.` and `node_modules` are always skipped. |
47
+ | Max bytes | Response size limit in UTF-8 bytes. Default 16000, minimum 4000. |
48
+
49
+ Symbolic links and junctions are not followed. librian only reads your docs; it never writes to them.
50
+
51
+ Adding, editing or removing an entry takes effect in new sessions only.
52
+
53
+ ### AI services
54
+
55
+ Registers librian as one MCP server named `librian` in **Claude Code** and **Codex**, for all your projects (user scope).
56
+ It runs `claude mcp add --scope user …` and `codex mcp add …` for you, and `… mcp remove …` to unregister.
57
+ Before running anything it shows the exact commands; unregistering asks with **No** as the default.
58
+ After registering it starts the server once and reports how many tools it offers (it does not call any tool).
59
+
60
+ A service whose command (`claude`, `codex`) is not on your `PATH` shows `command not found` and cannot be switched on.
61
+ If `librian` is already registered there with a different command, Apply replaces it and says so in the preview.
62
+
63
+ ### Runtime
64
+
65
+ librian installs itself with `npm install --prefix ~/.librian/runtime librian`, so the registered server does not depend on `npx` or a download at session start.
66
+ **Install**, **Check for updates** (asks npm only when you choose it) and **Update to X** do what they say; **Uninstall** removes the runtime folder and offers to unregister the services first.
67
+ Docs entries are kept.
68
+
69
+ ### Where things live
70
+
71
+ | Path | Content |
72
+ | --- | --- |
73
+ | `~/.librian/catalog.json` | Your entries and which services are registered. No secrets. |
74
+ | `~/.librian/runtime/` | The installed package. |
75
+
76
+ Set `LIBRIAN_HOME` to use another folder. When it is not the default, the registered command carries it along.
77
+
78
+ ## What the AI sees
79
+
80
+ One server, four tools per docs folder, prefixed with the entry name: for an entry `akms` the tools are `akms__list`, `akms__outline`, `akms__read` and `akms__search`.
81
+ Each tool description names its folder, and the server instructions list the folders with their file counts. A folder that is missing on disk offers no tools and is marked `unavailable`.
82
+
83
+ | Tool | Input | Returns |
84
+ | --- | --- | --- |
85
+ | `list` | `prefix?` | Files with size and document title, grouped by folder. `prefix` is a root-relative path start: `ks/ci` matches `ks/ci/…` and `ks/ci-notes.md`, `ks/ci/` matches the folder only. |
86
+ | `outline` | `ref` | Headings of a file or of one section, each with its line range and size. |
87
+ | `read` | `ref` | The text of a whole file, one section or a line range. |
88
+ | `search` | `query`, `prefix?`, `limit?`, `offset?` | Blocks that contain every word of the query, each with its `path:start-end`, ancestor headings, size, number of hits and a one-line excerpt. |
89
+
90
+ A typical session: `search` or `list` to find the file, `outline` to see its headings, `read` one section.
91
+
92
+ ### References
93
+
94
+ `outline` and `read` take a reference string, relative to the folder of the tool you call:
95
+
96
+ | Reference | Points to |
97
+ | --- | --- |
98
+ | `path` | The whole file |
99
+ | `path#heading` | The section under that heading. Give the heading text (`guide/setup.md#3.3 Pipes`) or its GitHub anchor (`guide/setup.md#33-pipes`). |
100
+ | `path:start-end` | A line range |
101
+ | `path:line` | The block containing that line |
102
+
103
+ `outline` accepts `path` and `path#heading` only.
104
+ When you pass a reference to another agent or write it into a document, prefer `path#heading`: line ranges move when the file is edited.
105
+
106
+ ### Search
107
+
108
+ - Words are separated by spaces; wrap a phrase in double quotes to keep it as one word. Matching ignores case.
109
+ - A word made only of letters, digits and `_` matches at the start of a word (`uat` matches `UAT` and `uat_token`, not `evaluate`). Other words, such as Korean, match anywhere.
110
+ - Every word must appear in the same block, a heading plus the text up to the next heading. Ancestor headings count, so a block under `## Release rail` matches `release deploy` even if only `deploy` is in its text.
111
+ - Results are ordered by words found in headings, then hits, then path and line.
112
+
113
+ ### Limits and continuing
114
+
115
+ Each response stays within the entry's byte limit (16000 by default, roughly 4–5 thousand tokens of Korean text).
116
+ When something is bigger, the response says how to get the rest:
117
+
118
+ - `read` of a large file returns its outline; `read` of a large section with subsections returns the section's own text plus the subsection outline.
119
+ - `read` of a large section without subsections returns the first page and ends with `Continue: path:next-end`. Pass that reference to `read` to get the next page.
120
+ - `search` and `list` end with `More: offset=N` or a hint to narrow with `prefix`.
121
+
122
+ ## Advanced: one folder, registered by hand
123
+
124
+ `librian serve --root <folder>` serves a single folder with unprefixed tools (`list`, `outline`, `read`, `search`), without the menu or the catalog:
125
+
126
+ ```
127
+ claude mcp add librian-docs -- npx -y librian serve --root ./docs
128
+ ```
129
+
130
+ On native Windows, if a client cannot start `npx` directly, wrap it: `claude mcp add librian-docs -- cmd /c npx -y librian serve --root ./docs`.
131
+
132
+ Codex (`~/.codex/config.toml`):
133
+
134
+ ```toml
135
+ [mcp_servers.librian-docs]
136
+ command = "npx"
137
+ args = ["-y", "librian", "serve", "--root", "/path/to/docs"]
138
+ ```
139
+
140
+ ```
141
+ librian serve --root <folder> [--exclude <name>]... [--max-bytes <n>]
142
+ librian serve --catalog
143
+ librian --help | --version
144
+ ```
145
+
146
+ `--root`, `--exclude` and `--max-bytes` mean what the entry fields above mean; `--root` exits with code 2 if the folder does not exist.
147
+ `serve --catalog` is what the registered services run: it reads `catalog.json` once at start.
148
+
149
+ ## Contributing
150
+
151
+ To run a checkout of this repository instead of the published package, build it (`npm run build`) and use **Runtime → Use a local checkout** in the menu.
152
+
153
+ ## License
154
+
155
+ AGPL-3.0-or-later. See [LICENSE](LICENSE) and [NOTICE](NOTICE).