Docs/AI Features

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:

PlatformInstallation
macOSDownload Node.js or use brew install node
WindowsDownload Node.js (LTS version recommended)
LinuxDownload 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#

ToolDescriptionRequirements
Claude CodeAnthropic's CLI for Claudeclaude CLI installed
OpenAI CodexOpenAI's coding assistantcodex 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:

Step 3: Enable in QueryMind#

  1. Open QueryMind and connect to a database
  2. Go to Settings > AI > Local CLI AI
  3. Click the refresh button to detect installed CLI tools
  4. Select the detected CLI tool to enable it
  5. 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
  1. Your AI CLI sends requests via MCP protocol
  2. QueryMind receives requests through its MCP server
  3. QueryMind executes queries on your connected database
  4. 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)#

OperationDescription
list_schemasList all schemas/databases in server
list_tablesList all tables in a specific schema
get_table_schemaGet columns, indexes, and foreign keys
get_sample_dataPreview rows from a table
execute_selectRun SELECT queries
count_rowsCount rows with optional filter
explain_queryGet query execution plan

Write Operations (Confirmation Required)#

OperationDescriptionConfirmation
execute_dmlINSERT, UPDATE, DELETESingle confirmation
execute_ddlCREATE, ALTER, DROPDouble 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)#

OperationDescription
redis_scanScan keys matching pattern
redis_getGet string value
redis_hgetallGet all hash fields
redis_lrangeGet list elements
redis_smembersGet set members
redis_zrangeGet sorted set elements
redis_typeGet key type
redis_ttlGet key TTL
redis_dbsizeGet total key count
redis_infoGet server information

Write Operations (Confirmation Required)#

OperationDescriptionConfirmation
redis_setSet string valueSingle confirmation
redis_hsetSet hash fieldSingle confirmation
redis_lpushPush to list headSingle confirmation
redis_rpushPush to list tailSingle confirmation
redis_saddAdd to setSingle confirmation
redis_zaddAdd to sorted setSingle confirmation
redis_expireSet key expirationSingle confirmation
redis_delDelete keysDouble 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:

  1. Click the Reset button (circular arrow icon) in the AI Panel header
  2. Confirm the reset in the dialog
  3. 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:

  1. Go to Settings > AI > Local CLI AI
  2. Click Configure Path next to the tool
  3. Enter the full path to the executable

Troubleshooting#

Node.js Not Installed#

If you see an error about Node.js:

  1. Download and install Node.js from nodejs.org
  2. Restart your terminal/command prompt
  3. Verify with node --version
  4. 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#