@brain-protocol/mcp 0.1.1 → 0.2.1

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.
Files changed (50) hide show
  1. package/README.md +76 -122
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +56 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +23 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/schemas.d.ts +166 -0
  11. package/dist/schemas.d.ts.map +1 -1
  12. package/dist/schemas.js +46 -0
  13. package/dist/schemas.js.map +1 -1
  14. package/dist/server.d.ts +1 -1
  15. package/dist/server.d.ts.map +1 -1
  16. package/dist/server.js +2 -2
  17. package/dist/server.js.map +1 -1
  18. package/dist/store/adapter.d.ts +5 -0
  19. package/dist/store/adapter.d.ts.map +1 -1
  20. package/dist/store/cloud.d.ts +6 -4
  21. package/dist/store/cloud.d.ts.map +1 -1
  22. package/dist/store/cloud.js +66 -115
  23. package/dist/store/cloud.js.map +1 -1
  24. package/dist/store/sqlite.d.ts +12 -0
  25. package/dist/store/sqlite.d.ts.map +1 -1
  26. package/dist/store/sqlite.js +267 -12
  27. package/dist/store/sqlite.js.map +1 -1
  28. package/dist/tools/delete.d.ts +6 -0
  29. package/dist/tools/delete.d.ts.map +1 -0
  30. package/dist/tools/delete.js +7 -0
  31. package/dist/tools/delete.js.map +1 -0
  32. package/dist/tools/import.d.ts +5 -0
  33. package/dist/tools/import.d.ts.map +1 -0
  34. package/dist/tools/import.js +6 -0
  35. package/dist/tools/import.js.map +1 -0
  36. package/dist/tools/index.d.ts +176 -0
  37. package/dist/tools/index.d.ts.map +1 -1
  38. package/dist/tools/index.js +63 -1
  39. package/dist/tools/index.js.map +1 -1
  40. package/dist/tools/prove.d.ts +6 -0
  41. package/dist/tools/prove.d.ts.map +1 -1
  42. package/dist/tools/prove.js +18 -1
  43. package/dist/tools/prove.js.map +1 -1
  44. package/dist/tools/update.d.ts +5 -0
  45. package/dist/tools/update.d.ts.map +1 -0
  46. package/dist/tools/update.js +10 -0
  47. package/dist/tools/update.js.map +1 -0
  48. package/dist/types.d.ts +11 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +4 -3
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @brain-protocol/mcp
2
2
 
3
- Verifiable Memory-as-a-Service for AI Agents. An MCP server that gives any AI agent persistent knowledge with full-text search, a knowledge graph, and optional on-chain verification via Starknet.
3
+ Verifiable Memory for AI Agents MCP server with local SQLite or cloud mode.
4
4
 
5
- **Dual-mode**: SQLite local (zero config) or cloud (HTTP to your Brain Protocol API).
5
+ Give any AI agent persistent, searchable, graph-connected memory that works offline and optionally syncs to a cloud backend with on-chain verification.
6
6
 
7
7
  ## Quick Start
8
8
 
@@ -10,21 +10,11 @@ Verifiable Memory-as-a-Service for AI Agents. An MCP server that gives any AI ag
10
10
  npx @brain-protocol/mcp
11
11
  ```
12
12
 
13
- That's it. The server starts in local mode with a SQLite database at the XDG-compliant default path.
13
+ That's it. The server starts in **local mode** with a SQLite database at your OS's standard data directory.
14
14
 
15
- ## Installation
15
+ ## Configure with Claude Desktop
16
16
 
17
- ```bash
18
- npm install -g @brain-protocol/mcp
19
- # or
20
- pnpm add -g @brain-protocol/mcp
21
- ```
22
-
23
- ## Configuration
24
-
25
- ### Claude Desktop
26
-
27
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
17
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
28
18
 
29
19
  ```json
30
20
  {
@@ -37,9 +27,9 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
37
27
  }
38
28
  ```
39
29
 
40
- ### Claude Code
30
+ ## Configure with Cursor
41
31
 
42
- Add to `~/.claude.json`:
32
+ Add to `.cursor/mcp.json` in your project:
43
33
 
44
34
  ```json
45
35
  {
@@ -52,9 +42,9 @@ Add to `~/.claude.json`:
52
42
  }
