polarisagi-knowledge-base 0.1.0 → 1.0.19
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 +36 -0
- package/dist/index.js +4 -4
- package/package.json +18 -2
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# PolarisAGI Knowledge Base MCP
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/polarisagi-knowledge-base)
|
|
4
|
+
|
|
5
|
+
An official Model Context Protocol (MCP) server plugin for [PolarisAGI](https://polarisagi.online/), enabling agents to securely read local files and directories.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **List Files**: Explore directory structures.
|
|
10
|
+
- **Read Content**: Read the textual contents of local files for RAG or context injection.
|
|
11
|
+
- **Sandboxed**: Restricts file reading strictly to a permitted directory via environment variables.
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
|
|
15
|
+
This plugin is a zero-dependency, pure TypeScript implementation utilizing native Node.js `fs` APIs.
|
|
16
|
+
|
|
17
|
+
## Usage with PolarisAGI
|
|
18
|
+
|
|
19
|
+
Configure your AI agent with the following MCP server setting, replacing `/your/allowed/dir` with the absolute path you wish to expose to the agent:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"polarisagi-knowledge-base": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "polarisagi-knowledge-base@latest"],
|
|
27
|
+
"env": {
|
|
28
|
+
"POLARISAGI_KB_ALLOWED_DIR": "/your/allowed/dir"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
- Node.js v18 or newer.
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const readline = __importStar(require("readline"));
|
|
|
38
38
|
const fs = __importStar(require("fs/promises"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
// Allowed directory validation
|
|
41
|
-
const allowedDir = process.env.
|
|
41
|
+
const allowedDir = process.env.POLARISAGI_KB_ALLOWED_DIR;
|
|
42
42
|
function isPathAllowed(targetPath) {
|
|
43
43
|
if (!allowedDir) {
|
|
44
44
|
return true;
|
|
@@ -83,7 +83,7 @@ rl.on('line', async (line) => {
|
|
|
83
83
|
protocolVersion: "2024-11-05",
|
|
84
84
|
capabilities: { tools: {} },
|
|
85
85
|
serverInfo: {
|
|
86
|
-
name: "
|
|
86
|
+
name: "polarisagi-knowledge-base-mcp",
|
|
87
87
|
version: "0.1.0"
|
|
88
88
|
}
|
|
89
89
|
});
|
|
@@ -132,7 +132,7 @@ rl.on('line', async (line) => {
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
if (!isPathAllowed(targetPath)) {
|
|
135
|
-
sendResult(id, { isError: true, content: [{ type: "text", text: "path is outside the allowed directory (
|
|
135
|
+
sendResult(id, { isError: true, content: [{ type: "text", text: "path is outside the allowed directory (POLARISAGI_KB_ALLOWED_DIR)" }] });
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
try {
|
|
@@ -152,7 +152,7 @@ rl.on('line', async (line) => {
|
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
if (!isPathAllowed(targetPath)) {
|
|
155
|
-
sendResult(id, { isError: true, content: [{ type: "text", text: "path is outside the allowed directory (
|
|
155
|
+
sendResult(id, { isError: true, content: [{ type: "text", text: "path is outside the allowed directory (POLARISAGI_KB_ALLOWED_DIR)" }] });
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polarisagi-knowledge-base",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "MCP Plugin for reading local knowledge base files",
|
|
3
|
+
"version": "1.0.19",
|
|
4
|
+
"description": "MCP Plugin for reading local knowledge base files, with path sandboxing for RAG",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "mrlaoliai",
|
|
8
|
+
"email": "polarisagi.online@gmail.com",
|
|
9
|
+
"url": "https://polarisagi.online/"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://polarisagi.online/",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/polarisagi/polarisagi-plugins-official.git",
|
|
15
|
+
"directory": "plugins/knowledge_base"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["mcp", "knowledge-base", "rag", "file-system", "local-files"],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
5
21
|
"files": [
|
|
6
22
|
"dist"
|
|
7
23
|
],
|