mcp-kb 0.2.0__tar.gz → 0.3.0__tar.gz
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-0.2.0 → mcp_kb-0.3.0}/PKG-INFO +3 -1
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb/config.py +7 -5
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb.egg-info/PKG-INFO +3 -1
- mcp_kb-0.3.0/mcp_kb.egg-info/SOURCES.txt +10 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb.egg-info/requires.txt +2 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/pyproject.toml +9 -2
- mcp_kb-0.2.0/mcp_kb/cli/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/cli/args.py +0 -153
- mcp_kb-0.2.0/mcp_kb/cli/main.py +0 -116
- mcp_kb-0.2.0/mcp_kb/cli/reindex.py +0 -91
- mcp_kb-0.2.0/mcp_kb/data/KNOWLEDBASE_DOC.md +0 -36
- mcp_kb-0.2.0/mcp_kb/data/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/ingest/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/ingest/chroma.py +0 -588
- mcp_kb-0.2.0/mcp_kb/knowledge/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/knowledge/bootstrap.py +0 -39
- mcp_kb-0.2.0/mcp_kb/knowledge/events.py +0 -100
- mcp_kb-0.2.0/mcp_kb/knowledge/search.py +0 -178
- mcp_kb-0.2.0/mcp_kb/knowledge/store.py +0 -263
- mcp_kb-0.2.0/mcp_kb/security/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/security/path_validation.py +0 -105
- mcp_kb-0.2.0/mcp_kb/server/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/server/app.py +0 -201
- mcp_kb-0.2.0/mcp_kb/utils/__init__.py +0 -1
- mcp_kb-0.2.0/mcp_kb/utils/filesystem.py +0 -127
- mcp_kb-0.2.0/mcp_kb.egg-info/SOURCES.txt +0 -29
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/README.md +0 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb/__init__.py +0 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb.egg-info/dependency_links.txt +0 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb.egg-info/entry_points.txt +0 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/mcp_kb.egg-info/top_level.txt +0 -0
- {mcp_kb-0.2.0 → mcp_kb-0.3.0}/setup.cfg +0 -0
@@ -1,16 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-kb
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: MCP server exposing a local markdown knowledge base
|
5
5
|
Author: LLM Maintainer
|
6
6
|
Requires-Python: >=3.11
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
Requires-Dist: httpx>=0.28.1
|
9
9
|
Requires-Dist: mcp[cli]>=1.15.0
|
10
|
+
Requires-Dist: pydantic>=2.11.9
|
10
11
|
Provides-Extra: vector
|
11
12
|
Requires-Dist: chromadb>=1.1.0; extra == "vector"
|
12
13
|
Requires-Dist: tiktoken>=0.11.0; extra == "vector"
|
13
14
|
Requires-Dist: langchain-text-splitters>=0.3.11; extra == "vector"
|
15
|
+
Requires-Dist: umap-learn>=0.5.9.post2; extra == "vector"
|
14
16
|
|
15
17
|
# MCP Knowledge Base Server
|
16
18
|
|
@@ -7,6 +7,7 @@ logic more reusable across different deployment environments because callers can
|
|
7
7
|
swap configurations programmatically or via environment variables without
|
8
8
|
modifying the core modules.
|
9
9
|
"""
|
10
|
+
|
10
11
|
from __future__ import annotations
|
11
12
|
|
12
13
|
from pathlib import Path
|
@@ -58,12 +59,13 @@ def resolve_knowledge_base_root(provided_path: str | None = None) -> Path:
|
|
58
59
|
root directory.
|
59
60
|
"""
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
os.getenv(
|
64
|
-
|
62
|
+
candidate = (
|
63
|
+
provided_path
|
64
|
+
or os.getenv(ENV_ROOT_KEY)
|
65
|
+
or Path(os.getenv("WORKSPACE_FOLDER_PATHS") or Path.cwd())
|
66
|
+
/ DEFAULT_KNOWLEDGE_BASE_DIR
|
67
|
+
)
|
65
68
|
root_path = Path(candidate).expanduser().resolve()
|
66
69
|
root_path.mkdir(parents=True, exist_ok=True)
|
67
70
|
|
68
|
-
|
69
71
|
return root_path
|
@@ -1,16 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-kb
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: MCP server exposing a local markdown knowledge base
|
5
5
|
Author: LLM Maintainer
|
6
6
|
Requires-Python: >=3.11
|
7
7
|
Description-Content-Type: text/markdown
|
8
8
|
Requires-Dist: httpx>=0.28.1
|
9
9
|
Requires-Dist: mcp[cli]>=1.15.0
|
10
|
+
Requires-Dist: pydantic>=2.11.9
|
10
11
|
Provides-Extra: vector
|
11
12
|
Requires-Dist: chromadb>=1.1.0; extra == "vector"
|
12
13
|
Requires-Dist: tiktoken>=0.11.0; extra == "vector"
|
13
14
|
Requires-Dist: langchain-text-splitters>=0.3.11; extra == "vector"
|
15
|
+
Requires-Dist: umap-learn>=0.5.9.post2; extra == "vector"
|
14
16
|
|
15
17
|
# MCP Knowledge Base Server
|
16
18
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
README.md
|
2
|
+
pyproject.toml
|
3
|
+
mcp_kb/__init__.py
|
4
|
+
mcp_kb/config.py
|
5
|
+
mcp_kb.egg-info/PKG-INFO
|
6
|
+
mcp_kb.egg-info/SOURCES.txt
|
7
|
+
mcp_kb.egg-info/dependency_links.txt
|
8
|
+
mcp_kb.egg-info/entry_points.txt
|
9
|
+
mcp_kb.egg-info/requires.txt
|
10
|
+
mcp_kb.egg-info/top_level.txt
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "mcp-kb"
|
3
|
-
version = "0.
|
3
|
+
version = "0.3.0"
|
4
4
|
description = "MCP server exposing a local markdown knowledge base"
|
5
5
|
readme = "README.md"
|
6
6
|
authors = [{ name = "LLM Maintainer" }]
|
@@ -8,6 +8,7 @@ requires-python = ">=3.11"
|
|
8
8
|
dependencies = [
|
9
9
|
"httpx>=0.28.1",
|
10
10
|
"mcp[cli]>=1.15.0",
|
11
|
+
"pydantic>=2.11.9",
|
11
12
|
]
|
12
13
|
|
13
14
|
[project.scripts]
|
@@ -19,7 +20,7 @@ vector = [
|
|
19
20
|
"chromadb>=1.1.0",
|
20
21
|
"tiktoken>=0.11.0",
|
21
22
|
"langchain-text-splitters>=0.3.11",
|
22
|
-
|
23
|
+
"umap-learn>=0.5.9.post2",
|
23
24
|
]
|
24
25
|
|
25
26
|
[build-system]
|
@@ -28,9 +29,15 @@ build-backend = "setuptools.build_meta"
|
|
28
29
|
|
29
30
|
[tool.setuptools.package-data]
|
30
31
|
"mcp_kb.data" = ["KNOWLEDBASE_DOC.md"]
|
32
|
+
"mcp_kb.ui.assets" = ["index.html", "assets/**"]
|
33
|
+
|
34
|
+
[tool.setuptools]
|
35
|
+
packages = ["mcp_kb"]
|
36
|
+
include-package-data = true
|
31
37
|
|
32
38
|
[tool.uv]
|
33
39
|
package = true
|
34
40
|
dev-dependencies = [
|
35
41
|
"pytest>=8.4.2",
|
42
|
+
"markitdown[all]>=0.1.3",
|
36
43
|
]
|
@@ -1 +0,0 @@
|
|
1
|
-
"""CLI subpackage exposing entry points for running the server."""
|
mcp_kb-0.2.0/mcp_kb/cli/args.py
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
"""Shared CLI argument wiring for knowledge base utilities.
|
2
|
-
|
3
|
-
This module centralizes the definition of common command-line options and
|
4
|
-
helpers so that multiple entry points (e.g., server and reindex commands) can
|
5
|
-
remain small and focused while sharing consistent behavior.
|
6
|
-
"""
|
7
|
-
from __future__ import annotations
|
8
|
-
|
9
|
-
import os
|
10
|
-
from argparse import ArgumentParser, Namespace
|
11
|
-
from pathlib import Path
|
12
|
-
from typing import Optional
|
13
|
-
|
14
|
-
from mcp_kb.ingest.chroma import SUPPORTED_CLIENTS, ChromaConfiguration, ChromaIngestor
|
15
|
-
|
16
|
-
|
17
|
-
def parse_bool(value: str | bool | None) -> bool:
|
18
|
-
"""Return ``True`` when ``value`` represents an affirmative boolean string.
|
19
|
-
|
20
|
-
The function accepts case-insensitive variants such as "true", "t",
|
21
|
-
"yes", and "1". ``None`` yields ``False``.
|
22
|
-
"""
|
23
|
-
|
24
|
-
if isinstance(value, bool):
|
25
|
-
return value
|
26
|
-
if value is None:
|
27
|
-
return False
|
28
|
-
return value.lower() in {"1", "true", "t", "yes", "y"}
|
29
|
-
|
30
|
-
|
31
|
-
def add_chroma_arguments(parser: ArgumentParser) -> None:
|
32
|
-
"""Register Chroma ingestion arguments on ``parser``.
|
33
|
-
|
34
|
-
Environment variables are used as defaults where available so that
|
35
|
-
deployments can configure ingestion without repeating flags.
|
36
|
-
"""
|
37
|
-
|
38
|
-
default_chroma_client = os.getenv("MCP_KB_CHROMA_CLIENT", "persistent").lower()
|
39
|
-
default_collection = os.getenv("MCP_KB_CHROMA_COLLECTION", "knowledge-base")
|
40
|
-
default_embedding = os.getenv("MCP_KB_CHROMA_EMBEDDING", "default")
|
41
|
-
default_data_dir = os.getenv("MCP_KB_CHROMA_DATA_DIR")
|
42
|
-
default_host = os.getenv("MCP_KB_CHROMA_HOST")
|
43
|
-
default_port_env = os.getenv("MCP_KB_CHROMA_PORT")
|
44
|
-
default_port = int(default_port_env) if default_port_env else None
|
45
|
-
default_ssl = parse_bool(os.getenv("MCP_KB_CHROMA_SSL", "true"))
|
46
|
-
default_tenant = os.getenv("MCP_KB_CHROMA_TENANT")
|
47
|
-
default_database = os.getenv("MCP_KB_CHROMA_DATABASE")
|
48
|
-
default_api_key = os.getenv("MCP_KB_CHROMA_API_KEY")
|
49
|
-
default_custom_auth = os.getenv("MCP_KB_CHROMA_CUSTOM_AUTH")
|
50
|
-
default_id_prefix = os.getenv("MCP_KB_CHROMA_ID_PREFIX")
|
51
|
-
|
52
|
-
parser.add_argument(
|
53
|
-
"--chroma-client",
|
54
|
-
dest="chroma_client",
|
55
|
-
choices=SUPPORTED_CLIENTS,
|
56
|
-
default=default_chroma_client,
|
57
|
-
help="Client implementation for mirroring data to ChromaDB (default: persistent).",
|
58
|
-
)
|
59
|
-
parser.add_argument(
|
60
|
-
"--chroma-collection",
|
61
|
-
dest="chroma_collection",
|
62
|
-
default=default_collection,
|
63
|
-
help="Chroma collection name used to store documents.",
|
64
|
-
)
|
65
|
-
parser.add_argument(
|
66
|
-
"--chroma-embedding",
|
67
|
-
dest="chroma_embedding",
|
68
|
-
default=default_embedding,
|
69
|
-
help="Embedding function name registered with chromadb.utils.embedding_functions.",
|
70
|
-
)
|
71
|
-
parser.add_argument(
|
72
|
-
"--chroma-data-dir",
|
73
|
-
dest="chroma_data_dir",
|
74
|
-
default=default_data_dir,
|
75
|
-
help="Storage directory for the persistent Chroma client.",
|
76
|
-
)
|
77
|
-
parser.add_argument(
|
78
|
-
"--chroma-host",
|
79
|
-
dest="chroma_host",
|
80
|
-
default=default_host,
|
81
|
-
help="Target host for HTTP or cloud Chroma clients.",
|
82
|
-
)
|
83
|
-
parser.add_argument(
|
84
|
-
"--chroma-port",
|
85
|
-
dest="chroma_port",
|
86
|
-
type=int,
|
87
|
-
default=default_port,
|
88
|
-
help="Port for the HTTP Chroma client.",
|
89
|
-
)
|
90
|
-
parser.add_argument(
|
91
|
-
"--chroma-ssl",
|
92
|
-
dest="chroma_ssl",
|
93
|
-
type=parse_bool,
|
94
|
-
default=default_ssl,
|
95
|
-
help="Toggle SSL for the HTTP Chroma client (default: true).",
|
96
|
-
)
|
97
|
-
parser.add_argument(
|
98
|
-
"--chroma-tenant",
|
99
|
-
dest="chroma_tenant",
|
100
|
-
default=default_tenant,
|
101
|
-
help="Tenant identifier for Chroma Cloud deployments.",
|
102
|
-
)
|
103
|
-
parser.add_argument(
|
104
|
-
"--chroma-database",
|
105
|
-
dest="chroma_database",
|
106
|
-
default=default_database,
|
107
|
-
help="Database name for Chroma Cloud deployments.",
|
108
|
-
)
|
109
|
-
parser.add_argument(
|
110
|
-
"--chroma-api-key",
|
111
|
-
dest="chroma_api_key",
|
112
|
-
default=default_api_key,
|
113
|
-
help="API key used to authenticate against Chroma Cloud.",
|
114
|
-
)
|
115
|
-
parser.add_argument(
|
116
|
-
"--chroma-custom-auth",
|
117
|
-
dest="chroma_custom_auth",
|
118
|
-
default=default_custom_auth,
|
119
|
-
help="Optional custom auth credentials for self-hosted HTTP deployments.",
|
120
|
-
)
|
121
|
-
parser.add_argument(
|
122
|
-
"--chroma-id-prefix",
|
123
|
-
dest="chroma_id_prefix",
|
124
|
-
default=default_id_prefix,
|
125
|
-
help="Prefix applied to document IDs stored in Chroma (default: kb::).",
|
126
|
-
)
|
127
|
-
|
128
|
-
|
129
|
-
def build_chroma_listener(options: Namespace, root: Path) -> Optional[ChromaIngestor]:
|
130
|
-
"""Construct a Chroma listener from parsed CLI options when enabled.
|
131
|
-
|
132
|
-
Returns ``None`` when the configured client type is ``off``.
|
133
|
-
"""
|
134
|
-
|
135
|
-
configuration = ChromaConfiguration.from_options(
|
136
|
-
root=root,
|
137
|
-
client_type=options.chroma_client,
|
138
|
-
collection_name=options.chroma_collection,
|
139
|
-
embedding=options.chroma_embedding,
|
140
|
-
data_directory=options.chroma_data_dir,
|
141
|
-
host=options.chroma_host,
|
142
|
-
port=options.chroma_port,
|
143
|
-
ssl=options.chroma_ssl,
|
144
|
-
tenant=options.chroma_tenant,
|
145
|
-
database=options.chroma_database,
|
146
|
-
api_key=options.chroma_api_key,
|
147
|
-
custom_auth_credentials=options.chroma_custom_auth,
|
148
|
-
id_prefix=options.chroma_id_prefix,
|
149
|
-
)
|
150
|
-
if not configuration.enabled:
|
151
|
-
return None
|
152
|
-
return ChromaIngestor(configuration)
|
153
|
-
|
mcp_kb-0.2.0/mcp_kb/cli/main.py
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
"""Command line interface for running the MCP knowledge base server."""
|
2
|
-
from __future__ import annotations
|
3
|
-
|
4
|
-
import argparse
|
5
|
-
import asyncio
|
6
|
-
import logging
|
7
|
-
import os
|
8
|
-
from pathlib import Path
|
9
|
-
from typing import Iterable, List, Optional
|
10
|
-
|
11
|
-
from mcp_kb.config import DATA_FOLDER_NAME, resolve_knowledge_base_root
|
12
|
-
from mcp_kb.cli.args import add_chroma_arguments, build_chroma_listener, parse_bool
|
13
|
-
from mcp_kb.ingest.chroma import ChromaIngestor
|
14
|
-
from mcp_kb.knowledge.bootstrap import install_default_documentation
|
15
|
-
from mcp_kb.security.path_validation import PathRules
|
16
|
-
from mcp_kb.server.app import create_fastmcp_app
|
17
|
-
from mcp.server.fastmcp import FastMCP
|
18
|
-
|
19
|
-
logging.basicConfig(level=logging.INFO)
|
20
|
-
|
21
|
-
logger = logging.getLogger(__name__)
|
22
|
-
|
23
|
-
|
24
|
-
def _build_argument_parser() -> argparse.ArgumentParser:
|
25
|
-
"""Create and return the argument parser used by ``main``."""
|
26
|
-
|
27
|
-
parser = argparse.ArgumentParser(description="Run the MCP knowledge base server")
|
28
|
-
parser.add_argument(
|
29
|
-
"--root",
|
30
|
-
dest="root",
|
31
|
-
default=None,
|
32
|
-
help="Optional path to the knowledge base root (defaults to environment configuration)",
|
33
|
-
)
|
34
|
-
parser.add_argument(
|
35
|
-
"--transport",
|
36
|
-
dest="transports",
|
37
|
-
action="append",
|
38
|
-
choices=["stdio", "sse", "http"],
|
39
|
-
help="Transport protocol to enable (repeatable). Defaults to stdio only.",
|
40
|
-
)
|
41
|
-
parser.add_argument(
|
42
|
-
"--host",
|
43
|
-
dest="host",
|
44
|
-
default=None,
|
45
|
-
help="Host interface for HTTP/SSE transports (default 127.0.0.1).",
|
46
|
-
)
|
47
|
-
parser.add_argument(
|
48
|
-
"--port",
|
49
|
-
dest="port",
|
50
|
-
type=int,
|
51
|
-
default=None,
|
52
|
-
help="Port for HTTP/SSE transports (default 8000).",
|
53
|
-
)
|
54
|
-
|
55
|
-
add_chroma_arguments(parser)
|
56
|
-
return parser
|
57
|
-
|
58
|
-
|
59
|
-
async def _run_transports(server: FastMCP, transports: List[str]) -> None:
|
60
|
-
"""Run all selected transport protocols concurrently."""
|
61
|
-
|
62
|
-
coroutines = []
|
63
|
-
for name in transports:
|
64
|
-
if name == "stdio":
|
65
|
-
coroutines.append(server.run_stdio_async())
|
66
|
-
elif name == "sse":
|
67
|
-
coroutines.append(server.run_sse_async())
|
68
|
-
elif name == "http":
|
69
|
-
coroutines.append(server.run_streamable_http_async())
|
70
|
-
else: # pragma: no cover - argparse restricts values
|
71
|
-
raise ValueError(f"Unsupported transport: {name}")
|
72
|
-
|
73
|
-
await asyncio.gather(*coroutines)
|
74
|
-
|
75
|
-
|
76
|
-
def run_server(arguments: Iterable[str] | None = None) -> None:
|
77
|
-
"""Entry point used by both CLI invocations and unit tests."""
|
78
|
-
|
79
|
-
parser = _build_argument_parser()
|
80
|
-
options = parser.parse_args(arguments)
|
81
|
-
root_path = resolve_knowledge_base_root(options.root)
|
82
|
-
rules = PathRules(root=root_path, protected_folders=(DATA_FOLDER_NAME,))
|
83
|
-
install_default_documentation(root_path)
|
84
|
-
listeners: List[ChromaIngestor] = []
|
85
|
-
try:
|
86
|
-
listener = build_chroma_listener(options, root_path)
|
87
|
-
except Exception as exc: # pragma: no cover - configuration errors
|
88
|
-
raise SystemExit(f"Failed to configure Chroma ingestion: {exc}") from exc
|
89
|
-
if listener is not None:
|
90
|
-
listeners.append(listener)
|
91
|
-
logger.info(
|
92
|
-
"Chroma ingestion enabled (client=%s, collection=%s)",
|
93
|
-
options.chroma_client,
|
94
|
-
options.chroma_collection,
|
95
|
-
)
|
96
|
-
server = create_fastmcp_app(
|
97
|
-
rules,
|
98
|
-
host=options.host,
|
99
|
-
port=options.port,
|
100
|
-
listeners=listeners,
|
101
|
-
)
|
102
|
-
transports = options.transports or ["stdio"]
|
103
|
-
logger.info(f"Running server on {options.host}:{options.port} with transports {transports}")
|
104
|
-
logger.info(f"Data root is {root_path}")
|
105
|
-
print("--------------------------------",root_path,"--------------------------------")
|
106
|
-
asyncio.run(_run_transports(server, transports))
|
107
|
-
|
108
|
-
|
109
|
-
def main() -> None:
|
110
|
-
"""CLI hook that executes :func:`run_server`."""
|
111
|
-
|
112
|
-
run_server()
|
113
|
-
|
114
|
-
|
115
|
-
if __name__ == "__main__":
|
116
|
-
main()
|
@@ -1,91 +0,0 @@
|
|
1
|
-
"""CLI command to reindex the knowledge base into configured ingestors.
|
2
|
-
|
3
|
-
This command does not expose an MCP tool. Instead, it builds the configured
|
4
|
-
ingestors and calls their ``reindex`` method when available, allowing operators
|
5
|
-
to trigger a full rebuild of external indexes (e.g., Chroma) from the current
|
6
|
-
filesystem state.
|
7
|
-
"""
|
8
|
-
from __future__ import annotations
|
9
|
-
|
10
|
-
import argparse
|
11
|
-
import logging
|
12
|
-
from typing import Iterable, List
|
13
|
-
|
14
|
-
from mcp_kb.cli.args import add_chroma_arguments, build_chroma_listener
|
15
|
-
from mcp_kb.config import DATA_FOLDER_NAME, resolve_knowledge_base_root
|
16
|
-
from mcp_kb.knowledge.events import KnowledgeBaseReindexListener
|
17
|
-
from mcp_kb.knowledge.store import KnowledgeBase
|
18
|
-
from mcp_kb.security.path_validation import PathRules
|
19
|
-
|
20
|
-
|
21
|
-
logger = logging.getLogger(__name__)
|
22
|
-
|
23
|
-
|
24
|
-
def _build_argument_parser() -> argparse.ArgumentParser:
|
25
|
-
"""Return the argument parser for the reindex command."""
|
26
|
-
|
27
|
-
parser = argparse.ArgumentParser(description="Reindex the knowledge base into configured backends")
|
28
|
-
parser.add_argument(
|
29
|
-
"--root",
|
30
|
-
dest="root",
|
31
|
-
default=None,
|
32
|
-
help="Optional path to the knowledge base root (defaults to environment configuration)",
|
33
|
-
)
|
34
|
-
add_chroma_arguments(parser)
|
35
|
-
return parser
|
36
|
-
|
37
|
-
|
38
|
-
def run_reindex(arguments: Iterable[str] | None = None) -> int:
|
39
|
-
"""Execute a reindex run across all registered ingestors.
|
40
|
-
|
41
|
-
The function constructs a :class:`~mcp_kb.knowledge.store.KnowledgeBase`
|
42
|
-
using the same root resolution logic as the server, builds any enabled
|
43
|
-
ingestion listeners from CLI options, and invokes ``reindex`` on those that
|
44
|
-
implement the optional protocol.
|
45
|
-
|
46
|
-
Parameters
|
47
|
-
----------
|
48
|
-
arguments:
|
49
|
-
Optional iterable of command-line arguments, primarily used by tests.
|
50
|
-
|
51
|
-
Returns
|
52
|
-
-------
|
53
|
-
int
|
54
|
-
The total number of documents processed across all reindex-capable
|
55
|
-
listeners.
|
56
|
-
"""
|
57
|
-
|
58
|
-
parser = _build_argument_parser()
|
59
|
-
options = parser.parse_args(arguments)
|
60
|
-
root_path = resolve_knowledge_base_root(options.root)
|
61
|
-
rules = PathRules(root=root_path, protected_folders=(DATA_FOLDER_NAME,))
|
62
|
-
kb = KnowledgeBase(rules)
|
63
|
-
|
64
|
-
listeners: List[KnowledgeBaseReindexListener] = []
|
65
|
-
try:
|
66
|
-
chroma = build_chroma_listener(options, root_path)
|
67
|
-
except Exception as exc: # pragma: no cover - configuration errors
|
68
|
-
raise SystemExit(f"Failed to configure Chroma ingestion: {exc}") from exc
|
69
|
-
if chroma is not None and isinstance(chroma, KnowledgeBaseReindexListener):
|
70
|
-
listeners.append(chroma)
|
71
|
-
|
72
|
-
total = 0
|
73
|
-
for listener in listeners:
|
74
|
-
logger.info("Reindexing via %s", listener.__class__.__name__)
|
75
|
-
count = listener.reindex(kb)
|
76
|
-
logger.info("Reindexed %d documents via %s", count, listener.__class__.__name__)
|
77
|
-
total += count
|
78
|
-
|
79
|
-
return total
|
80
|
-
|
81
|
-
|
82
|
-
def main() -> None:
|
83
|
-
"""CLI hook that executes :func:`run_reindex` and prints a summary."""
|
84
|
-
|
85
|
-
total = run_reindex()
|
86
|
-
print(f"Reindexed {total} documents")
|
87
|
-
|
88
|
-
|
89
|
-
if __name__ == "__main__":
|
90
|
-
main()
|
91
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# Knowledge Base Usage Guide
|
2
|
-
|
3
|
-
Welcome to the MCP-managed knowledge base. This document is automatically
|
4
|
-
installed the first time the server starts to ensure every deployment ships with
|
5
|
-
baseline documentation. Customize it to describe project-specific conventions or
|
6
|
-
operational practices.
|
7
|
-
|
8
|
-
## Structure
|
9
|
-
|
10
|
-
- All knowledge content lives beneath the `.knowledgebase/` root.
|
11
|
-
- Documentation and other non knowledge resides under `.data/` and is read-only from the MCP tools.
|
12
|
-
- Soft-deleted files are suffixed with `_DELETE_` and ignored by search/overview.
|
13
|
-
|
14
|
-
## Recommended Practices
|
15
|
-
|
16
|
-
1. Organize content into topic-based folders (e.g., `architecture/`, `ops/`).
|
17
|
-
2. Keep document titles within the first heading so search results show context.
|
18
|
-
3. Use relative markdown links to connect related documents inside the knowledge
|
19
|
-
base.
|
20
|
-
4. Periodically review `_DELETE_` files and clean up as necessary via direct
|
21
|
-
filesystem operations.
|
22
|
-
|
23
|
-
## Default Tools
|
24
|
-
|
25
|
-
| Tool | Purpose |
|
26
|
-
| --------------- | ----------------------------------------- |
|
27
|
-
| `create_file` | Create or overwrite markdown documents |
|
28
|
-
| `read_file` | Read entire files or specific line ranges |
|
29
|
-
| `append_file` | Append additional content to a file |
|
30
|
-
| `regex_replace` | Run regex-based replacements |
|
31
|
-
| `search` | Search text across active documents |
|
32
|
-
| `overview` | Display a tree overview of the knowledge |
|
33
|
-
| `documentation` | Read this documentation file |
|
34
|
-
| `delete` | Soft-delete files safely |
|
35
|
-
|
36
|
-
Update this document to reflect your team's workflows after deployment.
|
@@ -1 +0,0 @@
|
|
1
|
-
"""Embedded data files shipped with the MCP knowledge base server."""
|
@@ -1 +0,0 @@
|
|
1
|
-
"""Pluggable ingestion adapters for synchronizing knowledge base content."""
|