@hiveai/mcp 0.9.0 → 0.9.2

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
@@ -8,11 +8,15 @@ Connect your AI coding tools to a shared, version-controlled knowledge base. Eve
8
8
 
9
9
  ## Install
10
10
 
11
+ **Recommended:** install only `@hiveai/cli`. The MCP server is **bundled** inside `haive` — configure clients with `command: "haive"` and `args: ["mcp", "--stdio"]` (see `@hiveai/cli` README).
12
+
13
+ Standalone package (legacy / advanced):
14
+
11
15
  ```bash
12
16
  npm install -g @hiveai/mcp
13
17
  ```
14
18
 
15
- Also install the CLI to manage memories:
19
+ You usually still want the CLI for `haive init`, `haive sync`, etc.:
16
20
 
17
21
  ```bash
18
22
  npm install -g @hiveai/cli
@@ -50,8 +54,8 @@ Add to `~/.claude.json` (global) or `.claude/settings.json` (per-project):
50
54
  {
51
55
  "mcpServers": {
52
56
  "haive": {
53
- "command": "haive-mcp",
54
- "args": ["--root", "/absolute/path/to/your/project"]
57
+ "command": "haive",
58
+ "args": ["mcp", "--stdio", "--root", "/absolute/path/to/your/project"]
55
59
  }
56
60
  }
57
61
  }
@@ -65,8 +69,8 @@ Add to `~/.cursor/mcp.json`:
65
69
  {
66
70
  "mcpServers": {
67
71
  "haive": {
68
- "command": "haive-mcp",
69
- "args": ["--root", "/absolute/path/to/your/project"]
72
+ "command": "haive",
73
+ "args": ["mcp", "--stdio", "--root", "/absolute/path/to/your/project"]
70
74
  }
71
75
  }
72
76
  }
@@ -75,7 +79,7 @@ Add to `~/.cursor/mcp.json`:
75
79
  ### VS Code
76
80
 
77
81
  ```bash
