Uses CrewAI for AI-powered multi-agent systems to convert natural language to SQL queries
Supports connecting to and querying MySQL databases with natural language, including schema analysis and query validation
Includes a built-in NBA sample database for testing with player, team, and game statistics
Leverages OpenAI's models for natural language processing and SQL generation
Supports connecting to and querying PostgreSQL databases with natural language, including schema analysis and query validation
Supports connecting to and querying SQLite databases with natural language, including schema analysis and query validation
NLSQL MCP Server (Node.js)
A production-ready Node.js package that provides an MCP (Model Context Protocol) server for converting natural language questions into SQL queries using AI-powered multi-agent systems.
Quick Start
Features
- AI-Powered: Converts natural language to SQL using OpenAI and CrewAI
- Multi-Database: Supports SQLite, PostgreSQL, and MySQL
- Smart Analysis: AI-powered database schema analysis
- Easy Installation: One-command setup with automatic Python dependency management
- MCP Protocol: Full JSON-RPC implementation compatible with Claude Desktop and other MCP clients
- Safe Execution: Query validation and configurable limits
- Sample Data: Built-in NBA database for testing
- Production Ready: Comprehensive error handling and logging
Prerequisites
- Node.js 14+: JavaScript runtime
- Python 3.8+: For the underlying MCP server
- OpenAI API Key: For natural language processing
Installation
Global Installation (Recommended)
Local Installation
The package will automatically:
- Detect your Python installation
- Install required Python dependencies
- Set up the NLSQL MCP server
- Verify the installation
Configuration
Environment Setup
Claude Desktop Setup (Step-by-Step)
Step 1: Install the Package
Step 2: Get Your OpenAI API Key
- Go to OpenAI API Keys
- Create a new API key
- Copy the key (starts with
sk-
)
Step 3: Find Your Claude Desktop Config File
On Windows:
- Press
Windows + R
- Type
%APPDATA%\Claude
- Look for
claude_desktop_config.json
On Mac:
- Open Finder
- Press
Cmd + Shift + G
- Type
~/Library/Application Support/Claude
- Look for
claude_desktop_config.json
On Linux:
- Open file manager
- Go to
~/.config/Claude
- Look for
claude_desktop_config.json
Step 4: Edit the Config File
If the file exists: Open it and add the nlsql configuration to the existing mcpServers
section.
If the file doesn't exist: Create a new file called claude_desktop_config.json
with this content:
Important: Replace sk-your-actual-api-key-here
with your real OpenAI API key!
Step 5: Restart Claude Desktop
- Completely close Claude Desktop
- Open Claude Desktop again
- The nlsql server should now be available
Step 6: Test It Works
In Claude Desktop, try asking:
If it works, you'll see Claude connect to the NBA sample database!
Usage
Command Line Interface
Programmatic Usage
Available Tools
When running, the server provides these MCP tools:
Tool | Description |
---|---|
connect_database | Connect to SQLite, PostgreSQL, or MySQL |
connect_sample_database | Connect to built-in NBA sample database |
natural_language_to_sql | Convert questions to SQL using AI |
execute_sql_query | Execute SQL queries safely |
analyze_schema | AI-powered database schema analysis |
get_database_info | Get table and column information |
validate_sql_query | Validate SQL syntax |
get_table_sample | Get sample data from tables |
get_connection_status | Check database connection status |
disconnect_database | Disconnect from database |
Examples
Claude Desktop Usage
After setting up Claude Desktop integration, you can use natural language to interact with your databases:
Sample Database
Test with the built-in NBA database (30 teams, 15 tables with players, games, stats):
Then ask questions like:
- "How many teams are in the NBA?" → Returns: 30 teams
- "Show me sample data from the team table"
- "List teams from California"
- "Validate this SQL: SELECT COUNT(*) FROM team"
Testing
Troubleshooting
Common Issues
"Python not found"
"Failed to install Python dependencies"
"OpenAI API key not found"
"Server won't start"
Debug Mode
Run with debug mode for detailed logging:
Log Files
Logs are written to:
- Linux/macOS:
~/.config/nlsql-mcp-server/logs/
- Windows:
%APPDATA%\nlsql-mcp-server\logs\
Integration Examples
VS Code with Continue.dev
Add to your Continue.dev configuration:
Custom Applications
Performance
- Startup Time: ~2-3 seconds
- Database Operations: <1 second (connect, query, validate)
- AI Processing: 5-15 seconds (natural language to SQL, schema analysis)
- Memory Usage: ~100-200MB
- Database Support: SQLite, PostgreSQL, MySQL
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
npm test
- Submit a pull request
License
MIT License - see LICENSE file for details.
Credits
- Original Python Server: NLSQL MCP Server
- Underlying Application: nl2sql
- Built with: Model Context Protocol (MCP), CrewAI, OpenAI
Support
- Issues: GitHub Issues
- Documentation: GitHub Repository
- Discussions: GitHub Discussions
Made by Tushar Badhwar
This server cannot be installed
A Node.js package that provides a Model Context Protocol server for converting natural language questions into SQL queries using AI-powered multi-agent systems.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server implementation that enables AI assistants to execute SQL queries and interact with SQLite databases through a structured interface.Last updated -7TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.Last updated -3Python
- AsecurityFlicenseAqualityA Model Context Protocol server that allows AI agents to execute SQL queries against a MySQL database, supporting operations like reading data, creating tables, inserting, updating, and deleting records.Last updated -67792JavaScript
- AsecurityFlicenseAqualityA Model Context Protocol server that enables AI clients to interact with BlazeSQL's Natural Language Query API, allowing natural language queries against SQL databases.Last updated -1JavaScript