53
43
  ```
54
44
 
55
- ### Cursor
45
+ ## Configure with Claude Code
56
46
 
57
- Add to `.cursor/mcp.json`:
47
+ Add to `~/.claude.json`:
58
48
 
59
49
  ```json
60
50
  {
@@ -67,9 +57,7 @@ Add to `.cursor/mcp.json`:
67
57
  }
68
58
  ```
69
59
 
70
- ### Cloud Mode
71
-
72
- To connect to a Brain Protocol API instead of local SQLite:
60
+ ### Cloud Mode Configuration
73
61
 
74
62
  ```json
75
63
  {
@@ -86,130 +74,96 @@ To connect to a Brain Protocol API instead of local SQLite:
86
74
  }
87
75
  ```
88
76
 
77
+ ## Tools
78
+
79
+ | Tool | Description |
80
+ |------|-------------|
81
+ | `query_knowledge` | Full-text search with category, author, tag, brain_id filters |
82
+ | `archive_knowledge` | Store a new knowledge entry |
83
+ | `update_knowledge` | Partial update of an existing entry |
84
+ | `delete_knowledge` | Remove an entry by ID |
85
+ | `create_edge` | Create a typed relationship between entries |
86
+ | `get_graph` | Traverse the knowledge graph from any entry |
87
+ | `get_stats` | Knowledge base statistics |
88
+ | `export` | Export all entries and edges as JSON |
89
+ | `import` | Import entries and edges from a JSON export |
90
+ | `prove` | Anchor entry on Starknet (cloud mode) |
91
+ | `verify` | Verify on-chain proof (cloud mode) |
92
+
93
+ ## CLI Options
94
+
95
+ ```
96
+ --help Show help message
97
+ --version Show version number
98
+ --db-path Override SQLite database path
99
+ --cloud Cloud API URL (alternative to BRAIN_API_URL env)
100
+ --api-key API key for cloud mode (alternative to BRAIN_API_KEY env)
101
+ ```
102
+
89
103
  ## Environment Variables
90
104
 
91
105
  | Variable | Default | Description |
92
106
  |----------|---------|-------------|
93
107
  | `BRAIN_API_URL` | _(unset = local mode)_ | Cloud API URL. When set, uses HTTP instead of SQLite |
94
- | `BRAIN_API_KEY` | _(unset)_ | Bearer token for cloud API authentication |
108
+ | `BRAIN_API_KEY` | _(unset)_ | API key for cloud authentication (sent as `X-API-Key` header) |
95
109
  | `BRAIN_DB_PATH` | XDG default | Custom path for the SQLite database file |
96
110
 
97
- ### Default Database Paths
98
-
99
- | Platform | Path |
100
- |----------|------|
101
- | Linux | `~/.local/share/brain-protocol/brain.db` |
102
- | macOS | `~/Library/Application Support/brain-protocol/brain.db` |
103
- | Windows | `%APPDATA%/brain-protocol/brain.db` |
104
-
105
- Override with `XDG_DATA_HOME` (Linux) or `BRAIN_DB_PATH` (any platform).
106
-
107
- ## Tools Reference
108
-
109
- ### query_knowledge
111
+ ## Local vs Cloud Mode
110
112
 
111
- Search the knowledge base using full-text search with filters.
113
+ ### Local Mode (default)
112
114
 
113
- | Parameter | Type | Description |
114
- |-----------|------|-------------|
115
- | `q` | string | Search query |
116
- | `category` | string | Filter by category |
117
- | `author` | string | Filter by author |
118
- | `tags` | string | Filter by tags (comma-separated) |
119
- | `limit` | number | Max results (default 10, max 100) |
120
- | `offset` | number | Pagination offset |
115
+ Data stored in SQLite with FTS5 full-text search, WAL mode, and recursive CTE graph traversal. Works completely offline. Schema auto-migrates between versions.
121
116
 
122
- ### archive_knowledge
117
+ Database location follows OS conventions:
118
+ - **macOS**: `~/Library/Application Support/brain-protocol/brain.db`
119
+ - **Linux**: `~/.local/share/brain-protocol/brain.db`
120
+ - **Windows**: `%APPDATA%/brain-protocol/brain.db`
123
121
 
124
- Store a new knowledge entry.
122
+ Override with `--db-path`, `BRAIN_DB_PATH`, or `XDG_DATA_HOME`.
125
123
 
126
- | Parameter | Type | Required | Description |
127
- |-----------|------|----------|-------------|
128
- | `content` | string | Yes | Knowledge content |
129
- | `content_type` | string | No | markdown, code, decision, pattern, documentation, git_commit, json, structured_data |
130
- | `author` | string | No | Author name (default: user) |
131
- | `category` | string | No | Category (default: documentation) |
132
- | `tags` | string[] | No | Tags array |
133
- | `confidence` | number | No | Confidence 0-1 (default: 0.8) |
134
-
135
- ### create_edge
136
-
137
- Create a relationship between two knowledge entries.
138
-
139
- | Parameter | Type | Required | Description |
140
- |-----------|------|----------|-------------|
141
- | `source_id` | string | Yes | Source entry UUID |
142
- | `target_id` | string | Yes | Target entry UUID |
143
- | `edge_type` | string | Yes | derives_from, conflicts_with, validates, extends, implements, supersedes, tested_by, documented_by, optimizes, related_to |
144
- | `confidence` | number | No | Edge confidence 0-1 |
145
-
146
- ### get_graph
147
-
148
- Traverse the knowledge graph from an entry.
149
-
150
- | Parameter | Type | Required | Description |
151
- |-----------|------|----------|-------------|
152
- | `entry_id` | string | Yes | Starting entry UUID |
153
- | `depth` | number | No | Max depth (default 3, max 5) |
154
-
155
- ### get_stats
156
-
157
- Get knowledge base statistics. No parameters.
158
-
159
- ### prove (cloud only)
160
-
161
- Anchor a knowledge entry on Starknet for verifiable proof.
162
-
163
- | Parameter | Type | Required | Description |
164
- |-----------|------|----------|-------------|
165
- | `entry_id` | string | Yes | Entry UUID to anchor |
166
-
167
- ### verify (cloud only)
168
-
169
- Verify a knowledge entry's on-chain proof.
170
-
171
- | Parameter | Type | Required | Description |
172
- |-----------|------|----------|-------------|
173
- | `entry_id` | string | Yes | Entry UUID to verify |
174
-
175
- ### export
124
+ ### Cloud Mode
176
125
 
177
- Export all knowledge entries and edges.
126
+ Connect to a Brain Protocol API server for multi-device sync, team collaboration, and on-chain verification via Starknet.
178
127
 
179
- | Parameter | Type | Description |
180
- |-----------|------|-------------|
181
- | `format` | string | Export format (json) |
128
+ ```bash
129
+ npx @brain-protocol/mcp --cloud https://brain.api.vauban.tech --api-key YOUR_KEY
130
+ ```
182
131
 
183
132
  ## Architecture
184
133
 
185
134
  ```
