@hiveforge/hivemind-mcp 0.1.0
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/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/graph/builder.d.ts +47 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/builder.js +182 -0
- package/dist/graph/builder.js.map +1 -0
- package/dist/graph/database.d.ts +71 -0
- package/dist/graph/database.d.ts.map +1 -0
- package/dist/graph/database.js +255 -0
- package/dist/graph/database.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/markdown.d.ts +29 -0
- package/dist/parser/markdown.d.ts.map +1 -0
- package/dist/parser/markdown.js +122 -0
- package/dist/parser/markdown.js.map +1 -0
- package/dist/search/engine.d.ts +48 -0
- package/dist/search/engine.d.ts.map +1 -0
- package/dist/search/engine.js +88 -0
- package/dist/search/engine.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +504 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.d.ts +646 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +133 -0
- package/dist/types/index.js.map +1 -0
- package/dist/vault/reader.d.ts +56 -0
- package/dist/vault/reader.d.ts.map +1 -0
- package/dist/vault/reader.js +185 -0
- package/dist/vault/reader.js.map +1 -0
- package/dist/vault/watcher.d.ts +33 -0
- package/dist/vault/watcher.d.ts.map +1 -0
- package/dist/vault/watcher.js +92 -0
- package/dist/vault/watcher.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAQ1B,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAkB;gBAEvB,MAAM,EAAE,cAAc;IA6BlC,OAAO,CAAC,aAAa;YAwMP,oBAAoB;YA+CpB,mBAAmB;YA+CnB,iBAAiB;IAiC/B,OAAO,CAAC,iBAAiB;YAcX,aAAa;IAS3B,OAAO,CAAC,gCAAgC;IAwExC,OAAO,CAAC,+BAA+B;IA8CvC,OAAO,CAAC,mBAAmB;IA2BrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA6B7B"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { QueryCharacterArgsSchema, QueryLocationArgsSchema, SearchVaultArgsSchema, } from './types/index.js';
|
|
5
|
+
import { VaultReader } from './vault/reader.js';
|
|
6
|
+
import { VaultWatcher } from './vault/watcher.js';
|
|
7
|
+
import { HivemindDatabase } from './graph/database.js';
|
|
8
|
+
import { GraphBuilder } from './graph/builder.js';
|
|
9
|
+
import { SearchEngine } from './search/engine.js';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
export class HivemindServer {
|
|
12
|
+
server;
|
|
13
|
+
config;
|
|
14
|
+
vaultReader;
|
|
15
|
+
vaultWatcher;
|
|
16
|
+
database;
|
|
17
|
+
graphBuilder;
|
|
18
|
+
searchEngine;
|
|
19
|
+
isIndexed = false;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
this.vaultReader = new VaultReader(config.vault);
|
|
23
|
+
this.vaultWatcher = new VaultWatcher(config.vault);
|
|
24
|
+
// Initialize database
|
|
25
|
+
const dbPath = join(config.vault.path, '.hivemind', 'vault.db');
|
|
26
|
+
this.database = new HivemindDatabase({ path: dbPath });
|
|
27
|
+
this.graphBuilder = new GraphBuilder(this.database);
|
|
28
|
+
this.searchEngine = new SearchEngine(this.database);
|
|
29
|
+
this.server = new Server({
|
|
30
|
+
name: 'hivemind-mcp',
|
|
31
|
+
version: '0.1.0',
|
|
32
|
+
}, {
|
|
33
|
+
capabilities: {
|
|
34
|
+
tools: {},
|
|
35
|
+
resources: {},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
this.setupHandlers();
|
|
39
|
+
this.setupVaultWatcher();
|
|
40
|
+
}
|
|
41
|
+
setupHandlers() {
|
|
42
|
+
// List available tools
|
|
43
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
44
|
+
return {
|
|
45
|
+
tools: [
|
|
46
|
+
{
|
|
47
|
+
name: 'query_character',
|
|
48
|
+
description: 'Retrieve detailed information about a character from the worldbuilding vault',
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
id: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Character ID or name to query',
|
|
55
|
+
},
|
|
56
|
+
includeContent: {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
description: 'Include content body in response (default: true)',
|
|
59
|
+
default: true,
|
|
60
|
+
},
|
|
61
|
+
contentLimit: {
|
|
62
|
+
type: 'number',
|
|
63
|
+
description: 'Maximum characters of content to return (default: 500, max: 5000)',
|
|
64
|
+
default: 500,
|
|
65
|
+
minimum: 100,
|
|
66
|
+
maximum: 5000,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
required: ['id'],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'query_location',
|
|
74
|
+
description: 'Retrieve information about a location from the worldbuilding vault',
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
id: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'Location ID or name to query',
|
|
81
|
+
},
|
|
82
|
+
includeContent: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
description: 'Include content body in response (default: true)',
|
|
85
|
+
default: true,
|
|
86
|
+
},
|
|
87
|
+
contentLimit: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
description: 'Maximum characters of content to return (default: 500, max: 5000)',
|
|
90
|
+
default: 500,
|
|
91
|
+
minimum: 100,
|
|
92
|
+
maximum: 5000,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
required: ['id'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'search_vault',
|
|
100
|
+
description: 'Search across all worldbuilding content using hybrid search (keyword + semantic + graph)',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
query: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: 'Search query text',
|
|
107
|
+
},
|
|
108
|
+
filters: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
type: {
|
|
112
|
+
type: 'array',
|
|
113
|
+
items: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
enum: ['character', 'location', 'event', 'faction', 'system', 'asset', 'lore'],
|
|
116
|
+
},
|
|
117
|
+
description: 'Filter by note type',
|
|
118
|
+
},
|
|
119
|
+
status: {
|
|
120
|
+
type: 'array',
|
|
121
|
+
items: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
enum: ['draft', 'pending', 'canon', 'non-canon', 'archived'],
|
|
124
|
+
},
|
|
125
|
+
description: 'Filter by canon status',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
limit: {
|
|
130
|
+
type: 'number',
|
|
131
|
+
description: 'Maximum number of results (1-100)',
|
|
132
|
+
default: 10,
|
|
133
|
+
},
|
|
134
|
+
includeContent: {
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
description: 'Include content snippets in results (default: false for efficiency)',
|
|
137
|
+
default: false,
|
|
138
|
+
},
|
|
139
|
+
contentLimit: {
|
|
140
|
+
type: 'number',
|
|
141
|
+
description: 'Maximum characters of content per result (default: 300, max: 2000)',
|
|
142
|
+
default: 300,
|
|
143
|
+
minimum: 100,
|
|
144
|
+
maximum: 2000,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
required: ['query'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
// Handle tool calls
|
|
154
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
155
|
+
const { name, arguments: args } = request.params;
|
|
156
|
+
try {
|
|
157
|
+
switch (name) {
|
|
158
|
+
case 'query_character': {
|
|
159
|
+
const parsed = QueryCharacterArgsSchema.parse(args);
|
|
160
|
+
return await this.handleQueryCharacter(parsed);
|
|
161
|
+
}
|
|
162
|
+
case 'query_location': {
|
|
163
|
+
const parsed = QueryLocationArgsSchema.parse(args);
|
|
164
|
+
return await this.handleQueryLocation(parsed);
|
|
165
|
+
}
|
|
166
|
+
case 'search_vault': {
|
|
167
|
+
const parsed = SearchVaultArgsSchema.parse(args);
|
|
168
|
+
return await this.handleSearchVault(parsed);
|
|
169
|
+
}
|
|
170
|
+
default:
|
|
171
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
176
|
+
return {
|
|
177
|
+
content: [
|
|
178
|
+
{
|
|
179
|
+
type: 'text',
|
|
180
|
+
text: `Error: ${errorMessage}`,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
isError: true,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
// List available resources
|
|
188
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
189
|
+
return {
|
|
190
|
+
resources: [
|
|
191
|
+
{
|
|
192
|
+
uri: 'vault://index',
|
|
193
|
+
name: 'Vault Index',
|
|
194
|
+
description: 'Complete index of all entities in the worldbuilding vault',
|
|
195
|
+
mimeType: 'application/json',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
// Handle resource reads
|
|
201
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
202
|
+
const { uri } = request.params;
|
|
203
|
+
if (uri === 'vault://index') {
|
|
204
|
+
await this.ensureIndexed();
|
|
205
|
+
const stats = this.vaultReader.getStats();
|
|
206
|
+
const allNotes = this.vaultReader.getAllNotes();
|
|
207
|
+
const index = {
|
|
208
|
+
vault: this.config.vault.path,
|
|
209
|
+
stats,
|
|
210
|
+
notes: allNotes.map(note => ({
|
|
211
|
+
id: note.id,
|
|
212
|
+
type: note.frontmatter.type,
|
|
213
|
+
status: note.frontmatter.status,
|
|
214
|
+
title: note.frontmatter.title || note.fileName,
|
|
215
|
+
path: note.filePath,
|
|
216
|
+
links: note.links,
|
|
217
|
+
})),
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
contents: [
|
|
221
|
+
{
|
|
222
|
+
uri,
|
|
223
|
+
mimeType: 'application/json',
|
|
224
|
+
text: JSON.stringify(index, null, 2),
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async handleQueryCharacter(args) {
|
|
233
|
+
await this.ensureIndexed();
|
|
234
|
+
// Use search engine to get node with relationships
|
|
235
|
+
const result = await this.searchEngine.getNodeWithRelationships(args.id);
|
|
236
|
+
if (!result) {
|
|
237
|
+
// Try fuzzy search
|
|
238
|
+
const searchResults = await this.searchEngine.search(args.id, {
|
|
239
|
+
limit: 5,
|
|
240
|
+
filters: { type: ['character'] }
|
|
241
|
+
});
|
|
242
|
+
if (searchResults.nodes.length === 0) {
|
|
243
|
+
return {
|
|
244
|
+
content: [{
|
|
245
|
+
type: 'text',
|
|
246
|
+
text: `Character not found: "${args.id}"\n\nTry searching with: search_vault`,
|
|
247
|
+
}],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
// Return suggestions
|
|
251
|
+
const suggestions = searchResults.nodes.map(n => `- ${n.title} (${n.id})`).join('\n');
|
|
252
|
+
return {
|
|
253
|
+
content: [{
|
|
254
|
+
type: 'text',
|
|
255
|
+
text: `Character "${args.id}" not found. Did you mean:\n\n${suggestions}`,
|
|
256
|
+
}],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
// Format comprehensive response with relationships
|
|
260
|
+
const response = this.formatCharacterWithRelationships(result, args.includeContent ?? true, args.contentLimit ?? 500);
|
|
261
|
+
return {
|
|
262
|
+
content: [{
|
|
263
|
+
type: 'text',
|
|
264
|
+
text: response,
|
|
265
|
+
}],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async handleQueryLocation(args) {
|
|
269
|
+
await this.ensureIndexed();
|
|
270
|
+
// Use search engine to get node with relationships
|
|
271
|
+
const result = await this.searchEngine.getNodeWithRelationships(args.id);
|
|
272
|
+
if (!result) {
|
|
273
|
+
// Try fuzzy search
|
|
274
|
+
const searchResults = await this.searchEngine.search(args.id, {
|
|
275
|
+
limit: 5,
|
|
276
|
+
filters: { type: ['location'] }
|
|
277
|
+
});
|
|
278
|
+
if (searchResults.nodes.length === 0) {
|
|
279
|
+
return {
|
|
280
|
+
content: [{
|
|
281
|
+
type: 'text',
|
|
282
|
+
text: `Location not found: "${args.id}"\n\nTry searching with: search_vault`,
|
|
283
|
+
}],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
// Return suggestions
|
|
287
|
+
const suggestions = searchResults.nodes.map(n => `- ${n.title} (${n.id})`).join('\n');
|
|
288
|
+
return {
|
|
289
|
+
content: [{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: `Location "${args.id}" not found. Did you mean:\n\n${suggestions}`,
|
|
292
|
+
}],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// Format comprehensive response with relationships
|
|
296
|
+
const response = this.formatLocationWithRelationships(result, args.includeContent ?? true, args.contentLimit ?? 500);
|
|
297
|
+
return {
|
|
298
|
+
content: [{
|
|
299
|
+
type: 'text',
|
|
300
|
+
text: response,
|
|
301
|
+
}],
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
async handleSearchVault(args) {
|
|
305
|
+
await this.ensureIndexed();
|
|
306
|
+
// Use enhanced search engine
|
|
307
|
+
const results = await this.searchEngine.search(args.query, {
|
|
308
|
+
limit: args.limit || 10,
|
|
309
|
+
includeRelationships: true,
|
|
310
|
+
filters: args.filters,
|
|
311
|
+
});
|
|
312
|
+
if (results.nodes.length === 0) {
|
|
313
|
+
return {
|
|
314
|
+
content: [{
|
|
315
|
+
type: 'text',
|
|
316
|
+
text: `No results found for: "${args.query}"\n\nTry different keywords or check spelling.`,
|
|
317
|
+
}],
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const response = this.formatSearchResults(results, args.includeContent ?? false, args.contentLimit ?? 300);
|
|
321
|
+
return {
|
|
322
|
+
content: [{
|
|
323
|
+
type: 'text',
|
|
324
|
+
text: response,
|
|
325
|
+
}],
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
setupVaultWatcher() {
|
|
329
|
+
// Register change handler
|
|
330
|
+
this.vaultWatcher.onChange(async (event, filePath) => {
|
|
331
|
+
console.error(`Vault change detected: ${event} - ${filePath}`);
|
|
332
|
+
// Re-index on changes
|
|
333
|
+
if (event === 'add' || event === 'change') {
|
|
334
|
+
await this.vaultReader.scanVault();
|
|
335
|
+
const allNotes = this.vaultReader.getAllNotes();
|
|
336
|
+
this.graphBuilder.buildGraph(allNotes);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
async ensureIndexed() {
|
|
341
|
+
if (!this.isIndexed) {
|
|
342
|
+
await this.vaultReader.scanVault();
|
|
343
|
+
const allNotes = this.vaultReader.getAllNotes();
|
|
344
|
+
this.graphBuilder.buildGraph(allNotes);
|
|
345
|
+
this.isIndexed = true;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
formatCharacterWithRelationships(result, includeContent = true, contentLimit = 500) {
|
|
349
|
+
const { node, relatedNodes } = result;
|
|
350
|
+
const props = node.properties;
|
|
351
|
+
let response = `# ${node.title}\n\n`;
|
|
352
|
+
response += `**Type**: Character | **Status**: ${node.status} | **ID**: \`${node.id}\`\n\n`;
|
|
353
|
+
// Basic info
|
|
354
|
+
if (props.age)
|
|
355
|
+
response += `**Age**: ${props.age} | `;
|
|
356
|
+
if (props.gender)
|
|
357
|
+
response += `**Gender**: ${props.gender} | `;
|
|
358
|
+
if (props.race)
|
|
359
|
+
response += `**Race**: ${props.race}`;
|
|
360
|
+
response += `\n\n`;
|
|
361
|
+
// Content (if requested)
|
|
362
|
+
if (includeContent && node.content) {
|
|
363
|
+
response += `## Description\n`;
|
|
364
|
+
const content = node.content.trim();
|
|
365
|
+
if (content.length > contentLimit) {
|
|
366
|
+
response += `${content.substring(0, contentLimit)}...\n\n`;
|
|
367
|
+
response += `*[Truncated at ${contentLimit} chars. Full content: ${content.length} chars]*\n\n`;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
response += `${content}\n\n`;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// Appearance
|
|
374
|
+
if (props.appearance) {
|
|
375
|
+
response += `## Appearance\n`;
|
|
376
|
+
if (typeof props.appearance === 'object') {
|
|
377
|
+
for (const [key, value] of Object.entries(props.appearance)) {
|
|
378
|
+
response += `- **${key}**: ${value}\n`;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
response += `${props.appearance}\n`;
|
|
383
|
+
}
|
|
384
|
+
response += `\n`;
|
|
385
|
+
}
|
|
386
|
+
// Personality
|
|
387
|
+
if (props.personality) {
|
|
388
|
+
response += `## Personality\n`;
|
|
389
|
+
if (typeof props.personality === 'object') {
|
|
390
|
+
for (const [key, value] of Object.entries(props.personality)) {
|
|
391
|
+
response += `- **${key}**: ${JSON.stringify(value)}\n`;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
response += `${props.personality}\n`;
|
|
396
|
+
}
|
|
397
|
+
response += `\n`;
|
|
398
|
+
}
|
|
399
|
+
// Relationships (from graph)
|
|
400
|
+
if (relatedNodes.length > 0) {
|
|
401
|
+
response += `## Relationships\n`;
|
|
402
|
+
const characters = relatedNodes.filter((n) => n.type === 'character');
|
|
403
|
+
const locations = relatedNodes.filter((n) => n.type === 'location');
|
|
404
|
+
if (characters.length > 0) {
|
|
405
|
+
response += `**Characters**: ${characters.map((c) => c.title).join(', ')}\n`;
|
|
406
|
+
}
|
|
407
|
+
if (locations.length > 0) {
|
|
408
|
+
response += `**Locations**: ${locations.map((l) => l.title).join(', ')}\n`;
|
|
409
|
+
}
|
|
410
|
+
response += `\n`;
|
|
411
|
+
}
|
|
412
|
+
response += `---\n*Source: ${node.filePath}*\n`;
|
|
413
|
+
response += `*Last updated: ${new Date(node.updated).toLocaleString()}*`;
|
|
414
|
+
return response;
|
|
415
|
+
}
|
|
416
|
+
formatLocationWithRelationships(result, includeContent = true, contentLimit = 500) {
|
|
417
|
+
const { node, relatedNodes } = result;
|
|
418
|
+
const props = node.properties;
|
|
419
|
+
let response = `# ${node.title}\n\n`;
|
|
420
|
+
response += `**Type**: Location | **Status**: ${node.status} | **ID**: \`${node.id}\`\n\n`;
|
|
421
|
+
// Basic info
|
|
422
|
+
if (props.region)
|
|
423
|
+
response += `**Region**: ${props.region} | `;
|
|
424
|
+
if (props.category)
|
|
425
|
+
response += `**Category**: ${props.category} | `;
|
|
426
|
+
if (props.climate)
|
|
427
|
+
response += `**Climate**: ${props.climate}`;
|
|
428
|
+
response += `\n\n`;
|
|
429
|
+
// Content (if requested)
|
|
430
|
+
if (includeContent && node.content) {
|
|
431
|
+
response += `## Description\n`;
|
|
432
|
+
const content = node.content.trim();
|
|
433
|
+
if (content.length > contentLimit) {
|
|
434
|
+
response += `${content.substring(0, contentLimit)}...\n\n`;
|
|
435
|
+
response += `*[Truncated at ${contentLimit} chars. Full content: ${content.length} chars]*\n\n`;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
response += `${content}\n\n`;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Connected entities (from graph)
|
|
442
|
+
if (relatedNodes.length > 0) {
|
|
443
|
+
response += `## Connected Entities\n`;
|
|
444
|
+
const characters = relatedNodes.filter((n) => n.type === 'character');
|
|
445
|
+
const locations = relatedNodes.filter((n) => n.type === 'location');
|
|
446
|
+
if (characters.length > 0) {
|
|
447
|
+
response += `**Inhabitants**: ${characters.map((c) => c.title).join(', ')}\n`;
|
|
448
|
+
}
|
|
449
|
+
if (locations.length > 0) {
|
|
450
|
+
response += `**Connected Locations**: ${locations.map((l) => l.title).join(', ')}\n`;
|
|
451
|
+
}
|
|
452
|
+
response += `\n`;
|
|
453
|
+
}
|
|
454
|
+
response += `---\n*Source: ${node.filePath}*\n`;
|
|
455
|
+
response += `*Last updated: ${new Date(node.updated).toLocaleString()}*`;
|
|
456
|
+
return response;
|
|
457
|
+
}
|
|
458
|
+
formatSearchResults(results, includeContent = false, contentLimit = 300) {
|
|
459
|
+
const { nodes, metadata } = results;
|
|
460
|
+
let response = `# Search Results\n\n`;
|
|
461
|
+
response += `Found ${metadata.totalResults} results in ${metadata.executionTime}ms (showing ${nodes.length}):\n\n`;
|
|
462
|
+
for (const node of nodes) {
|
|
463
|
+
response += `## ${node.title}\n`;
|
|
464
|
+
response += `- **Type**: ${node.type} | **Status**: ${node.status}\n`;
|
|
465
|
+
response += `- **ID**: \`${node.id}\`\n`;
|
|
466
|
+
response += `- **Path**: ${node.filePath}\n`;
|
|
467
|
+
if (includeContent && node.content) {
|
|
468
|
+
const content = node.content.trim();
|
|
469
|
+
if (content.length > contentLimit) {
|
|
470
|
+
response += `- **Snippet**: ${content.substring(0, contentLimit)}...\n`;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
response += `- **Snippet**: ${content}\n`;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
response += `\n`;
|
|
477
|
+
}
|
|
478
|
+
return response;
|
|
479
|
+
}
|
|
480
|
+
async start() {
|
|
481
|
+
// Initial vault scan
|
|
482
|
+
console.error('Performing initial vault scan...');
|
|
483
|
+
await this.vaultReader.scanVault();
|
|
484
|
+
// Build knowledge graph
|
|
485
|
+
const allNotes = this.vaultReader.getAllNotes();
|
|
486
|
+
this.graphBuilder.buildGraph(allNotes);
|
|
487
|
+
this.isIndexed = true;
|
|
488
|
+
// Start file watcher
|
|
489
|
+
if (this.config.vault.watchForChanges) {
|
|
490
|
+
this.vaultWatcher.start();
|
|
491
|
+
}
|
|
492
|
+
// Start MCP server
|
|
493
|
+
const transport = new StdioServerTransport();
|
|
494
|
+
await this.server.connect(transport);
|
|
495
|
+
console.error('Hivemind MCP server started');
|
|
496
|
+
console.error(`Vault path: ${this.config.vault.path}`);
|
|
497
|
+
console.error(`Transport: ${this.config.server.transport}`);
|
|
498
|
+
const vaultStats = this.vaultReader.getStats();
|
|
499
|
+
const dbStats = this.database.getStats();
|
|
500
|
+
console.error(`Vault: ${vaultStats.totalNotes} notes`);
|
|
501
|
+
console.error(`Database: ${dbStats.nodes} nodes, ${dbStats.relationships} relationships`);
|
|
502
|
+
}
|
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