mcp-kb 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl
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.
- mcp_kb/cli/__init__.py +1 -0
- mcp_kb/cli/args.py +175 -0
- mcp_kb/cli/main.py +181 -0
- mcp_kb/cli/reindex.py +113 -0
- mcp_kb/cli/runtime_config.py +421 -0
- mcp_kb/data/KNOWLEDBASE_DOC.md +151 -0
- mcp_kb/data/__init__.py +1 -0
- mcp_kb/ingest/__init__.py +1 -0
- mcp_kb/ingest/chroma.py +1287 -0
- mcp_kb/knowledge/__init__.py +1 -0
- mcp_kb/knowledge/bootstrap.py +44 -0
- mcp_kb/knowledge/events.py +105 -0
- mcp_kb/knowledge/search.py +177 -0
- mcp_kb/knowledge/store.py +294 -0
- mcp_kb/security/__init__.py +1 -0
- mcp_kb/security/path_validation.py +108 -0
- mcp_kb/server/__init__.py +1 -0
- mcp_kb/server/app.py +201 -0
- mcp_kb/ui/__init__.py +17 -0
- mcp_kb/ui/api.py +377 -0
- mcp_kb/ui/assets/assets/index.css +1 -0
- mcp_kb/ui/assets/index.html +62 -0
- mcp_kb/ui/server.py +332 -0
- mcp_kb/utils/__init__.py +1 -0
- mcp_kb/utils/filesystem.py +128 -0
- mcp_kb-0.3.3.dist-info/METADATA +338 -0
- mcp_kb-0.3.3.dist-info/RECORD +32 -0
- mcp_kb-0.3.1.dist-info/METADATA +0 -181
- mcp_kb-0.3.1.dist-info/RECORD +0 -7
- {mcp_kb-0.3.1.dist-info → mcp_kb-0.3.3.dist-info}/WHEEL +0 -0
- {mcp_kb-0.3.1.dist-info → mcp_kb-0.3.3.dist-info}/entry_points.txt +0 -0
- {mcp_kb-0.3.1.dist-info → mcp_kb-0.3.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,338 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: mcp-kb
|
3
|
+
Version: 0.3.3
|
4
|
+
Summary: MCP server exposing a local markdown knowledge base
|
5
|
+
Author: LLM Maintainer
|
6
|
+
Requires-Python: >=3.11
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
Requires-Dist: httpx>=0.28.1
|
9
|
+
Requires-Dist: mcp[cli]>=1.15.0
|
10
|
+
Requires-Dist: pydantic>=2.11.9
|
11
|
+
Provides-Extra: vector
|
12
|
+
Requires-Dist: chromadb>=1.1.0; extra == "vector"
|
13
|
+
Requires-Dist: tiktoken>=0.11.0; extra == "vector"
|
14
|
+
Requires-Dist: langchain-text-splitters>=0.3.11; extra == "vector"
|
15
|
+
Requires-Dist: umap-learn>=0.5.9.post2; extra == "vector"
|
16
|
+
Provides-Extra: sentence-transformer
|
17
|
+
Requires-Dist: mcp-kb[vector]; extra == "sentence-transformer"
|
18
|
+
Requires-Dist: sentence-transformers>=5.1.1; extra == "sentence-transformer"
|
19
|
+
|
20
|
+
# MCP Knowledge Base Server
|
21
|
+
|
22
|
+
A local, text‑only knowledge base exposed as an MCP server with optional HTTP/SSE transports and a built‑in web UI. Supports creating, reading, updating, searching, and soft‑deleting UTF‑8 text files. Optionally mirrors content to Chroma for semantic search and 2D/3D vector visualization.
|
23
|
+
|
24
|
+
## Highlights
|
25
|
+
|
26
|
+
- **MCP tools** for file lifecycle + search
|
27
|
+
- **HTTP/SSE transports** and a minimal **built‑in UI**
|
28
|
+
- **Deterministic path validation** and **soft deletes**
|
29
|
+
- **Optional Chroma mirroring** for semantic search and vector plotting
|
30
|
+
- **No lock‑in**: works with any Python toolchain (pip/pipx/Poetry/PDM/Rye/etc.)
|
31
|
+
|
32
|
+
---
|
33
|
+
|
34
|
+
## Table of contents
|
35
|
+
|
36
|
+
- [Quick start](#quick-start)
|
37
|
+
- [How it works](#how-it-works)
|
38
|
+
- [CLI usage](#cli-usage)
|
39
|
+
- [MCP tools](#mcp-tools)
|
40
|
+
- [Human UI](#human-ui)
|
41
|
+
- [UI HTTP API](#ui-http-api)
|
42
|
+
- [Optional: ChromaDB mirroring](#optional-chromadb-mirroring)
|
43
|
+
- [Reindexing CLI](#reindexing-cli)
|
44
|
+
- [Persistent CLI defaults](#persistent-cli-defaults)
|
45
|
+
- [Path rules & safety](#path-rules--safety)
|
46
|
+
- [Testing](#testing)
|
47
|
+
- [Integrating with LLM clients](#integrating-with-llm-clients)
|
48
|
+
- [Troubleshooting](#troubleshooting)
|
49
|
+
|
50
|
+
---
|
51
|
+
|
52
|
+
## Quick start
|
53
|
+
|
54
|
+
**Prereqs:** Python 3.11+ is required. :contentReference[oaicite:1]{index=1}
|
55
|
+
|
56
|
+
**Install (choose one):**
|
57
|
+
|
58
|
+
- From PyPI:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
python -m pip install mcp-kb
|
62
|
+
```
|
63
|
+
|
64
|
+
**Run the server (HTTP transport + UI):**
|
65
|
+
|
66
|
+
```bash
|
67
|
+
mcp-kb-server --root /path/to/knowledgebase --transport http
|
68
|
+
# Alternative if entry points aren't on PATH:
|
69
|
+
python -m mcp_kb.cli.main --root /path/to/knowledgebase --transport http
|
70
|
+
```
|
71
|
+
|
72
|
+
On first launch, a documentation file is installed at `.data/KNOWLEDBASE_DOC.md`. The UI binds to port **8765** by default and increments until free, logging a URL like:
|
73
|
+
|
74
|
+
```
|
75
|
+
UI available at http://127.0.0.1:8765
|
76
|
+
```
|
77
|
+
|
78
|
+
> **Note:** The server defaults to `stdio` only. Add `--transport sse` and/or `--transport http` to enable network transports.
|
79
|
+
|
80
|
+
---
|
81
|
+
|
82
|
+
## How it works
|
83
|
+
|
84
|
+
- **KnowledgeBase**: safe, validated file operations (create/read/append/regex/soft‑delete).
|
85
|
+
- **MCP server**: exposes the operations as MCP tools over chosen transports.
|
86
|
+
- **Human UI**: small web UI for browsing, editing, and searching files.
|
87
|
+
- **Optional vector layer**: if Chroma is configured, semantic search and a 3D scatter of embeddings appear in the UI.
|
88
|
+
|
89
|
+
---
|
90
|
+
|
91
|
+
## CLI usage
|
92
|
+
|
93
|
+
The package exposes these entry points: `mcp-kb` / `mcp-kb-server` (run server) and `mcp-kb-reindex` (offline reindex).
|
94
|
+
|
95
|
+
Common flags (server):
|
96
|
+
|
97
|
+
- `--root <path>`: KB root directory (relative paths are enforced internally)
|
98
|
+
- `--transport {stdio|sse|http}` (repeatable; default: `stdio`)
|
99
|
+
- `--host <ip>` / `--port <int>`: apply to HTTP/SSE transports
|
100
|
+
- `--ui-port <int>`: starting port for UI (default 8765; auto‑increments if busy)
|
101
|
+
- `--no-ui`: disable the UI even if HTTP/SSE is active
|
102
|
+
|
103
|
+
Examples:
|
104
|
+
|
105
|
+
```bash
|
106
|
+
# stdio only (default):
|
107
|
+
mcp-kb-server --root /path/to/kb
|
108
|
+
|
109
|
+
# HTTP + SSE + stdio:
|
110
|
+
mcp-kb-server --root /path/to/kb \
|
111
|
+
--transport stdio --transport sse --transport http \
|
112
|
+
--host 0.0.0.0 --port 9000
|
113
|
+
```
|
114
|
+
|
115
|
+
---
|
116
|
+
|
117
|
+
## MCP tools
|
118
|
+
|
119
|
+
All tools operate on **relative** paths inside the KB root and respect soft‑deletes.
|
120
|
+
|
121
|
+
- `create_file(path, content) -> str`
|
122
|
+
- `read_file(path, start_line?, end_line?) -> {path, start_line, end_line, content}`
|
123
|
+
- `append_file(path, content) -> str`
|
124
|
+
- `regex_replace(path, pattern, replacement) -> {replacements}`
|
125
|
+
- `delete(path) -> str` _(soft delete; renames file with sentinel)_
|
126
|
+
- `search(query, limit=5) -> [FileSegment...]` _(semantic first if Chroma is on; otherwise literal scan)_
|
127
|
+
- `overview() -> str`
|
128
|
+
- `documentation() -> str`
|
129
|
+
|
130
|
+
`read_file` and `search` return **FileSegment** objects with `start_line`, `end_line`, and `content`. Line indices are **0‑based inclusive** in the JSON the server emits.
|
131
|
+
|
132
|
+
---
|
133
|
+
|
134
|
+
## Human UI
|
135
|
+
|
136
|
+
- Menu: **Browse** (always) and **Vectors** (when a vector store is available).
|
137
|
+
- Browse: left tree, right editor, Save/Cancel/Delete, and **New File**.
|
138
|
+
- Search: sidebar search filters the tree; clicking a result opens the file and highlights the matched lines. When vectors are available, the plot highlights results and the query point.
|
139
|
+
|
140
|
+
---
|
141
|
+
|
142
|
+
## UI HTTP API
|
143
|
+
|
144
|
+
Base path is the UI origin.
|
145
|
+
|
146
|
+
- `GET /api/tree` → file tree (nested `{name, path, type, children}`)
|
147
|
+
- `GET /api/file?path=<rel>` → `{path, start_line, end_line, content}`
|
148
|
+
- `PUT /api/file` (JSON `{path, content}`) → `204` on success
|
149
|
+
- `DELETE /api/file?path=<rel>` → `204` on success
|
150
|
+
- `GET /api/search?query=<text>&limit=<int>` →
|
151
|
+
|
152
|
+
```json
|
153
|
+
{
|
154
|
+
"results": [
|
155
|
+
{ "path": "notes/a.md", "start_line": 10, "end_line": 12, "content": "..." }
|
156
|
+
],
|
157
|
+
"meta": {
|
158
|
+
"query_embeddings": [ ... ],
|
159
|
+
"query_embeddings_umap2d": [x, y],
|
160
|
+
"query_embeddings_umap3d": [x, y, z]
|
161
|
+
}
|
162
|
+
}
|
163
|
+
```
|
164
|
+
|
165
|
+
_(Meta fields appear when Chroma is enabled.)_
|
166
|
+
|
167
|
+
**Vector endpoints** (visible when Chroma is configured):
|
168
|
+
|
169
|
+
- `GET /api/vector/status` → `{ "available": bool, "dimensions": int|null, "count": int|null }`
|
170
|
+
- `GET /api/vector/embeddings?limit=<int>&offset=<int>&path=<rel?>` → `[ { id, document_id, path, chunk, embedding, umap2d?, umap3d? } ]`
|
171
|
+
- `GET /api/vector/query_embedding?query=<text>` → `{ embedding: number[], used_model: string|null }`
|
172
|
+
- `POST /api/vector/reindex` → `{ status: "queued"|"running"|"unavailable"|"error" }`
|
173
|
+
- `POST /api/vector/refit` → `{ status: "queued"|"unavailable"|"error" }`
|
174
|
+
|
175
|
+
---
|
176
|
+
|
177
|
+
## Optional: ChromaDB mirroring
|
178
|
+
|
179
|
+
Install the vector extras (pick what you need):
|
180
|
+
|
181
|
+
```bash
|
182
|
+
# core vector support (Chroma, UMAP integration, splitters)
|
183
|
+
python -m pip install 'mcp-kb[vector]'
|
184
|
+
|
185
|
+
# add Sentence Transformers embedding support
|
186
|
+
python -m pip install 'mcp-kb[sentence-transformer]'
|
187
|
+
```
|
188
|
+
|
189
|
+
Enable via CLI flags (examples):
|
190
|
+
|
191
|
+
```bash
|
192
|
+
mcp-kb-server \
|
193
|
+
--root /path/to/kb \
|
194
|
+
--transport http \
|
195
|
+
--chroma-client ephemeral \
|
196
|
+
--chroma-collection local-kb \
|
197
|
+
--chroma-embedding default
|
198
|
+
```
|
199
|
+
|
200
|
+
Supported clients: `off`, `ephemeral`, `persistent`, `http`, `cloud`. All `--chroma-*` flags have `MCP_KB_CHROMA_*` env var equivalents (e.g., `MCP_KB_CHROMA_CLIENT=http`, `MCP_KB_CHROMA_HOST=...`). Chunking can be tuned with `--chroma-chunk-size` and `--chroma-chunk-overlap`.
|
201
|
+
|
202
|
+
---
|
203
|
+
|
204
|
+
## Reindexing CLI
|
205
|
+
|
206
|
+
Rebuild the Chroma index from disk without running the MCP transports:
|
207
|
+
|
208
|
+
```bash
|
209
|
+
mcp-kb-reindex --root /path/to/kb \
|
210
|
+
--chroma-client persistent \
|
211
|
+
--chroma-data-dir /path/to/chroma \
|
212
|
+
--chroma-collection knowledge-base \
|
213
|
+
--chroma-embedding default
|
214
|
+
```
|
215
|
+
|
216
|
+
This processes all active text files and updates the collection; some tests assert the reindex path mirrors content exactly.
|
217
|
+
|
218
|
+
---
|
219
|
+
|
220
|
+
## Persistent CLI defaults
|
221
|
+
|
222
|
+
Resolved CLI/environment settings are persisted per KB root at:
|
223
|
+
|
224
|
+
```
|
225
|
+
<root>/.data/cli-config.json
|
226
|
+
```
|
227
|
+
|
228
|
+
Future runs inherit these defaults unless overridden by new flags or env vars. Delete or edit the file to reset.
|
229
|
+
|
230
|
+
---
|
231
|
+
|
232
|
+
## Path rules & safety
|
233
|
+
|
234
|
+
- **Relative paths only.** Absolute paths and `..` traversal are rejected.
|
235
|
+
- **`.data/` is read‑only** for writes (reads allowed).
|
236
|
+
- **Soft delete**: files renamed with a sentinel; hidden from listing/search.
|
237
|
+
- Writes are serialized with per‑file locks to avoid corruption.
|
238
|
+
|
239
|
+
These rules are enforced in the validation and filesystem helpers.
|
240
|
+
|
241
|
+
---
|
242
|
+
|
243
|
+
## Testing
|
244
|
+
|
245
|
+
Install test deps and run:
|
246
|
+
|
247
|
+
```bash
|
248
|
+
python -m pip install pytest
|
249
|
+
pytest -q
|
250
|
+
```
|
251
|
+
|
252
|
+
Vector‑related tests are skipped if Chroma isn’t installed. To run them:
|
253
|
+
|
254
|
+
```bash
|
255
|
+
python -m pip install 'mcp-kb[vector]'
|
256
|
+
pytest -q
|
257
|
+
```
|
258
|
+
|
259
|
+
The suite exercises the real HTTP UI, vector endpoints, CLI config persistence, and FastMCP flows.
|
260
|
+
|
261
|
+
---
|
262
|
+
|
263
|
+
## Integrating with LLM clients
|
264
|
+
|
265
|
+
Provide the server command your client can execute. Two portable options:
|
266
|
+
|
267
|
+
- **Executable** (preferred if on PATH):
|
268
|
+
|
269
|
+
```json
|
270
|
+
{
|
271
|
+
"command": "mcp-kb-server",
|
272
|
+
"args": ["--root", "/absolute/path/.knowledgebase", "--transport", "stdio"]
|
273
|
+
}
|
274
|
+
```
|
275
|
+
|
276
|
+
- **Python module** (works even without entry points on PATH):
|
277
|
+
|
278
|
+
```json
|
279
|
+
{
|
280
|
+
"command": "python",
|
281
|
+
"args": [
|
282
|
+
"-m",
|
283
|
+
"mcp_kb.cli.main",
|
284
|
+
"--root",
|
285
|
+
"/absolute/path/.knowledgebase",
|
286
|
+
"--transport",
|
287
|
+
"stdio"
|
288
|
+
]
|
289
|
+
}
|
290
|
+
```
|
291
|
+
|
292
|
+
Examples:
|
293
|
+
|
294
|
+
- **Claude Desktop** (`claude_desktop_config.json`):
|
295
|
+
|
296
|
+
```json
|
297
|
+
{
|
298
|
+
"mcpServers": {
|
299
|
+
"local-kb": {
|
300
|
+
"command": "mcp-kb-server",
|
301
|
+
"args": [
|
302
|
+
"--root",
|
303
|
+
"/absolute/path/.knowledgebase",
|
304
|
+
"--transport",
|
305
|
+
"stdio"
|
306
|
+
]
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
```
|
311
|
+
|
312
|
+
- **VS Code (Claude MCP Extension)** (`settings.json`):
|
313
|
+
|
314
|
+
```json
|
315
|
+
{
|
316
|
+
"claudeMcp.servers": {
|
317
|
+
"local-kb": {
|
318
|
+
"command": "mcp-kb-server",
|
319
|
+
"args": [
|
320
|
+
"--root",
|
321
|
+
"/absolute/path/.knowledgebase",
|
322
|
+
"--transport",
|
323
|
+
"stdio"
|
324
|
+
],
|
325
|
+
"env": { "MCP_KB_ROOT": "/absolute/path/.knowledgebase" }
|
326
|
+
}
|
327
|
+
}
|
328
|
+
}
|
329
|
+
```
|
330
|
+
|
331
|
+
---
|
332
|
+
|
333
|
+
## Troubleshooting
|
334
|
+
|
335
|
+
- **“Absolute paths are not permitted”** → Use a **relative** path in tools and UI.
|
336
|
+
- **“Writes are not allowed inside the protected folder '.data'”** → Choose a different directory (e.g., `docs/`).
|
337
|
+
- **Vector endpoints missing** → You didn’t install/enable the vector extras or a Chroma client.
|
338
|
+
- **UI port in use** → Set `--ui-port` to another number; it auto‑increments if busy.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
mcp_kb/__init__.py,sha256=Ry7qODhfFQF6u6p2m3bwGWhB0-BdWTQcHDJB7NBYAio,74
|
2
|
+
mcp_kb/config.py,sha256=NUpzjDH4PQw4FyjGgYUcMsGMeenNiZTMrQj4U62xKlk,2530
|
3
|
+
mcp_kb/cli/__init__.py,sha256=dEIRWFycAfPkha1S1Bj_Y6zkvEZv4eF0qtbF9t74r60,67
|
4
|
+
mcp_kb/cli/args.py,sha256=NaAcxW6WzRZeDLEASKx6tPu3RDeJLX0cDkn2yeLSNZc,5904
|
5
|
+
mcp_kb/cli/main.py,sha256=t8zDokpVjRPkkhYBO4UGhHRHJifp4jAuxxbFQP4lQLE,5910
|
6
|
+
mcp_kb/cli/reindex.py,sha256=JxukrYWWurEk2DlyIEUNF6PzGbNSSwsw_XJ6-ABwIvs,3829
|
7
|
+
mcp_kb/cli/runtime_config.py,sha256=Lwb5IIINCQeidqP6Ev5JO_uqwhLpPsTokerQA8yIfPE,13077
|
8
|
+
mcp_kb/data/KNOWLEDBASE_DOC.md,sha256=xnLUJIK8WvdLxqm-rkjL00brpb3hvZHeNVpuqf_3w4E,6704
|
9
|
+
mcp_kb/data/__init__.py,sha256=UYYuO_n2ikjpwkPSykgleiifYvC0V8_O-atUaRBQUm4,70
|
10
|
+
mcp_kb/ingest/__init__.py,sha256=8obrvfa8nLNLYPbi1MHlFUqfoFHgK9YfdryPzAXQ6kU,77
|
11
|
+
mcp_kb/ingest/chroma.py,sha256=gsR1Y4PsE4v18NJQYCkV6xt5P3iRgLb6wb_JY90OGu4,47422
|
12
|
+
mcp_kb/knowledge/__init__.py,sha256=W_dtRbtnQlrDJ_425vWR8BcoZGJ8gC5-wg1De1E654s,76
|
13
|
+
mcp_kb/knowledge/bootstrap.py,sha256=Og72GvxeJX7PLe_vHVMzRqnXIS06JswSrIdKcz776_8,1237
|
14
|
+
mcp_kb/knowledge/events.py,sha256=4pYC7gP6k-_O6hIdc0w69SkcoMq639f9TIJg6PikMgs,3624
|
15
|
+
mcp_kb/knowledge/search.py,sha256=G38AEKL38sA2SaVvuGSmy0TdR17Sx8n12GA8E4i9JvE,6003
|
16
|
+
mcp_kb/knowledge/store.py,sha256=SNkD-6I3J8xvHQdt-Z9xdoZdlQ8rSxj1nuqckNtNmak,10932
|
17
|
+
mcp_kb/security/__init__.py,sha256=lF8_XAjzpwhAFresuskXMo0u9v7KFiTJId88wqOAM4Y,62
|
18
|
+
mcp_kb/security/path_validation.py,sha256=yqSPb6_WFJF3ZwwyOtzvJIhM9pNYmCVpseQdXPkb1gM,3658
|
19
|
+
mcp_kb/server/__init__.py,sha256=j9TmxW_WLCoibyQvCsDT1MIuUqSL8sRh2h4u0M4eU0c,74
|
20
|
+
mcp_kb/server/app.py,sha256=Ol3usBD9Rr4fjRYBGChWQOR5GkYinR0zfh_DDVuF8Fk,7336
|
21
|
+
mcp_kb/ui/__init__.py,sha256=vQMh9koOAjJO35WRd0LlUvvadZZ5gZ74C4Rs_XVmH9k,639
|
22
|
+
mcp_kb/ui/api.py,sha256=kKEIqcHi-OAuY8NfYKAMuNSFcHSM-yqV7SKUIuCnqmk,13078
|
23
|
+
mcp_kb/ui/server.py,sha256=miJXMYpfbcxpIvawkFsLvJtKHLCur0Ze10hJaD8X2ZA,13321
|
24
|
+
mcp_kb/ui/assets/index.html,sha256=4oPfhGAYhxrtwNj31JVfLgtrTyHEdoIirOTDPhMBh7g,2452
|
25
|
+
mcp_kb/ui/assets/assets/index.css,sha256=0ijQKJMsklOMXKKMdFhx7cQUV-ksgJX1pT7XSX0XSyg,3923
|
26
|
+
mcp_kb/utils/__init__.py,sha256=lKhRsjgnbhye1sSlch1_wsAI3eWKE1M6RVIiNlnsvLI,71
|
27
|
+
mcp_kb/utils/filesystem.py,sha256=1Jr9cxIimV-o91DJMh5lR9GLFE3BDknoGquVBFQ-fd4,4027
|
28
|
+
mcp_kb-0.3.3.dist-info/METADATA,sha256=kMzKsM-pcL_EE0ah6FkLyIyNBkR5LOH83otv2DW7JzM,9944
|
29
|
+
mcp_kb-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
30
|
+
mcp_kb-0.3.3.dist-info/entry_points.txt,sha256=PdX1utY9cbvU_NQcKqUrWnMa4r3jGl448T7HUF9Gjqw,126
|
31
|
+
mcp_kb-0.3.3.dist-info/top_level.txt,sha256=IBiz3TNE3FF3TwkbCZpC1kkk6ohTwtBQNSPJNV3-qGA,7
|
32
|
+
mcp_kb-0.3.3.dist-info/RECORD,,
|
mcp_kb-0.3.1.dist-info/METADATA
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: mcp-kb
|
3
|
-
Version: 0.3.1
|
4
|
-
Summary: MCP server exposing a local markdown knowledge base
|
5
|
-
Author: LLM Maintainer
|
6
|
-
Requires-Python: >=3.11
|
7
|
-
Description-Content-Type: text/markdown
|
8
|
-
Requires-Dist: httpx>=0.28.1
|
9
|
-
Requires-Dist: mcp[cli]>=1.15.0
|
10
|
-
Requires-Dist: pydantic>=2.11.9
|
11
|
-
Provides-Extra: vector
|
12
|
-
Requires-Dist: chromadb>=1.1.0; extra == "vector"
|
13
|
-
Requires-Dist: tiktoken>=0.11.0; extra == "vector"
|
14
|
-
Requires-Dist: langchain-text-splitters>=0.3.11; extra == "vector"
|
15
|
-
Requires-Dist: umap-learn>=0.5.9.post2; extra == "vector"
|
16
|
-
Provides-Extra: sentence-transformer
|
17
|
-
Requires-Dist: mcp-kb[vector]; extra == "sentence-transformer"
|
18
|
-
Requires-Dist: sentence-transformers>=5.1.1; extra == "sentence-transformer"
|
19
|
-
|
20
|
-
# MCP Knowledge Base Server
|
21
|
-
|
22
|
-
This project implements a Model Context Protocol (MCP) server that manages a local markdown knowledge base. It provides tools for creating, reading, updating, searching, and organizing documents stored beneath a configurable root directory. The server uses `FastMCP` for transport and schema generation, so the Python tool functions double as the canonical source of truth for MCP metadata.
|
23
|
-
|
24
|
-
## Running the server
|
25
|
-
|
26
|
-
```bash
|
27
|
-
uv run mcp-kb-server --root /path/to/knowledgebase
|
28
|
-
```
|
29
|
-
|
30
|
-
To expose multiple transports, pass `--transport` flags (supported values: `stdio`,
|
31
|
-
`sse`, `http`):
|
32
|
-
|
33
|
-
```bash
|
34
|
-
uv run mcp-kb-server --transport stdio --transport http
|
35
|
-
```
|
36
|
-
|
37
|
-
Use `--host` and `--port` to bind HTTP/SSE transports to specific interfaces:
|
38
|
-
|
39
|
-
```bash
|
40
|
-
uv run mcp-kb-server --transport http --host 0.0.0.0 --port 9000
|
41
|
-
```
|
42
|
-
|
43
|
-
On first launch the server copies a bundled `KNOWLEDBASE_DOC.md` into the
|
44
|
-
`.data/` directory if it is missing so that every deployment starts with a
|
45
|
-
baseline usage guide.
|
46
|
-
|
47
|
-
## Optional ChromaDB Mirroring
|
48
|
-
|
49
|
-
The CLI can mirror knowledge base changes into a Chroma collection without
|
50
|
-
exposing raw Chroma operations as MCP tools. Mirroring is enabled by default via
|
51
|
-
the `persistent` client, which stores data under `<root>/chroma`. Choose a
|
52
|
-
different backend with `--chroma-client` (choices: `ephemeral`, `persistent`,
|
53
|
-
`http`, `cloud`). Example:
|
54
|
-
|
55
|
-
```bash
|
56
|
-
uv run mcp-kb-server \
|
57
|
-
--root /path/to/knowledgebase \
|
58
|
-
--chroma-client ephemeral \
|
59
|
-
--chroma-collection local-kb \
|
60
|
-
--chroma-embedding default
|
61
|
-
```
|
62
|
-
|
63
|
-
Persistent and remote clients accept additional flags:
|
64
|
-
|
65
|
-
- `--chroma-data-dir`: storage directory for the persistent client (defaults to
|
66
|
-
`<root>/chroma` when not supplied).
|
67
|
-
- `--chroma-host`, `--chroma-port`, `--chroma-ssl`, `--chroma-custom-auth`:
|
68
|
-
options for a self-hosted HTTP server.
|
69
|
-
- `--chroma-tenant`, `--chroma-database`, `--chroma-api-key`: credentials for
|
70
|
-
Chroma Cloud deployments.
|
71
|
-
- `--chroma-id-prefix`: custom document ID prefix (`kb::` by default).
|
72
|
-
|
73
|
-
Every flag has a matching environment variable (`MCP_KB_CHROMA_*`), so the
|
74
|
-
following snippet enables an HTTP client without modifying CLI commands:
|
75
|
-
|
76
|
-
```bash
|
77
|
-
export MCP_KB_CHROMA_CLIENT=http
|
78
|
-
export MCP_KB_CHROMA_HOST=chroma.internal
|
79
|
-
export MCP_KB_CHROMA_PORT=8001
|
80
|
-
export MCP_KB_CHROMA_CUSTOM_AUTH="username:password"
|
81
|
-
uv run mcp-kb-server --transport http
|
82
|
-
```
|
83
|
-
|
84
|
-
When enabled, any file creation, update, or soft deletion is synchronously
|
85
|
-
propagated to the configured Chroma collection, ensuring semantic search stays
|
86
|
-
in lockstep with the markdown knowledge base.
|
87
|
-
|
88
|
-
The `kb.search` MCP tool automatically queries Chroma when mirroring is active,
|
89
|
-
falling back to direct filesystem scans if the semantic index returns no hits.
|
90
|
-
|
91
|
-
## Reindexing
|
92
|
-
|
93
|
-
Use the standalone CLI to rebuild external indexes (e.g., Chroma) from the
|
94
|
-
current knowledge base. This command is not exposed as an MCP tool.
|
95
|
-
|
96
|
-
```bash
|
97
|
-
uv run mcp-kb-reindex --root /path/to/knowledgebase \
|
98
|
-
--chroma-client persistent \
|
99
|
-
--chroma-data-dir /path/to/chroma \
|
100
|
-
--chroma-collection knowledge-base \
|
101
|
-
--chroma-embedding default
|
102
|
-
```
|
103
|
-
|
104
|
-
- Honors the same `--chroma-*` flags and `MCP_KB_CHROMA_*` environment
|
105
|
-
variables as the server.
|
106
|
-
- Processes all non-deleted `*.md` files under the root and prints a summary:
|
107
|
-
`Reindexed N documents`.
|
108
|
-
|
109
|
-
## Testing
|
110
|
-
|
111
|
-
```bash
|
112
|
-
uv run pytest
|
113
|
-
```
|
114
|
-
|
115
|
-
## LLM Client Configuration
|
116
|
-
|
117
|
-
Below are sample configurations for popular MCP-capable LLM clients. All
|
118
|
-
examples assume this repository is cloned locally and that `uv` is installed.
|
119
|
-
|
120
|
-
### Claude Desktop
|
121
|
-
|
122
|
-
Add the following block to your Claude Desktop `claude_desktop_config.json`:
|
123
|
-
|
124
|
-
```json
|
125
|
-
{
|
126
|
-
"mcpServers": {
|
127
|
-
"local-kb": {
|
128
|
-
"server-name": "kb-server",
|
129
|
-
"command": "uv",
|
130
|
-
"args": [
|
131
|
-
"run",
|
132
|
-
"mcp-kb-server",
|
133
|
-
"--root",
|
134
|
-
"/absolute/path/to/.knowledgebase"
|
135
|
-
]
|
136
|
-
}
|
137
|
-
}
|
138
|
-
}
|
139
|
-
```
|
140
|
-
|
141
|
-
### Cursor AI
|
142
|
-
|
143
|
-
In Cursor's `cursor-settings.json`, register the server as a custom tool:
|
144
|
-
|
145
|
-
```json
|
146
|
-
{
|
147
|
-
"mcpServers": {
|
148
|
-
"local_knowledge_base": {
|
149
|
-
"id": "local-kb",
|
150
|
-
"title": "Local Knowledge Base",
|
151
|
-
"command": "uvx",
|
152
|
-
"args": [
|
153
|
-
" --from",
|
154
|
-
"~/cursor_projects/local_knowledge_base",
|
155
|
-
"mcp-kb-server"
|
156
|
-
]
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
```
|
161
|
-
|
162
|
-
### VS Code (Claude MCP Extension)
|
163
|
-
|
164
|
-
For the `Claude MCP` extension, add an entry to `settings.json`:
|
165
|
-
|
166
|
-
```json
|
167
|
-
{
|
168
|
-
"claudeMcp.servers": {
|
169
|
-
"local-kb": {
|
170
|
-
"command": "uv",
|
171
|
-
"args": ["run", "mcp-kb-server"],
|
172
|
-
"env": {
|
173
|
-
"MCP_KB_ROOT": "/absolute/path/to/.knowledgebase"
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
}
|
178
|
-
```
|
179
|
-
|
180
|
-
Adjust the `--root` flag or `MCP_KB_ROOT` environment variable to point at the
|
181
|
-
desired knowledge base directory for each client.
|
mcp_kb-0.3.1.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
mcp_kb/__init__.py,sha256=Ry7qODhfFQF6u6p2m3bwGWhB0-BdWTQcHDJB7NBYAio,74
|
2
|
-
mcp_kb/config.py,sha256=NUpzjDH4PQw4FyjGgYUcMsGMeenNiZTMrQj4U62xKlk,2530
|
3
|
-
mcp_kb-0.3.1.dist-info/METADATA,sha256=PChkcVS-WUUnKFSHxIkpDn7PtJlOmQFvHIjkus7xBRU,5389
|
4
|
-
mcp_kb-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
5
|
-
mcp_kb-0.3.1.dist-info/entry_points.txt,sha256=PdX1utY9cbvU_NQcKqUrWnMa4r3jGl448T7HUF9Gjqw,126
|
6
|
-
mcp_kb-0.3.1.dist-info/top_level.txt,sha256=IBiz3TNE3FF3TwkbCZpC1kkk6ohTwtBQNSPJNV3-qGA,7
|
7
|
-
mcp_kb-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|