78
- code --add-mcp '{"name":"haive","command":"haive-mcp","args":["--root","/absolute/path/to/project"]}'
82
+ code --add-mcp '{"name":"haive","command":"haive","args":["mcp","--stdio","--root","/absolute/path/to/project"]}'
79
83
  ```
80
84
 
81
85
  ### Project-scoped (auto-detected)
@@ -86,8 +90,9 @@ Add a `.mcp.json` at the project root:
86
90
  {
87
91
  "mcpServers": {
88
92
  "haive": {
89
- "command": "haive-mcp",
90
- "args": ["--root", "."]
93
+ "command": "haive",
94
+ "args": ["mcp", "--stdio"],
95
+ "env": { "HAIVE_PROJECT_ROOT": "/absolute/path/to/your/project" }
91
96
  }
92
97
  }
93
98
  }
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/index.ts
4
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
-
6
3
  // src/server.ts
7
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
6
 
9
7
  // src/context.ts
10
8
  import { findProjectRoot, resolveHaivePaths } from "@hiveai/core";
@@ -142,7 +140,9 @@ var MemSaveInputSchema = {
142
140
  ),
143
141
  slug: z4.string().min(1).describe("Short human-readable identifier \u2014 becomes part of the filename"),
144
142
  body: z4.string().describe("Markdown body of the memory"),
145
- scope: z4.enum(["personal", "team", "module"]).default("personal").describe("Visibility scope: personal | team | module"),
143
+ scope: z4.enum(["personal", "team", "module"]).optional().describe(
144
+ "Visibility scope: personal | team | module. When omitted, falls back to defaultScope in haive.config.json (default: personal)."
145
+ ),
146
146
  module: z4.string().optional().describe("Module name (required when scope=module)"),
147
147
  tags: z4.array(z4.string()).default([]).describe("Tags for filtering"),
148
148
  domain: z4.string().optional().describe("Domain (e.g. transactions, billing)"),
@@ -164,12 +164,14 @@ async function memSave(input, ctx) {
164
164
  );
165
165
  }
166
166
  const existing = existsSync4(ctx.paths.memoriesDir) ? await loadMemoriesFromDir2(ctx.paths.memoriesDir) : [];
167
+ const haiveConfig = await loadConfig(ctx.paths);
168
+ const resolvedScope = input.scope ?? haiveConfig.defaultScope ?? "personal";
167
169
  const invalidPaths = input.paths.filter(
168
170
  (p) => !existsSync4(path3.resolve(ctx.paths.root, p))
169
171
  );
170
172
  const incomingHash = bodyHash(input.body);
171
173
  const hashDuplicate = existing.find(
172
- ({ memory }) => bodyHash(memory.body) === incomingHash && memory.frontmatter.scope === input.scope
174
+ ({ memory }) => bodyHash(memory.body) === incomingHash && memory.frontmatter.scope === resolvedScope
173
175
  );
174
176
  if (hashDuplicate) {
175
177
  throw new Error(
@@ -178,7 +180,7 @@ async function memSave(input, ctx) {
178
180
  }
179
181
  if (input.topic) {
180
182
  const topicMatch = existing.find(
181
- ({ memory }) => memory.frontmatter.topic === input.topic && memory.frontmatter.scope === input.scope && (!input.module || memory.frontmatter.module === input.module)
183
+ ({ memory }) => memory.frontmatter.topic === input.topic && memory.frontmatter.scope === resolvedScope && (!input.module || memory.frontmatter.module === input.module)
182
184
  );
183
185
  if (topicMatch) {
184
186
  const fm = topicMatch.memory.frontmatter;
@@ -208,8 +210,6 @@ async function memSave(input, ctx) {
208
210
  };
209
211
  }
210
212
  }
211
- const haiveConfig = await loadConfig(ctx.paths);
212
- const resolvedScope = input.scope !== "personal" ? input.scope : haiveConfig.defaultScope ?? "personal";
213
213
  const frontmatter = buildFrontmatter({
214
214
  type: input.type,
215
215
  slug: input.slug,
@@ -1464,8 +1464,9 @@ async function getBriefing(input, ctx) {
1464
1464
  if (input.track && memories.length > 0) {
1465
1465
  await trackReads3(ctx.paths, memories.map((m) => m.id));
1466
1466
  const freshUsage = await loadUsageIndex7(ctx.paths);
1467
+ const cfg = await loadConfig3(ctx.paths);
1467
1468
  const rule = {
1468
- minReads: DEFAULT_AUTO_PROMOTE_RULE.minReads,
1469
+ minReads: cfg.autoPromoteMinReads ?? DEFAULT_AUTO_PROMOTE_RULE.minReads,
1469
1470
  maxRejections: DEFAULT_AUTO_PROMOTE_RULE.maxRejections
1470
1471
  };
1471
1472
  for (const m of memories) {
@@ -2813,7 +2814,9 @@ async function patternDetect(input, ctx) {
2813
2814
  for (const file of configFiles.slice(0, 5)) {
2814
2815
  const diff = gitFileDiff(ctx.paths.root, file, input.since_days);
2815
2816
  if (!diff) continue;
2816
- const slug = path11.basename(file).replace(/\.[^.]+$/, "").replace(/[^a-z0-9]/gi, "-").toLowerCase().slice(0, 40);
2817
+ const parentDir = path11.basename(path11.dirname(file));
2818
+ const baseName = path11.basename(file).replace(/\.[^.]+$/, "");
2819
+ const slug = `${parentDir}-${baseName}`.replace(/[^a-z0-9]/gi, "-").toLowerCase().slice(0, 40);
2817
2820
  matches.push({
2818
2821
  kind: "config_change",
2819
2822
  signal: `Config file modified: ${file}`,
@@ -3212,7 +3215,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
3212
3215
 
3213
3216
  // src/server.ts
3214
3217
  var SERVER_NAME = "haive";
3215
- var SERVER_VERSION = "0.9.0";
3218
+ var SERVER_VERSION = "0.9.2";
3216
3219
  function jsonResult(data) {
3217
3220
  return {
3218
3221
  content: [
@@ -3941,9 +3944,13 @@ function createHaiveServer(options = {}) {
3941
3944
  );
3942
3945
  return { server, context, tracker };
3943
3946
  }
3944
-
3945
- // src/index.ts
3946
- function parseArgs(argv) {
3947
+ function parseMcpCliArgs(argv) {
3948
+ for (let i = 2; i < argv.length; i++) {
3949
+ const arg = argv[i];
3950
+ if (arg === "--version" || arg === "-V") {
3951
+ return { versionOnly: true };
3952
+ }
3953
+ }
3947
3954
  const out = {};
3948
3955
  for (let i = 2; i < argv.length; i++) {
3949
3956
  const arg = argv[i];
@@ -3953,18 +3960,26 @@ function parseArgs(argv) {
3953
3960
  out.root = arg.slice("--root=".length);
3954
3961
  }
3955
3962
  }
3956
- return out;
3963
+ return { root: out.root, versionOnly: false };
3957
3964
  }
3958
- async function main() {
3959
- const { root } = parseArgs(process.argv);
3960
- const { server, context } = createHaiveServer({ root });
3965
+ function printHaiveMcpVersion() {
3966
+ console.log(SERVER_VERSION);
3967
+ }
3968
+ async function runHaiveMcpStdio(options) {
3969
+ const { server, context } = createHaiveServer({ root: options.root });
3961
3970
  console.error(
3962
3971
  `[haive-mcp] starting server v${SERVER_VERSION} (project root: ${context.paths.root})`
3963
3972
  );
3964
- const transport = new StdioServerTransport();
3965
- await server.connect(transport);
3973
+ await server.connect(new StdioServerTransport());
3974
+ }
3975
+
3976
+ // src/index.ts
3977
+ var parsed = parseMcpCliArgs(process.argv);
3978
+ if (parsed.versionOnly) {
3979
+ printHaiveMcpVersion();
3980
+ process.exit(0);
3966
3981
  }
3967
- main().catch((err) => {
3982
+ runHaiveMcpStdio({ root: parsed.root }).catch((err) => {
3968
3983
  console.error("[haive-mcp] fatal:", err instanceof Error ? err.message : err);
3969
3984
  process.exit(1);
3970
3985
  });