186
- @brain-protocol/mcp
187
- ├── index.ts # Entry point: env detection, store init
188
- ├── server.ts # MCP Server factory
189
- ├── store/
190
- ├── adapter.ts # StoreAdapter interface
191
- ├── sqlite.ts # SQLiteStore (better-sqlite3 + FTS5)
192
- ├── cloud.ts # CloudStore (HTTP client)
193
- │ └── paths.ts # XDG-compliant path resolution
194
- └── tools/ # 8 MCP tool handlers
135
+ ┌─────────────────────────────────────────────┐
136
+ │ MCP Protocol (stdio) │
137
+ ├─────────────────────────────────────────────┤
138
+ │ 11 Tool Handlers │
139
+ query | archive | update | delete | edge │
140
+ graph | stats | export | import | prove │
141
+ verify │
142
+ ├─────────────────────────────────────────────┤
143
+ │ StoreAdapter Interface
144
+ ├──────────────────┬──────────────────────────┤
145
+ │ SQLiteStore │ CloudStore │
146
+ │ FTS5 + WAL │ @brain-protocol/sdk │
147
+ │ Graph CTE │ HTTP + API Key │
148
+ │ Schema v2 │ On-chain proof │
149
+ └──────────────────┴──────────────────────────┘
195
150
  ```
196
151
 
197
- **3 production dependencies**: `@modelcontextprotocol/sdk`, `better-sqlite3`, `zod`.
152
+ ## Programmatic Use
198
153
 
199
- ## Local Mode Features
154
+ ```typescript
155
+ import { SQLiteStore, createMCPServer } from "@brain-protocol/mcp";
200
156
 
