Local CLI AI Integration#
QueryMind supports integration with local AI CLI tools, allowing you to use your existing AI assistants (Claude Code, OpenAI Codex) with direct database access.
Prerequisites#
Important: Node.js is required to run the MCP server that enables Local CLI AI integration.
Node.js Installation#
Before using Local CLI AI features, you must have Node.js installed on your system:
| Platform | Installation |
|---|---|
| macOS | Download Node.js or use brew install node |
| Windows | Download Node.js (LTS version recommended) |
| Linux | Download Node.js or use your package manager |
Verify Installation:
node --version
# Should output: v18.x.x or higher
Overview#
Local CLI AI integration enables CLI-based AI tools to interact with your database through QueryMind's MCP (Model Context Protocol) server. This means your AI assistant can:
- List schemas and tables in your database
- View detailed schema information
- Execute SELECT queries to explore data
- Run data modifications with confirmation
- Access your database context without manual setup
Supported AI Tools#
| Tool | Description | Requirements |
|---|---|---|
| Claude Code | Anthropic's CLI for Claude | claude CLI installed |
| OpenAI Codex | OpenAI's coding assistant | codex CLI installed |
Setup#
Step 1: Install Node.js#
Make sure Node.js is installed on your system. See the Prerequisites section above.
Step 2: Install a CLI Tool#
Install Claude Code or Codex CLI on your system:
- Claude Code: Installation Guide
- OpenAI Codex: Installation Guide
Step 3: Enable in QueryMind#
- Open QueryMind and connect to a database
- Go to Settings > AI > Local CLI AI
- Click the refresh button to detect installed CLI tools
- Select the detected CLI tool to enable it
- Click Register to register QueryMind's MCP server with your CLI
Step 4: Start Using#
Once configured, your AI CLI tool can access your database:
claude "Show me all schemas in the database"
claude "List tables in the main schema"
claude "Find customers who signed up this month"
How It Works#
AI CLI Tool (Claude/Codex)
↓
MCP Protocol
↓
QueryMind Desktop
↓
Your Database
- Your AI CLI sends requests via MCP protocol
- QueryMind receives requests through its MCP server
- QueryMind executes queries on your connected database
- Results are returned to the AI for analysis
Copy Code Snippets#
When the AI generates code in its responses:
- Hover over any code block to reveal the Copy button
- Click to copy the entire snippet to your clipboard
- Use the copied SQL queries directly in your database tools
Available Database Operations#
Read Operations (No Confirmation Required)#
| Operation | Description |
|---|---|
list_schemas | List all schemas/databases in server |
list_tables | List all tables in a specific schema |
get_table_schema | Get columns, indexes, and foreign keys |
get_sample_data | Preview rows from a table |
execute_select | Run SELECT queries |
count_rows | Count rows with optional filter |
explain_query | Get query execution plan |
Write Operations (Confirmation Required)#
| Operation | Description | Confirmation |
|---|---|---|
execute_dml | INSERT, UPDATE, DELETE | Single confirmation |
execute_ddl | CREATE, ALTER, DROP | Double confirmation |
Safety: All write operations require explicit confirmation in the QueryMind app to prevent accidental data changes.
Redis Support#
For Redis connections, different operations are available:
Read Operations (No Confirmation Required)#
| Operation | Description |
|---|---|
redis_scan | Scan keys matching pattern |
redis_get | Get string value |
redis_hgetall | Get all hash fields |
redis_lrange | Get list elements |
redis_smembers | Get set members |
redis_zrange | Get sorted set elements |
redis_type | Get key type |
redis_ttl | Get key TTL |
redis_dbsize | Get total key count |
redis_info | Get server information |
Write Operations (Confirmation Required)#
| Operation | Description | Confirmation |
|---|---|---|
redis_set | Set string value | Single confirmation |
redis_hset | Set hash field | Single confirmation |
redis_lpush | Push to list head | Single confirmation |
redis_rpush | Push to list tail | Single confirmation |
redis_sadd | Add to set | Single confirmation |
redis_zadd | Add to sorted set | Single confirmation |
redis_expire | Set key expiration | Single confirmation |
redis_del | Delete keys | Double confirmation |
Safety: All write operations require explicit confirmation in the QueryMind app to prevent accidental data changes.
Example Usage#
List Schemas#
"What schemas are available in this database?"
List Tables#
"What tables are in the main schema?"
Explore Schema#
"Show me the structure of the users table"
Query Data#
"Find the top 10 customers by order count"
Complex Analysis#
"Analyze the relationship between orders and products tables,
then show me products that have never been ordered"
Session Management#
When using Local CLI AI, QueryMind maintains conversation sessions with your CLI tool. This allows for multi-turn conversations where the AI remembers context from previous queries.
Session Indicator#
The AI Panel displays the active CLI session ID when connected. This helps you:
- Know which CLI session is currently active
- Track conversation continuity across queries
Reset Session#
To start a fresh conversation:
- Click the Reset button (circular arrow icon) in the AI Panel header
- Confirm the reset in the dialog
- Your next query will start a new conversation
Tip: Reset your session when switching to a different topic or when you want a clean slate.
Configuration Options#
Custom CLI Path#
If your CLI tool is installed in a non-standard location:
- Go to Settings > AI > Local CLI AI
- Click Configure Path next to the tool
- Enter the full path to the executable
Troubleshooting#
Node.js Not Installed#
If you see an error about Node.js:
- Download and install Node.js from nodejs.org
- Restart your terminal/command prompt
- Verify with
node --version - Restart QueryMind
CLI Not Detected#
- Ensure the CLI is installed globally
- Check that the CLI is in your system PATH
- Try running the CLI directly in terminal to verify
- Restart QueryMind after installing a new CLI
MCP Server Not Connecting#
- Make sure QueryMind is running
- Ensure a database is connected
- Reinstall the MCP server from Settings
Slow Response Times#
- Local CLI AI operations depend on the CLI tool's performance
- Complex queries may take longer to process
- Consider increasing the timeout setting
Platform Support#
Local CLI AI integration works on:
- macOS: Full support (Intel and Apple Silicon)
- Windows: Full support (requires Node.js in PATH)
- Linux: Full support (AppImage, deb)
Privacy & Security#
- All AI operations run locally through your CLI tool
- Database credentials stay within QueryMind
- No data is sent to QueryMind servers
- MCP communication uses local sockets/pipes
Next Steps#
- Natural Language Queries - Use the built-in AI assistant
- Query Editor - Manual query editing features