feat: add npx support for zero-installation usage (closes #15)
- Add bin configuration to package.json for npx execution - Implement smart database path resolution for npx/global/local installs - Create dedicated npm publish script using runtime-only dependencies - Add .npmignore to control published package contents - Update README with npx as primary installation method - Add n8n version badge to README - Sync version between package.json and package.runtime.json - Update CHANGELOG for v2.7.8 release This allows users to run 'npx n8n-mcp' without installing the package, reducing friction and making it easier to get started with n8n-MCP. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,8 @@ export class NodeDocumentationService {
|
||||
private initialized: Promise<void>;
|
||||
|
||||
constructor(dbPath?: string) {
|
||||
this.dbPath = dbPath || process.env.NODE_DB_PATH || path.join(process.cwd(), 'data', 'nodes.db');
|
||||
// Determine database path with multiple fallbacks for npx support
|
||||
this.dbPath = dbPath || process.env.NODE_DB_PATH || this.findDatabasePath();
|
||||
|
||||
// Ensure directory exists
|
||||
const dbDir = path.dirname(this.dbPath);
|
||||
@@ -79,6 +80,32 @@ export class NodeDocumentationService {
|
||||
this.initialized = this.initializeAsync();
|
||||
}
|
||||
|
||||
private findDatabasePath(): string {
|
||||
const fs = require('fs');
|
||||
|
||||
// Priority order for database locations:
|
||||
// 1. Local working directory (current behavior)
|
||||
const localPath = path.join(process.cwd(), 'data', 'nodes.db');
|
||||
if (fs.existsSync(localPath)) {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
// 2. Package installation directory (for npx)
|
||||
const packagePath = path.join(__dirname, '..', '..', 'data', 'nodes.db');
|
||||
if (fs.existsSync(packagePath)) {
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
// 3. Global npm modules directory (for global install)
|
||||
const globalPath = path.join(__dirname, '..', '..', '..', 'data', 'nodes.db');
|
||||
if (fs.existsSync(globalPath)) {
|
||||
return globalPath;
|
||||
}
|
||||
|
||||
// 4. Default to local path (will be created if needed)
|
||||
return localPath;
|
||||
}
|
||||
|
||||
private async initializeAsync(): Promise<void> {
|
||||
try {
|
||||
this.db = await createDatabaseAdapter(this.dbPath);
|
||||
|
||||
Reference in New Issue
Block a user