@ngao/search 1.0.0-alpha.4 ā 1.0.0-alpha.5
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/dist-bundled/main.js +38 -28
- package/package.json +1 -1
package/dist-bundled/main.js
CHANGED
|
@@ -33365,18 +33365,27 @@ const logger_1 = __webpack_require__(1789);
|
|
|
33365
33365
|
// Check for --setup flag for interactive setup
|
|
33366
33366
|
const args = process.argv.slice(2);
|
|
33367
33367
|
const setupMode = args.includes('--setup') || process.env.NGAO_SETUP === 'true';
|
|
33368
|
+
// When setup completes, auto-start in MCP stdio mode for Claude
|
|
33369
|
+
if (setupMode) {
|
|
33370
|
+
process.env.MCP_TRANSPORT = 'stdio';
|
|
33371
|
+
}
|
|
33368
33372
|
const transport = (process.env.MCP_TRANSPORT || 'http').toLowerCase();
|
|
33369
33373
|
const httpPort = process.env.PORT ? parseInt(process.env.PORT, 10) : 0; // 0 = random available port
|
|
33370
33374
|
/**
|
|
33371
33375
|
* Main async function
|
|
33372
33376
|
*/
|
|
33373
33377
|
async function main() {
|
|
33374
|
-
// Run setup first if requested
|
|
33378
|
+
// Run setup first if requested, then continue to start server
|
|
33375
33379
|
if (setupMode) {
|
|
33376
33380
|
try {
|
|
33377
33381
|
const { setupMCP } = await Promise.resolve().then(() => __importStar(__webpack_require__(5021)));
|
|
33378
|
-
await setupMCP();
|
|
33379
|
-
|
|
33382
|
+
const { projectDir, port } = await setupMCP();
|
|
33383
|
+
// Set environment vars for server startup
|
|
33384
|
+
process.env.NGAO_SEARCH_PROJECT = projectDir;
|
|
33385
|
+
if (port)
|
|
33386
|
+
process.env.NGAO_SEARCH_PORT = port;
|
|
33387
|
+
console.log('\nš Starting NGAO Search MCP server...\n');
|
|
33388
|
+
// Continue to server startup below
|
|
33380
33389
|
}
|
|
33381
33390
|
catch (error) {
|
|
33382
33391
|
console.error('Setup failed:', error);
|
|
@@ -34422,14 +34431,16 @@ async function setupMCP() {
|
|
|
34422
34431
|
console.log('\nš§ NGAO Search - MCP Setup for Claude\n');
|
|
34423
34432
|
const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
|
|
34424
34433
|
const claudeConfigPath = path.join(homeDir, '.claude');
|
|
34425
|
-
const
|
|
34434
|
+
const claudeConfigFile = path.join(claudeConfigPath, 'claude_desktop_config.json');
|
|
34426
34435
|
// Check if already set up
|
|
34427
|
-
if (fs.existsSync(
|
|
34428
|
-
const existingConfig = JSON.parse(fs.readFileSync(
|
|
34436
|
+
if (fs.existsSync(claudeConfigFile)) {
|
|
34437
|
+
const existingConfig = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8'));
|
|
34429
34438
|
if (existingConfig.mcpServers?.['ngao-search']) {
|
|
34430
|
-
console.log('ā
NGAO Search is already configured in Claude
|
|
34439
|
+
console.log('ā
NGAO Search is already configured in Claude Desktop!');
|
|
34440
|
+
const projectDir = process.env.NGAO_SEARCH_PROJECT || process.cwd();
|
|
34441
|
+
const port = existingConfig.mcpServers['ngao-search'].env?.NGAO_SEARCH_PORT || '3000';
|
|
34431
34442
|
rl.close();
|
|
34432
|
-
return;
|
|
34443
|
+
return { projectDir, port };
|
|
34433
34444
|
}
|
|
34434
34445
|
}
|
|
34435
34446
|
// Ask for project directory
|
|
@@ -34443,23 +34454,24 @@ async function setupMCP() {
|
|
|
34443
34454
|
fs.mkdirSync(claudeConfigPath, { recursive: true });
|
|
34444
34455
|
}
|
|
34445
34456
|
// Read existing config or create new
|
|
34446
|
-
let
|
|
34447
|
-
if (fs.existsSync(
|
|
34448
|
-
|
|
34457
|
+
let claudeConfig = { mcpServers: {} };
|
|
34458
|
+
if (fs.existsSync(claudeConfigFile)) {
|
|
34459
|
+
claudeConfig = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8'));
|
|
34449
34460
|
}
|
|
34450
34461
|
// Add ngao-search server config
|
|
34451
|
-
|
|
34452
|
-
|
|
34462
|
+
claudeConfig.mcpServers = claudeConfig.mcpServers || {};
|
|
34463
|
+
claudeConfig.mcpServers['ngao-search'] = {
|
|
34453
34464
|
command: 'npx',
|
|
34454
34465
|
args: ['@ngao/search@alpha'],
|
|
34455
34466
|
env: {
|
|
34456
34467
|
NGAO_SEARCH_PORT: port,
|
|
34457
34468
|
NGAO_SEARCH_PROJECT: resolvedProjectDir,
|
|
34469
|
+
MCP_TRANSPORT: 'stdio',
|
|
34458
34470
|
},
|
|
34459
34471
|
};
|
|
34460
|
-
// Write config
|
|
34461
|
-
fs.writeFileSync(
|
|
34462
|
-
console.log(`\nā
|
|
34472
|
+
// Write to Claude Desktop config
|
|
34473
|
+
fs.writeFileSync(claudeConfigFile, JSON.stringify(claudeConfig, null, 2));
|
|
34474
|
+
console.log(`\nā
Claude Desktop config updated: ${claudeConfigFile}\n`);
|
|
34463
34475
|
// Create .ngao-search config in project
|
|
34464
34476
|
const projectConfigPath = path.join(resolvedProjectDir, '.ngao-search.json');
|
|
34465
34477
|
if (!fs.existsSync(projectConfigPath)) {
|
|
@@ -34467,26 +34479,24 @@ async function setupMCP() {
|
|
|
34467
34479
|
port,
|
|
34468
34480
|
indexDir: path.join(resolvedProjectDir, '.ngao-search-index'),
|
|
34469
34481
|
includePaths: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.py', '**/*.md'],
|
|
34470
|
-
excludePaths: ['node_modules/**', 'dist/**', '.git/**'],
|
|
34482
|
+
excludePaths: ['node_modules/**', 'dist/**', '.git/**', '.ngao-search-index/**'],
|
|
34471
34483
|
};
|
|
34472
34484
|
fs.writeFileSync(projectConfigPath, JSON.stringify(projectConfig, null, 2));
|
|
34473
34485
|
console.log(`ā
Project config created: ${projectConfigPath}\n`);
|
|
34474
34486
|
}
|
|
34475
34487
|
// Show setup instructions
|
|
34476
|
-
console.log('š Setup
|
|
34477
|
-
console.log('
|
|
34478
|
-
console.log('
|
|
34479
|
-
console.log('
|
|
34480
|
-
console.log('
|
|
34481
|
-
console.log('
|
|
34482
|
-
console.log('
|
|
34483
|
-
console.log(
|
|
34484
|
-
console.log(`š Server port: ${port}\n`);
|
|
34488
|
+
console.log('š Setup Complete!\n');
|
|
34489
|
+
console.log('⨠NGAO Search is now integrated with Claude Desktop');
|
|
34490
|
+
console.log('Starting server on port ' + port + '...\n');
|
|
34491
|
+
console.log('ā¹ļø Configuration Details:');
|
|
34492
|
+
console.log('š Project directory: ' + resolvedProjectDir);
|
|
34493
|
+
console.log('š Server port: ' + port);
|
|
34494
|
+
console.log('š Claude config: ' + claudeConfigFile);
|
|
34495
|
+
console.log('š Project config: ' + projectConfigPath + '\n');
|
|
34485
34496
|
rl.close();
|
|
34497
|
+
return { projectDir: resolvedProjectDir, port };
|
|
34486
34498
|
}
|
|
34487
34499
|
exports.setupMCP = setupMCP;
|
|
34488
|
-
// Run setup
|
|
34489
|
-
setupMCP().catch(console.error);
|
|
34490
34500
|
|
|
34491
34501
|
|
|
34492
34502
|
/***/ },
|
package/package.json
CHANGED