@ngao/search 1.0.0-alpha.3 → 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.
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  /******/ (() => { // webpackBootstrap
2
3
  /******/ var __webpack_modules__ = ({
3
4
 
@@ -33364,18 +33365,27 @@ const logger_1 = __webpack_require__(1789);
33364
33365
  // Check for --setup flag for interactive setup
33365
33366
  const args = process.argv.slice(2);
33366
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
+ }
33367
33372
  const transport = (process.env.MCP_TRANSPORT || 'http').toLowerCase();
33368
33373
  const httpPort = process.env.PORT ? parseInt(process.env.PORT, 10) : 0; // 0 = random available port
33369
33374
  /**
33370
33375
  * Main async function
33371
33376
  */
33372
33377
  async function main() {
33373
- // Run setup first if requested
33378
+ // Run setup first if requested, then continue to start server
33374
33379
  if (setupMode) {
33375
33380
  try {
33376
33381
  const { setupMCP } = await Promise.resolve().then(() => __importStar(__webpack_require__(5021)));
33377
- await setupMCP();
33378
- process.exit(0);
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
33379
33389
  }
33380
33390
  catch (error) {
33381
33391
  console.error('Setup failed:', error);
@@ -34421,14 +34431,16 @@ async function setupMCP() {
34421
34431
  console.log('\nšŸ”§ NGAO Search - MCP Setup for Claude\n');
34422
34432
  const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
34423
34433
  const claudeConfigPath = path.join(homeDir, '.claude');
34424
- const mcpConfigFile = path.join(claudeConfigPath, 'mcp.json');
34434
+ const claudeConfigFile = path.join(claudeConfigPath, 'claude_desktop_config.json');
34425
34435
  // Check if already set up
34426
- if (fs.existsSync(mcpConfigFile)) {
34427
- const existingConfig = JSON.parse(fs.readFileSync(mcpConfigFile, 'utf8'));
34436
+ if (fs.existsSync(claudeConfigFile)) {
34437
+ const existingConfig = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8'));
34428
34438
  if (existingConfig.mcpServers?.['ngao-search']) {
34429
- console.log('āœ… NGAO Search is already configured in Claude MCP!');
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';
34430
34442
  rl.close();
34431
- return;
34443
+ return { projectDir, port };
34432
34444
  }
34433
34445
  }
34434
34446
  // Ask for project directory
@@ -34442,23 +34454,24 @@ async function setupMCP() {
34442
34454
  fs.mkdirSync(claudeConfigPath, { recursive: true });
34443
34455
  }
34444
34456
  // Read existing config or create new
34445
- let mcpConfig = { mcpServers: {} };
34446
- if (fs.existsSync(mcpConfigFile)) {
34447
- mcpConfig = JSON.parse(fs.readFileSync(mcpConfigFile, 'utf8'));
34457
+ let claudeConfig = { mcpServers: {} };
34458
+ if (fs.existsSync(claudeConfigFile)) {
34459
+ claudeConfig = JSON.parse(fs.readFileSync(claudeConfigFile, 'utf8'));
34448
34460
  }
34449
34461
  // Add ngao-search server config
34450
- mcpConfig.mcpServers = mcpConfig.mcpServers || {};
34451
- mcpConfig.mcpServers['ngao-search'] = {
34462
+ claudeConfig.mcpServers = claudeConfig.mcpServers || {};
34463
+ claudeConfig.mcpServers['ngao-search'] = {
34452
34464
  command: 'npx',
34453
34465
  args: ['@ngao/search@alpha'],
34454
34466
  env: {
34455
34467
  NGAO_SEARCH_PORT: port,
34456
34468
  NGAO_SEARCH_PROJECT: resolvedProjectDir,
34469
+ MCP_TRANSPORT: 'stdio',
34457
34470
  },
34458
34471
  };
34459
- // Write config file
34460
- fs.writeFileSync(mcpConfigFile, JSON.stringify(mcpConfig, null, 2));
34461
- console.log(`\nāœ… MCP configuration saved to: ${mcpConfigFile}\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`);
34462
34475
  // Create .ngao-search config in project
34463
34476
  const projectConfigPath = path.join(resolvedProjectDir, '.ngao-search.json');
34464
34477
  if (!fs.existsSync(projectConfigPath)) {
@@ -34466,26 +34479,24 @@ async function setupMCP() {
34466
34479
  port,
34467
34480
  indexDir: path.join(resolvedProjectDir, '.ngao-search-index'),
34468
34481
  includePaths: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.py', '**/*.md'],
34469
- excludePaths: ['node_modules/**', 'dist/**', '.git/**'],
34482
+ excludePaths: ['node_modules/**', 'dist/**', '.git/**', '.ngao-search-index/**'],
34470
34483
  };
34471
34484
  fs.writeFileSync(projectConfigPath, JSON.stringify(projectConfig, null, 2));
34472
34485
  console.log(`āœ… Project config created: ${projectConfigPath}\n`);
34473
34486
  }
34474
34487
  // Show setup instructions
34475
- console.log('šŸ“ Setup Instructions:\n');
34476
- console.log('1. Claude now has access to NGAO Search MCP server');
34477
- console.log('2. When you ask Claude about your code, it can:');
34478
- console.log(' - Search through your project files');
34479
- console.log(' - Index and understand your codebase');
34480
- console.log(' - Provide context-aware code suggestions\n');
34481
- console.log('3. Restart Claude Desktop for changes to take effect\n');
34482
- console.log(`šŸ“ Project directory: ${resolvedProjectDir}`);
34483
- 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');
34484
34496
  rl.close();
34497
+ return { projectDir: resolvedProjectDir, port };
34485
34498
  }
34486
34499
  exports.setupMCP = setupMCP;
34487
- // Run setup
34488
- setupMCP().catch(console.error);
34489
34500
 
34490
34501
 
34491
34502
  /***/ },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngao/search",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "NGAO Search - Model Context Protocol Server for Local Code/Document Search with LLM-Friendly Output",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  "scripts": {
18
18
  "build": "npm run build:backend && npm run clean:dist",
19
19
  "build:backend": "webpack --config webpack.backend.config.js --mode production && tsc --emitDeclarationOnly",
20
- "build:bundled": "BUNDLE=true webpack --config webpack.backend.config.js && npm run clean:dist:bundled",
20
+ "build:bundled": "BUNDLE=true webpack --config webpack.backend.config.js && npm run add:shebang && npm run clean:dist:bundled",
21
+ "add:shebang": "node -e \"const fs=require('fs');const f='dist-bundled/main.js';const c=fs.readFileSync(f,'utf8');if(!c.startsWith('#!')){fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c);console.log('āœ“ Shebang added');}\"",
21
22
  "clean:dist": "rm -rf dist/backend dist/cli dist/mcp dist/shared dist/index.* dist/**/*.map dist/*.map 2>/dev/null; true",
22
23
  "clean:dist:bundled": "rm -rf dist-bundled/backend dist-bundled/cli dist-bundled/mcp dist-bundled/shared dist-bundled/*.map 2>/dev/null; true",
23
24
  "start": "npm run build && node dist/main.js",