Nectar CLI
用于查询Nectar数据库模式和存储过程的命令行工具,支持自然语言。
快速入门(Windows)
选项1:带翼子板的自动安装(Windows 10/11)
打开 命令提示符 以管理员身份运行:
winget install OpenJS.NodeJS.LTS
winget install Git.Git关闭并重新打开命令提示符,然后:
npm install -g git+https://github.com/jcolernectar/nectar-cli.git选项2:使用Chocolatey自动安装
如果您安装了Chocolatey,请打开 命令提示符 作为管理员:
choco install nodejs git -y关闭并重新打开命令提示符,然后:
npm install -g git+https://github.com/jcolernectar/nectar-cli.git选项3:手动安装
- 下载并安装Node.js:https://nodejs.org/(LTS版本)
- 下载并安装Git:https://git-scm.com/download/win
- 打开 命令提示符 (非PowerShell)并运行:
npm install -g git+https://github.com/jcolernectar/nectar-cli.git重要:始终使用 命令提示符 (cmd),而不是PowerShell,以避免执行策略错误。
先决条件
上面的自动安装命令将安装:
- Node.js (版本14或更高)-包括npm
- Git -需要从GitHub安装
要验证安装:
node --version
npm --version
git --version安装
来自GitHub
npm install -g git+https://github.com/jcolernectar/nectar-cli.git从地方发展
cd C:\Users\JColer\nectar-cli
npm install
npm link设置
使用API密钥和终结点配置CLI:
# Set your API key (from Applications in Nectar)
nectar config:set-key YOUR_64_CHAR_API_KEY_HERE
# Set the endpoint (default: https://staging-api.magazinemanager.biz)
nectar config:set-endpoint https://staging-api.magazinemanager.biz
# Verify configuration
nectar config用法
自然语言查询(推荐)
用简单的英语提问——人工智能会找出使用哪些工具:
nectar ask "What tables are used in the opportunities module?"
nectar ask "Show me the schema for customer-related tables"
nectar ask "How does usp_ProcessOrder work?"
nectar ask "What are the parameters for usp_GetCustomerData?"直接命令
搜索对象
# Search by keyword
nectar search "customer"
nectar search "order"
# Include full schemas in results
nectar search "invoice" --full获取表架构
nectar schema Customers
nectar schema dbo.Orders
nectar table Invoices # 'table' is an alias for 'schema'获取程序详细信息
nectar proc usp_GetCustomerData
nectar procedure usp_ProcessOrder # 'procedure' is an alias for 'proc'发现数据库
# Show all objects
nectar discover
# Show only specific types
nectar discover --tables
nectar discover --procs
nectar discover --views
nectar discover --functions服务器信息
# Show server and role info
nectar info
# List all available tools
nectar tools配置管理
# Show current configuration
nectar config
# Clear all configuration
nectar config:clear示例
示例1:探索新模块
# Start with natural language
nectar ask "I'm working on the billing module. What tables and procedures should I know about?"
# Drill down on specific tables
nectar schema Invoices
nectar schema Payments
# Check procedure details
nectar proc usp_CreateInvoice示例2:理解存储过程
# Ask about the procedure
nectar ask "How does usp_ProcessOrder work and what tables does it use?"
# Get full details
nectar proc usp_ProcessOrder示例3:查找相关对象
# Search for all customer-related objects
nectar search "customer" --full
# Get specific table schemas
nectar schema Customers
nectar schema CustomerAddresses配置文件位置
CLI将配置存储在:
- 视窗:
%APPDATA%\nectar-cli\config.json - macOS:
~/Library/Preferences/nectar-cli/config.json - Linux:
~/.config/nectar-cli/config.json
故障排除
API密钥无效
# Verify your API key is 64 characters
nectar config
# Get a new API key from Applications in Nectar
# Set it again:
nectar config:set-key YOUR_NEW_API_KEY连接错误
# Verify endpoint is correct
nectar config
# Test connection
nectar info权限错误
# Check which role your API key is using
nectar info
# Contact admin to verify role has MCP enabled and correct permissions发展
项目结构
nectar-cli/
├── bin/
│ └── nectar.js # Main CLI entry point
├── lib/
│ ├── api.js # API client
│ ├── config.js # Configuration management
│ ├── formatter.js # Output formatting
│ └── commands/ # Command implementations
│ ├── ask.js
│ ├── config.js
│ ├── discover.js
│ ├── proc.js
│ ├── schema.js
│ └── search.js
├── package.json
└── README.md局部测试
# Install dependencies
npm install
# Link for local testing
npm link
# Test commands
nectar config
nectar info调试
启用调试模式以查看原始API响应:
DEBUG=true nectar ask "show me customer tables"支持
对于问题或疑问:
- 检查配置:
nectar config - 测试连接:
nectar info - 联系您的Nectar管理员
许可证
私人-仅供内部使用