201
- - SQLite with WAL mode for concurrent reads
202
- - FTS5 full-text search with ranking
203
- - Knowledge graph with recursive CTE traversal
204
- - Cycle detection in graph traversal
205
- - Automatic schema creation on first run
157
+ const store = new SQLiteStore("/path/to/brain.db");
158
+ await store.initialize();
206
159
 
207
- ## Cloud Mode Features
160
+ // Use directly
161
+ const entry = await store.create({ content: "Hello brain" });
162
+ const results = await store.query({ q: "hello" });
208
163
 
209
- - All local features via HTTP API
210
- - `prove`: Anchor knowledge hashes on Starknet (Poseidon hash + L2)
211
- - `verify`: Verify on-chain proofs
212
- - Bearer token authentication
164
+ // Or as MCP server
165
+ const server = createMCPServer(store);
166
+ ```
213
167
 
214
168
  ## License
215
169
 
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export declare const VERSION = "0.2.0";
2
+ export declare const HELP_TEXT = "brain-protocol MCP server v0.2.0\nVerifiable Memory for AI Agents\n\nUsage:\n npx @brain-protocol/mcp [options]\n\nOptions:\n --help Show this help message\n --version Show version number\n --db-path Override SQLite database path (default: XDG data dir)\n --cloud Cloud API URL (alternative to BRAIN_API_URL env)\n --api-key API key for cloud mode (alternative to BRAIN_API_KEY env)\n\nEnvironment variables:\n BRAIN_API_URL Cloud mode API URL (e.g., https://brain.api.vauban.tech)\n BRAIN_API_KEY API key for cloud mode authentication\n BRAIN_DB_PATH Override SQLite database path\n\nExamples:\n # Local mode (default)\n npx @brain-protocol/mcp\n\n # Cloud mode\n npx @brain-protocol/mcp --cloud https://brain.api.vauban.tech --api-key xxx\n\n # Custom database path\n npx @brain-protocol/mcp --db-path ./my-brain.db\n";
3
+ export interface CliArgs {
4
+ help: boolean;
5
+ version: boolean;
6
+ dbPath?: string;
7
+ cloud?: string;
8
+ apiKey?: string;
9
+ }
10
+ export declare function parseArgs(argv: string[]): CliArgs;
11
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,eAAO,MAAM,SAAS,o2BA2BrB,CAAC;AAEF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CA2BjD"}
package/dist/cli.js ADDED
@@ -0,0 +1,56 @@
1
+ export const VERSION = "0.2.0";
2
+ export const HELP_TEXT = `brain-protocol MCP server v${VERSION}
3
+ Verifiable Memory for AI Agents
4
+
5
+ Usage:
6
+ npx @brain-protocol/mcp [options]
7
+
8
+ Options:
9
+ --help Show this help message
10
+ --version Show version number
11
+ --db-path Override SQLite database path (default: XDG data dir)
12
+ --cloud Cloud API URL (alternative to BRAIN_API_URL env)
13
+ --api-key API key for cloud mode (alternative to BRAIN_API_KEY env)
14
+
15
+ Environment variables:
16
+ BRAIN_API_URL Cloud mode API URL (e.g., https://brain.api.vauban.tech)
17
+ BRAIN_API_KEY API key for cloud mode authentication
18
+ BRAIN_DB_PATH Override SQLite database path
19
+
20
+ Examples:
21
+ # Local mode (default)
22
+ npx @brain-protocol/mcp
23
+
24
+ # Cloud mode
25
+ npx @brain-protocol/mcp --cloud https://brain.api.vauban.tech --api-key xxx
26
+
27
+ # Custom database path
28
+ npx @brain-protocol/mcp --db-path ./my-brain.db
29
+ `;
30
+ export function parseArgs(argv) {
31
+ const args = { help: false, version: false };
32
+ for (let i = 0; i < argv.length; i++) {
33
+ const arg = argv[i];
34
+ switch (arg) {
35
+ case "--help":
36
+ case "-h":
37
+ args.help = true;
38
+ break;
39
+ case "--version":
40
+ case "-v":
41
+ args.version = true;
42
+ break;
43
+ case "--db-path":
44
+ args.dbPath = argv[++i];
45
+ break;
46
+ case "--cloud":
47
+ args.cloud = argv[++i];
48
+ break;
49
+ case "--api-key":
50
+ args.apiKey = argv[++i];
51
+ break;
52
+ }
53
+ }
54
+ return args;
55
+ }
56
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,SAAS,GAAG,8BAA8B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B7D,CAAC;AAUF,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,IAAI,GAAY,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAEtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,QAAQ,CAAC;YACd,KAAK,IAAI;gBACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;gBACjB,MAAM;YACR,KAAK,WAAW,CAAC;YACjB,KAAK,IAAI;gBACP,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;gBACpB,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxB,MAAM;YACR,KAAK,SAAS;gBACZ,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBACvB,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxB,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  export { createMCPServer } from "./server.js";
3
3
  export { SQLiteStore } from "./store/sqlite.js";
4
4
  export { CloudStore } from "./store/cloud.js";
5
+ export { parseArgs, VERSION } from "./cli.js";
6
+ export type { CliArgs } from "./cli.js";
5
7
  export type { StoreAdapter } from "./store/adapter.js";
6
8
  export type * from "./types.js";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAiDA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,mBAAmB,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAqEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC9C,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,mBAAmB,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,24 +1,39 @@
1
1
  #!/usr/bin/env node
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { VERSION, HELP_TEXT, parseArgs } from "./cli.js";
3
4
  import { createMCPServer } from "./server.js";
4
5
  import { CloudStore } from "./store/cloud.js";
5
6
  import { SQLiteStore } from "./store/sqlite.js";
6
7
  import { getDbPath } from "./store/paths.js";
7
- function createStore() {
8
- const apiUrl = process.env.BRAIN_API_URL;
8
+ function createStore(args) {
9
+ const apiUrl = args.cloud || process.env.BRAIN_API_URL;
9
10
  if (apiUrl) {
10
- const apiKey = process.env.BRAIN_API_KEY;
11
+ const apiKey = args.apiKey || process.env.BRAIN_API_KEY;
11
12
  return new CloudStore(apiUrl, apiKey);
12
13
  }
14
+ if (args.dbPath) {
15
+ return new SQLiteStore(args.dbPath);
16
+ }
13
17
  return new SQLiteStore();
14
18
  }
15
19
  async function main() {
16
- const store = createStore();
20
+ const args = parseArgs(process.argv.slice(2));
21
+ if (args.help) {
22
+ process.stdout.write(HELP_TEXT);
23
+ process.exit(0);
24
+ }
25
+ if (args.version) {
26
+ process.stdout.write(`${VERSION}\n`);
27
+ process.exit(0);
28
+ }
29
+ const store = createStore(args);
17
30
  await store.initialize();
18
31
  const mode = store.mode;
19
- const location = mode === "local" ? getDbPath() : process.env.BRAIN_API_URL;
20
- process.stderr.write(`brain-protocol MCP server starting (${mode} mode: ${location})\n`);
21
- const server = createMCPServer(store);
32
+ const location = mode === "local"
33
+ ? (args.dbPath || getDbPath())
34
+ : (args.cloud || process.env.BRAIN_API_URL);
35
+ process.stderr.write(`brain-protocol MCP server v${VERSION} (${mode} mode: ${location})\n`);
36
+ const server = createMCPServer(store, VERSION);
22
37
  const transport = new StdioServerTransport();
23
38
  process.on("SIGINT", async () => {
24
39
  await store.close();
@@ -38,4 +53,5 @@ main().catch((err) => {
38
53
  export { createMCPServer } from "./server.js";
39
54
  export { SQLiteStore } from "./store/sqlite.js";
40
55
  export { CloudStore } from "./store/cloud.js";
56
+ export { parseArgs, VERSION } from "./cli.js";
41
57
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,SAAS,WAAW;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAEzC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QACzC,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,WAAW,EAAE,CAAC;AAC3B,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;IAEzB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,MAAM,QAAQ,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CA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AAClB,CAAC,CAAC,CAAC;AAEH,iCAAiC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
package/dist/schemas.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare const queryKnowledgeSchema: z.ZodObject<{
6
6
  tags: z.ZodOptional<z.ZodString>;
7
7
  limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
8
  offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
+ brain_id: z.ZodOptional<z.ZodString>;
9
10
  }, "strip", z.ZodTypeAny, {
10
11
  limit: number;
11
12
  offset: number;
@@ -13,6 +14,7 @@ export declare const queryKnowledgeSchema: z.ZodObject<{
13
14
  category?: string | undefined;
14
15
  author?: string | undefined;
15
16
  tags?: string | undefined;
17
+ brain_id?: string | undefined;
16
18
  }, {
17
19
  q?: string | undefined;
18
20
  category?: string | undefined;
@@ -20,6 +22,7 @@ export declare const queryKnowledgeSchema: z.ZodObject<{
20
22
  tags?: string | undefined;
21
23
  limit?: number | undefined;
22
24
  offset?: number | undefined;
25
+ brain_id?: string | undefined;
23
26
  }>;
24
27
  export declare const archiveKnowledgeSchema: z.ZodObject<{
25
28
  content: z.ZodString;
@@ -29,6 +32,8 @@ export declare const archiveKnowledgeSchema: z.ZodObject<{
29
32
  tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
30
33
  confidence: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
31
34
  metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
35
+ is_public: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
36
+ brain_id: z.ZodOptional<z.ZodString>;
32
37
  }, "strip", z.ZodTypeAny, {
33
38
  category: string;
34
39
  author: string;
@@ -37,14 +42,18 @@ export declare const archiveKnowledgeSchema: z.ZodObject<{
37
42
  content_type: "markdown" | "code" | "decision" | "pattern" | "documentation" | "git_commit" | "json" | "structured_data";
38
43
  confidence: number;
39
44
  metadata: Record<string, unknown>;
45
+ is_public: boolean;
46
+ brain_id?: string | undefined;
40
47
  }, {
41
48
  content: string;
42
49
  category?: string | undefined;
43
50
  author?: string | undefined;
44
51
  tags?: string[] | undefined;
52
+ brain_id?: string | undefined;
45
53
  content_type?: "markdown" | "code" | "decision" | "pattern" | "documentation" | "git_commit" | "json" | "structured_data" | undefined;
46
54
  confidence?: number | undefined;
47
55
  metadata?: Record<string, unknown> | undefined;
56
+ is_public?: boolean | undefined;
48
57
  }>;
49
58
  export declare const createEdgeSchema: z.ZodObject<{
50
59
  source_id: z.ZodString;
@@ -93,4 +102,161 @@ export declare const exportSchema: z.ZodObject<{
93
102
  }, {
94
103
  format?: "json" | undefined;
95
104
  }>;
105
+ export declare const updateKnowledgeSchema: z.ZodObject<{
106
+ id: z.ZodString;
107
+ content: z.ZodOptional<z.ZodString>;
108
+ content_type: z.ZodOptional<z.ZodEnum<["markdown", "code", "decision", "pattern", "documentation", "git_commit", "json", "structured_data"]>>;
109
+ author: z.ZodOptional<z.ZodString>;
110
+ category: z.ZodOptional<z.ZodString>;
111
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
112
+ confidence: z.ZodOptional<z.ZodNumber>;
113
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
114
+ is_public: z.ZodOptional<z.ZodBoolean>;
115
+ brain_id: z.ZodOptional<z.ZodString>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ id: string;
118
+ category?: string | undefined;
119
+ author?: string | undefined;
120
+ tags?: string[] | undefined;
121
+ brain_id?: string | undefined;
122
+ content?: string | undefined;
123
+ content_type?: "markdown" | "code" | "decision" | "pattern" | "documentation" | "git_commit" | "json" | "structured_data" | undefined;
124
+ confidence?: number | undefined;
125
+ metadata?: Record<string, unknown> | undefined;
126
+ is_public?: boolean | undefined;
127
+ }, {
128
+ id: string;
129
+ category?: string | undefined;
130
+ author?: string | undefined;
131
+ tags?: string[] | undefined;
132
+ brain_id?: string | undefined;
133
+ content?: string | undefined;
134
+ content_type?: "markdown" | "code" | "decision" | "pattern" | "documentation" | "git_commit" | "json" | "structured_data" | undefined;
135
+ confidence?: number | undefined;
136
+ metadata?: Record<string, unknown> | undefined;
137
+ is_public?: boolean | undefined;
138
+ }>;
139
+ export declare const deleteKnowledgeSchema: z.ZodObject<{
140
+ id: z.ZodString;
141
+ }, "strip", z.ZodTypeAny, {
142
+ id: string;
143
+ }, {
144
+ id: string;
145
+ }>;
146
+ export declare const importDataSchema: z.ZodObject<{
147
+ entries: z.ZodArray<z.ZodObject<{
148
+ id: z.ZodString;
149
+ content: z.ZodString;
150
+ content_type: z.ZodDefault<z.ZodOptional<z.ZodString>>;
151
+ author: z.ZodDefault<z.ZodOptional<z.ZodString>>;
152
+ category: z.ZodDefault<z.ZodOptional<z.ZodString>>;
153
+ tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
154
+ metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
155
+ confidence: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
156
+ created_at: z.ZodString;
157
+ updated_at: z.ZodString;
158
+ brain_id: z.ZodOptional<z.ZodString>;
159
+ is_public: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
160
+ }, "strip", z.ZodTypeAny, {
161
+ category: string;
162
+ author: string;
163
+ tags: string[];
164
+ content: string;
165
+ content_type: string;
166
+ confidence: number;
167
+ metadata: Record<string, unknown>;
168
+ is_public: boolean;
169
+ id: string;
170
+ created_at: string;
171
+ updated_at: string;
172
+ brain_id?: string | undefined;
173
+ }, {
174
+ content: string;
175
+ id: string;
176
+ created_at: string;
177
+ updated_at: string;
178
+ category?: string | undefined;
179
+ author?: string | undefined;
180
+ tags?: string[] | undefined;
181
+ brain_id?: string | undefined;
182
+ content_type?: string | undefined;
183
+ confidence?: number | undefined;
184
+ metadata?: Record<string, unknown> | undefined;
185
+ is_public?: boolean | undefined;
186
+ }>, "many">;
187
+ edges: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
188
+ id: z.ZodString;
189
+ source_id: z.ZodString;
190
+ target_id: z.ZodString;
191
+ edge_type: z.ZodString;
192
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
193
+ created_at: z.ZodString;
194
+ }, "strip", z.ZodTypeAny, {
195
+ source_id: string;
196
+ target_id: string;
197
+ edge_type: string;
198
+ id: string;
199
+ created_at: string;
200
+ confidence?: number | null | undefined;
201
+ }, {
202
+ source_id: string;
203
+ target_id: string;
204
+ edge_type: string;
205
+ id: string;
206
+ created_at: string;
207
+ confidence?: number | null | undefined;
208
+ }>, "many">>>;
209
+ exportedAt: z.ZodOptional<z.ZodString>;
210
+ mode: z.ZodOptional<z.ZodEnum<["local", "cloud"]>>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ entries: {
213
+ category: string;
214
+ author: string;
215
+ tags: string[];
216
+ content: string;
217
+ content_type: string;
218
+ confidence: number;
219
+ metadata: Record<string, unknown>;
220
+ is_public: boolean;
221
+ id: string;
222
+ created_at: string;
223
+ updated_at: string;
224
+ brain_id?: string | undefined;
225
+ }[];
226
+ edges: {
227
+ source_id: string;
228
+ target_id: string;
229
+ edge_type: string;
230
+ id: string;
231
+ created_at: string;
232
+ confidence?: number | null | undefined;
233
+ }[];
234
+ exportedAt?: string | undefined;
235
+ mode?: "local" | "cloud" | undefined;
236
+ }, {
237
+ entries: {
238
+ content: string;
239
+ id: string;
240
+ created_at: string;
241
+ updated_at: string;
242
+ category?: string | undefined;
243
+ author?: string | undefined;
244
+ tags?: string[] | undefined;
245
+ brain_id?: string | undefined;
246
+ content_type?: string | undefined;
247
+ confidence?: number | undefined;
248
+ metadata?: Record<string, unknown> | undefined;
249
+ is_public?: boolean | undefined;
250
+ }[];
251
+ edges?: {
252
+ source_id: string;
253
+ target_id: string;
254
+ edge_type: string;
255
+ id: string;
256
+ created_at: string;
257
+ confidence?: number | null | undefined;
258
+ }[] | undefined;
259
+ exportedAt?: string | undefined;
260
+ mode?: "local" | "cloud" | undefined;
261
+ }>;
96
262
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;EAWjC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAgB3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAGzB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;EAEtB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;EAEvB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;EAEvB,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;EAQ/B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAajC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAgB3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAGzB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;EAEtB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;EAEvB,CAAC;AAEH,eAAO,MAAM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